[R] solving nls
jorfid
jorgen.fidjeland at slu.se
Wed Jan 25 11:19:48 CET 2012
Hi,
I have some data I want to fit with a non-linear function using nls, but it
won't solve.
> regresjon<-nls(lcfu~lN0+log10(1-(1-10^(k*t))^m), data=cfu_data,
> start=(list(lN0 = 7.6, k = -0.08, m = 2)))
Error in nls(lcfu ~ lN0 + log10(1 - (1 - 10^(k * t))^m), data = cfu_data, :
step factor 0.000488281 reduced below 'minFactor' of 0.000976562
Tried to increase minFactor and number of iteration, but resulted in
extremely high number of iterations
> regresjon2<-nls(lcfu~lN0+log(1-(1-10^(k*t))^m, base=10), data=cfu_data,
> start=(list(lN0 = 7.6, k = -0.08, m = 2)),
> control=nls.control(maxiter=50000, minFactor=1/1000000000000000000))
Error in nls(lcfu ~ lN0 + log(1 - (1 - 10^(k * t))^m, base = 10), data =
cfu_data, :
number of iterations exceeded maximum of 50000
Tried to give the derivatives, but got an error message I don't understand:
> model <- deriv(~lN0+log(1-(1-10^(k*t))^m,base=10), # rhs of model
+ c('lN0', 'k', 't', 'm'), # parameter names
+ function(lN0, k, t, m){} # arguments for result
+ )
> regresjon2<-nls(lcfu~model(lN0, k, t, m), data=cfu_data, start=(list(lN0 =
> 7.6, k = -0.08, m = 2)), control=nls.control(maxiter=50000,
> minFactor=1/1000000000000000000))
Error in qr.default(.swts * attr(rhs, "gradient")) :
NA/NaN/Inf in foreign function call (arg 1)
I have many datasets, but here is one as an example:
t lcfu
0 7.344108507
1.0625 7.166004379
1.958333333 7.317609443
3.722222222 7.099456839
6.847222222 7.009846065
16.95833333 6.7143479
28.90625 6.086498408
37.9375 5.060249368
45.29166667 3.69628886
57.29166667 1.008174184
Thanks
Jörgen
--
View this message in context: http://r.789695.n4.nabble.com/solving-nls-tp4326845p4326845.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list