An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20040219/c1d9d14e/attachment.pl
controlling nls errors
2 messages · Bill Shipley, Douglas Bates
"Bill Shipley" <bill.shipley at usherbrooke.ca> writes:
Hello. I am using the nonlinear least squares function (nls). The
function that I am trying to fit seems to be very sensitive to the
starting values and, if these are not chosen properly, the nls function
stops and gives an error message:
Error in numericDeriv(form[[3]], names(ind), env) :
Missing value or an Infinity produced when evaluating the model
In addition: Warning message:
NaNs produced in: sqrt((quantum.yeild * I + Amax)^2 - 4 * theta *
quantum.yeild *
I want to embed the nls function within a loop so that if it gives an
error message I can automatically adjust the starting value and retry.
To do this I have to be able to test if the function has converged
within the loop. I need something like an if.error(fit) function that
will return true if there has been an error. Does such a thing exist?
Recently this issue was discussed on this list - specifically related to using try() to wrap the call the nls. The nlsList function in package nlme does exactly this. BTW, if I were Google I would ask something like "did you mean to search for Quantum.yield?"