[R] nls error handling

Prof Brian D Ripley ripley at stats.ox.ac.uk
Thu Jan 11 08:53:20 CET 2001

On Wed, 10 Jan 2001, Gregg Rosenkranz wrote:

> I'm written a function that uses nls in a loop to fit a model to resampled data.  Occasionally a sample is drawn such that the algorithm (apparently) can't converge and
> step factor reduced below minimum
> is printed to the screen.  I tried a few different settings for the minFactor parameter in nls.control with no different result.  When this happens, I would like my function to put NAs in the output matrix that holds the parameter estimates and move to the next iteration.  As it is, the function terminates upon error and the partially-filled result matrix is not returned.  Any suggestions?

Use try() around the nls call. See help(try).

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list