To add to Gabor's remarks:

This has nothing to do per se with R -- it is your insufficient
understanding of the underlying mathematical issues.

It is pretty trivial to do the plinear algorithm by hand. Fit linear
regressions
weight ~ lm(weight ~z)

where z is exp(gamma*week) for a suitable sequence of gamma values and just
choose that which gives the best fit. Or use this to get a starting value
for nls.

-- Bert



On Thu, Jul 12, 2012 at 1:03 PM, Gabor Grothendieck <ggrothendieck@gmail.com
> wrote:

> On Thu, Jul 12, 2012 at 3:40 PM, Felipe Carrillo
> <mazatlanmexico@yahoo.com> wrote:
> > I get a different error now:
> >>  nls(weight ~ cbind(1, exp(gamma*week)), weightData, start = list(gamma=
> >> 0.2), alg = "plinear")
> > Error in nls(weight ~ cbind(1, exp(gamma * week)), weightData, start =
> > list(gamma = 0.2),  :
> >   step factor 0.000488281 reduced below 'minFactor' of 0.000976562
> > The help file says: ........When start is missing, a very cheap guess for
> > start is tried (if algorithm != "plinear").
>
>
> Please give a reproducible example by setting the seed.  This
> reproducible example converges:
>
> > set.seed(123)
> > weight_random <- runif(50,1,24)
> > weight <- sort(weight_random)
> > weightData <- data.frame(weight,week=1:50)
> > nls(weight ~ cbind(1, exp(gamma*week)), weightData, start = list(gamma =
> 0.2), alg = "plinear")
> Nonlinear regression model
>   model:  weight ~ cbind(1, exp(gamma * week))
>    data:  weightData
>      gamma      .lin1      .lin2
>  1.136e-03 -3.949e+02  3.962e+02
>  residual sum-of-squares: 9.17
>
> Number of iterations to convergence: 8
> Achieved convergence tolerance: 9.581e-06
>
> as does nls with Gauss Newton:
>
> > nls(weight ~ alpha + beta*exp(gamma*week), weightData, start =
> + c(alpha = 0.0, beta = 1, gamma = 0.2)
> + )
> Nonlinear regression model
>   model:  weight ~ alpha + beta * exp(gamma * week)
>    data:  weightData
>      alpha       beta      gamma
> -3.949e+02  3.961e+02  1.136e-03
>  residual sum-of-squares: 9.17
>
> Number of iterations to convergence: 48
> Achieved convergence tolerance: 2.906e-06
>
> >
> > So I removed  'plinear' from the call and got the following:
> >  nls(weight ~ cbind(1, exp(gamma*week)), weightData,start =
> > list(gamma=0.2),trace=TRUE)
>
> It cannot be specified as if it were a plinear model but then use
> Gauss-Newton.  See ?nls
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>
> ______________________________________________
> 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]]

