[R] Setting optimizer in lme

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Feb 13 11:28:30 CET 2009


lme(..., control=lmeControl(opt="optim"))

Uwe



Ron Burns wrote:
> I am using R 2.7.0 on a linux platform. I am trying to reproduce a 2002 
> example using lme from the nlme library.
> I want to change the otimizer from the default (nlminb) to optim.
> 
> Specifically, this is what I am trying to do:
> R> library(nlme)
> R> library(car)  # for data only
> R> data(Blackmoor) # from car
> R> Blackmoor$log.exercise <- log(Blackmoor$exercise + 5/60, 2)
> R> attach(Blackmoor)
> 
> R> lme(log.exercise ~ I(age - 8)*group,
> +                      random = ~ I(age - 8) | subject,
> +                      correlation = corCAR1(form = ~ age-8|subject),
> +                      data=Blackmoor)
> Error in lme.formula(log.exercise ~ I(age - 8) * group, random = ~I(age 
> -  :
>  nlminb problem, convergence error code = 1
>  message = iteration limit reached without convergence (9)
> 
> This converged in the example that I am studying.
> Help file indicates that
> "opt     the optimizer to be used, either nlminb (the default
> since (R 2.2.0) or optim (the previous default)."
> 
> So tried to go back the old optimize that used in the 2002 example, but 
> I do not seem to be able to get there.
> 
> lmeControl(opt=optim)
> Error in match.arg(opt) : 'arg' must be NULL or a character vector
> 
> 
> R> lmeControl(opt="optim")
> $maxIter
> [1] 50
> ...
> $opt
> [1] "optim"
> ...
> 
> R> lme(log.exercise ~ I(age - 8)*group,
> +                      random = ~ I(age - 8) | subject,
> +                      correlation = corCAR1(form = ~ age-8|subject),
> +                      data=Blackmoor)
> Error in lme.formula(log.exercise ~ I(age - 8) * group, random = ~I(age 
> -  :
>  nlminb problem, convergence error code = 1
>  message = iteration limit reached without convergence (9)
> 
> Seem that the nlminb minimizer is still being. Try setting it in the
> function call:
> 
> R> lme(log.exercise ~ I(age - 8)*group,
> +                      random = ~ I(age - 8) | subject,
> +                      correlation = corCAR1(form = ~ age-8|subject),
> +                      opt=optim,
> +                      data=Blackmoor)
> Error in lme(log.exercise ~ I(age - 8) * group, random = ~I(age - 8) |  :
>  unused argument(s) (opt = function (par, fn, gr = NULL, ...,
>      method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN"),
>      lower = -Inf, upper = Inf, control = list(), hessian = FALSE)
> 
> This does not look like what I want either.  Any suggestions appreciated.
> 
> My thanks in advance,
> 
>    Ron
> 
>




More information about the R-help mailing list