[R] newbie nls question
michael.manning at niwa.co.nz
Wed Jun 11 01:08:21 CEST 2008
On 11/06/2008 at 10:56 a.m., "Ranney, Steven" <steven.ranney at montana.edu>
> I'm tyring to fit a relatively simple nls model to some data, but keep coming
> up against the same error (code follows):
> Oto=nls(Otolith ~ Linf*(1-exp(-k(AGE-to))),
> data = ages,
> start = list(Linf=1000, k=0.1, to=0.1),
> trace = TRUE)
> The error message I keep getting is "Error in eval(expr, envir, enclos) :
> could not find function "k"". I've used this line of code for other nls
> models (with different data, parameter estimates, etc.), but have never
> gotten this error. The data is
> Are the missing values (e.g., no value for Otolith, AGE 9) having an effect?
> I am using Tinn-R as an editor
> I'm new to R, trying to get away from Rcmdr (though it has been helpful),
> and still trying to learn the language with the aid of several books on the
> R. A search of the R Archive did not prove fruitful.
> Thanks in advance,
> Steven H. Ranney
You've made a typo.
Check out the formula you passed to nls -- you forget to include a "*" after k.
What I think you want is something like
Oto <- nls(Otolith ~ Linf * (1 - exp(-k * (AGE - t0) ) ), ...)
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the R-help