Read the Help file! ?nls ## Note the "control" argument ?nls.control
-- Bert On Thu, Jul 12, 2012 at 10:47 AM, Felipe Carrillo <mazatlanmex...@yahoo.com>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@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. > > -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]] ______________________________________________ R-help@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.