[R] nls.control: increasing number of iterations

Martin Biuw emb7 at st-andrews.ac.uk
Thu Jun 2 21:05:28 CEST 2005


Hello,
I'm using the nls function and would like to increase the number of 
iterations. According to the documentation as well as other postings on 
R-help, I've tried to do this using the "control" argument:

nls(y ~ SSfpl(x, A, B, xmid, scal), data=my.data, 
control=nls.control(maxiter=200))

but no matter how much I increase "maxiter", I get the following error 
message:

Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = 
xy,  :
        number of iterations exceeded maximum of 50

The second line here suggests that the maximum number of iterations is 
still 50, despite changing the "control" argument. Also, increasing 
"maxiter" to something silly, like 50000, doesn't seem to increase the 
process time, which made me a bit suspicious that I'm not giving the 
right statement to the "control" argument. Or is the function indeed 
using the increased number of "maxiter", while the error message remains 
the same rather than reflecting the requested change to nls.control?

I should say that nls converges without increasing maxiter when I use 
the full dataset, and it is only when I use a smaller subset that the 
error occurs, possibly due to noisy data. But I would very much 
appreciate if someone could clarify whether the error message is wrong 
or if my statement to the "control" argument is wrong.

Thanks very much in advance,
Martin

-- 
Dr Martin Biuw
NERC Postdoctoral research fellow
Sea Mammal Research Unit
Gatty Marine Laboratory
University of St Andrews
St Andrews, Fife KY16 8LB
Scotland
Ph: +44-(0)1334-462677
Fax: +44-(0)1334-462632
www: http://www.smru.st-and.ac.uk




More information about the R-help mailing list