[R] nls question
Douglas Bates
bates at stat.wisc.edu
Mon Jun 30 18:52:32 CEST 2003
Suchandra Thapa <s-thapa-11 at alumni.uchicago.edu> writes:
> I'm running into problems trying to use the nls function to fit the some
> data. I'm invoking nls using
>
> nls(s~k/(a+r)^b, start=list(k=1, a=13, b=0.59))
>
> but I get errors indicating that the step has been reduced below the
> minimum step size or an inifinity is generated in numericDeriv. I've
> tried to use a variety of starting values for a, b, k but get similar
> errors.
>
> Is there anything I can do to get the a fit or is there an alternative
> to the nls function?
Well, first you plot the data and see if the relationship between r
and s is sufficiently well defined to estimate three parameters in a
nonlinear model. It is common to try to estimate more parameters than
can reasonably be determined from the data.
Secondly, the parameter k is conditionally linear so you can try
fitting the model as
nls(s ~ 1/(a+r)^b, start = list(a = 13, b = 0.59), alg = 'plinear',
trace = TRUE)
I recommend using trace = TRUE on difficult problems so you can see
exactly where the iterations are going.
If that shows unstable behavior then try to determine how the model is
collapsing. In particular, what is happening to the value of a?
--
Douglas Bates bates at stat.wisc.edu
Statistics Department 608/262-2598
University of Wisconsin - Madison http://www.stat.wisc.edu/~bates/
More information about the R-help
mailing list