Hello colleagues,
I am attempting to determine the nonlinear least-squares estimates of
the nonlinear model parameters using nls. I have come across a common
problem that R users have reported when I attempt to fit a particular
3-parameter nonlinear function to my dataset:
Error in nls(r ~ tlm(a, N.fix, k, theta), data = tlm.data, start =
list(a = a.st, :
step factor 0.000488281 reduced below `minFactor' of 0.000976563
Despite modifying minFactor using nls.control, I am unable to counter
the apparent singularity in the model fit. I have also tried changing
the tolerance and start parameter values to no avail. If anyone can
provide a relatively simple solution (perhaps adjusting the gradient,
but I'm not sure how to do this), I would be most appreciative. My
dataset is:
> tlm.data
r N.fix
1 -0.52407085 76
2 0.10536052 45
3 -0.17435339 50
4 0.19415601 42
5 0.48701498 51
6 -0.50681760 83
7 -0.17435339 50
8 0.55278982 42
9 0.15219182 73
10 0.49899117 85
11 0.10821358 140
12 -0.83034830 156
13 -0.30748470 68
14 -0.22314355 50
15 0.04879016 40
16 -0.04879016 42
17 0.75377180 40
18 -0.12516314 85
19 -0.36624439 75
My function is:
tlm <- function(a,N,k,theta) (a*(1-((N/k)^theta)))
The nls fit I've coded is:
tlm.fit <- try(nls(r~tlm(a,N.fix,k,theta), data=tlm.data,
start=list(a=a.st,k=k.st,theta=1),
trace=TRUE,
control=nls.control(maxiter=6000,tol=1e-05,minFactor=1/1024)))
I'm using start values parsed in from another (previous, but not shown)
model fit. In this case,
> a.st
[1] 0.3812922
> k.st
[1] 64.66529
I happen to know the true values for the optimised parameters (from
another application), but I can't get nls to reproduce them. They are:
a = 2.0466
k = 60.8275
theta = 0.2277
Any ideas?
Regards,
Corey Bradshaw
[[alternative HTML version deleted]]
______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html