[R] nls() newbie convergence question

From: Bernard Leemon <bernie.leemon_at_gmail.com>
Date: Wed, 04 Jun 2008 17:15:53 -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)
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 <-

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)

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 Wed 04 Jun 2008 - 23:18:38 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 Wed 04 Jun 2008 - 23:30:58 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