[R] nls question
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Jul 12 19:54:44 CEST 2012
See ?nls.control (referenced from ?nls).
On 12/07/2012 18:47, Felipe Carrillo wrote:
> Hi:
> Using nls how can I increase the numbers of iterations to go beyond 50.
> I just want to be able to predict for the last two weeks of the year.
> This is what I have:
>
> weight_random <- runif(50,1,24)
> weight <- sort(weight_random);weight
> weightData <- data.frame(weight,week=1:50)
> weightData
> plot(weight ~ week, weightData)
> M_model <- nls(weight ~ alpha + beta*exp(gamma*week), weightData,
> start = c(alpha = 0.0, beta = 1, gamma = 0.2), trace = TRUE)
>
> ### I get the error below:
> Error in nls(weight ~ alpha + beta * exp(gamma * week), weightData, start = c(alpha = 0, :
> number of iterations exceeded maximum of 50
>
>
> M_model
> ### predict for another 2 weeks
> newD <- data.frame(week = 1:52);newD
> newD$pred_wt <- predict(M_model, newD)
> newD
> plot(pred_wt ~ week, newD, pch = 4, col = "red", ylab = "Weight", xlab = "Week")
> with(weightData, points(week, weight,col='blue'))
>
>
> Felipe D. Carrillo
> Supervisory Fishery Biologist
> Department of the Interior
> US Fish & Wildlife Service
> California, USA
> http://www.fws.gov/redbluff/rbdd_jsmp.aspx
>
> [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> 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.
>
--
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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list