[R] nls() newbie convergence question
bernie.leemon at gmail.com
Thu Jun 5 01:15:53 CEST 2008
I'm sure this must be a nls() newbie question, but I'm stumped.
I'm trying to do the example from Draper
and Yang (1997). They give this snippet of S-Plus code:
Specify the weight function:
weight < - function(y,x1,x2,b0,b1,b2)
pred <- b0+b1*x1 + b2*x2
parms <- abs(b1*b2)^(1/3)
Fit the model
gmfit < -nls(~weight(y,x1,x2,b0,b1,b2), observe,list("starting value"))
in converting this to R, I left the weight function alone and replaced the
where dydata is the appropriate data.frame.
nls() quickly (6 iterations) finds the exact values from Draper & Yang for
b0, b1, and b2 but
despite reporting a discrepancy of only 3.760596e-29 by the 7th iteration,
it merrily goes on
to 50 iterations and thinks it never converged. how do I tell nls() that
I'm actually quite
happy with 3.760596e-29 and it need not work further?
I've attached the full file if you want to play with it.
gary mcclelland (aka bernie)
More information about the R-help