problem with nls starting values
On 27-09-2012, at 21:15, Benedikt Gehr <benedikt.gehr at ieu.uzh.ch> wrote:
thanks for your reply I agree that an lm model would fit just as well, however the expectation from a mechanistic point of view would be a non-linear relationship. Also when I "simulate" data as in y_val<-115-118*exp(-0.12*(seq(1,100)+rnorm(100,0,0.8))) x_val<-seq(1:100) plot(y_val~x_val) summary(mod1<-nls(y_val~a-b*exp(-c*x_val),start=list(a=115,b=118,c=0.12))) I do not get a convergence. I obviously must be doing something wrong.
I do get convergence:
nls(y_val~a-b*exp(-c*x_val),start=list(a=115,b=118,c=0.12))
Nonlinear regression model
model: y_val ~ a - b * exp(-c * x_val)
data: parent.frame()
a b c
115.0420 117.0529 0.1192
residual sum-of-squares: 181.6
Number of iterations to convergence: 3
Achieved convergence tolerance: 1.436e-07
sessionInfo()
R version 2.15.1 Patched (2012-09-11 r60679) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base Berend