[R] nls() newbie convergence problem

From: Bernard Leemon <bernie.leemon_at_gmail.com>
Date: Wed, 04 Jun 2008 18:20:40 -0600


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)
(y-pred)/parms
}
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 nls() with

gmfit <-
 nls(~weight(y,x1,x2,b0,b1,b2),data=dydata,trace=TRUE,start=list(b0=1,b1=1,b2=1))

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?

thanks for any suggestions.

gary mcclelland (aka bernie)
univ of colorado

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 05 Jun 2008 - 00:24:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 Jun 2008 - 02:30:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive