Thanks Bert, I increased the  number of iterations:
 
M_model <- nls(weight ~ alpha + 
beta*exp(gamma*week),control=nls.control(maxiter=200), weightData,
             start = c(alpha = 0.0, beta = 1, gamma = 0.2), trace = TRUE)
 
But now the 'start' argument seems to be the problem. 
Looking at the model coefficients:
  alpha          beta         gamma 
-49.108008320  52.394172340   0.005269907 
If I change the alpha and beta values inside start..I still get the error...

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx



>________________________________
>From: Bert Gunter <gunter.ber...@gene.com>
>To: Felipe Carrillo <mazatlanmex...@yahoo.com> 
>Cc: "r-help@r-project.org" <r-help@r-project.org> 
>Sent: Thursday, July 12, 2012 10:56 AM
>Subject: Re: [R] nls question
>
>
>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.

Reply via email to