[R] nls: example code throws error

Gabor Grothendieck ggrothendieck at gmail.com
Fri Apr 26 08:31:03 CEST 2013


On Thu, Apr 25, 2013 at 7:16 PM, Steven LeBlanc <oreslag at gmail.com> wrote:
> Greets,
>
> I'm trying to learn to use nls and was running the example code for an exponential model:
>
>> x <- -(1:100)/10
>> y <- 100 + 10 * exp(x / 2) + rnorm(x)/10
>> nlmod <- nls(y ~  Const + A * exp(B * x))
> Error in B * x : non-numeric argument to binary operator
> In addition: Warning message:
> In nls(y ~ Const + A * exp(B * x)) :
>   No starting values specified for some parameters.
> Initializing ‘Const’ to '1.'.
> Consider specifying 'start' or using a selfStart model
>
> Presumably, the code should work if it is part of an example on the help page. In perusing various help forums for similar problems, it also appears that others believe this syntax should work in the model formula.
>
> Any ideas?
>

Try running in a clean session.  Having B <- "X" in your workspace
would cause such an error.

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list