[R] using nls to fit a curve to data
Ben Bolker
bolker at ufl.edu
Sat Sep 6 22:44:19 CEST 2008
jpl <s-jlubben1 <at> math.unl.edu> writes:
>
>
> Hi,
>
> I am trying to fit a curve to data. My command line is:
>
>
model10=nls(offspring~((A*c^k)/gamma(k))*
((degdays-alpha)^(k-1))*exp(-c*(degdays-alpha)),
> start=list(A=30,k=2,c=.018,alpha=131))
>
try trace=TRUE to see where the function is trying to go.
I think you could also simplify this a bit:
model10 = nls(offspring~A*dgamma(degdays-alpha,rate=c,shape=k),...)
You can probably also use algorithm="plinear" and eliminate
the explicit A parameter.
I would also consider using algorithm="port" and setting
lower and upper boundaries.
good luck,
Ben Bolker
More information about the R-help
mailing list