Re: [R] number of iteration s exceeded maximum of 50

From: Leaf Sun <leaflovesun_at_yahoo.ca>
Date: Tue 20 Jun 2006 - 04:51:24 EST

Thanks to Douglas and all others who responded.

I applied nls(y ~ a*x^b, start = list(a = a1, b = b1), control = list(maxiter = 500), trace=TRUE) to increase the number of iterations, found it successful. The suggestion Douglas raised in plotting the data and then tracing the optim numbers is correct because I found when I gave the number of b1 oppositely(say, should be positive, then given negative), nls( ) would never reached the convergence. Thanks for the nice suggestions!

Leaf

> Sorry, I thought it was a straightforward question inside which I was stuck .
>
> I used nls( ) to estimate a and b in this function.
>
> nls(y~ a*x^b,start=list(a=a1,b=b1)
>
> seems the start list I gave was not able to reach convergence and it gave notes: number of iteration s exceeded maximum of 50. Then I put nls.control(maxiter = 50, tol = 1e-05, minFactor = 1/1024) in nls(.. ), and modified the argument of maxiter = 500. But it worked out as the same way and noted : number of iteration s exceeded maximum of 50. I have totally no idea how to set this parameter MAXITER.
>
> Thanks for any information!

I think you are assuming that values passed to nls.control are persistent and will apply to further calls to nls. They don't. If you want to increase the maximum number of iterations you do it as

nls(y ~ a*x^b, start = list(a = a1, b = b1), control = list(maxiter = 500))

but I would suggest that you also use trace = TRUE in the call to nls so you can see where the iterations are going. Merely increasing the number of iterations for an optimization that has gone into never-never land isn't going to help it converge.

Two other things to consider: this is a partially linear model in the the parameter `a' appears linearly in the model expression. You may be able to stabilize the iterations using

 nls(y ~ x^b, start = list(b = b1), control = list(maxiter = 500), trace = TRUE, alg = 'plinear')

Finally, and most important, please plot the data before trying to fit a nonlinear model to it so you can see if it has the characteristics that you would expect from data generate by such a model. As Brian Joiner said, "Regression without plots is truly a regression".
>
> Leaf
>
>
> > Hi all,
> >
> > I found r-site-research not work for me these days.
> >
> > When I was doing nls( ) , there was an error "number of iterations exceeded maximum of 50". I set number in nls.control which is supposed to control the number of iterations but it didn't work well. Could anybody with this experience tell me how to fix it? Thanks in advance!
>
> We cannot make suggestions unless you tell us what you tried yourself.
> Id possible, please gibīve a reproducible examle.
>
> Uwe Ligges
>
> > Leaf
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jun 20 05:01:31 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 18 Jul 2006 - 06:16:07 EST.

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