Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

increase iterations for new version of lmer?

I just updated lme4 to version 1.0-4 and when I run lmer() my mixed effects model, which was converging before, now prints this warning:

Warning message:
In (function (fn, par, lower = rep.int(-Inf, n), upper = rep.int(Inf,  :
  failure to converge in 10000 evaluations

So, I'd like to try to increase the number of iterations to see if I can fix this. (I must say I have no idea what is causing the warning, as the first part of the message sounds a bit opaque). In any case, I read in the documentation that now I should use lmerControl(), but I haven't been able to implement it. Could someone give me a specific example of how you'd do it for concreteness? (the Help file doesn't help). Here is my model:

m <- lmer(RT ~ Factor1*Factor2 + (0+Factor1+Factor2|Subject) + (1|Subject)  + (1|Item) + (0+Factor1+Factor2|Item), data= data)

Thanks a lot!

like image 386
Sol Avatar asked Oct 20 '13 14:10

Sol


People also ask

What is the difference between LMER and Glmer?

The lmer() function is for linear mixed models and the glmer() function is for generalized mixed models.

How long does Glmer run?

The second option tells glmer to fit using the "nloptwrap" optimizer (there are several other optimizers available, too), which tends to be faster than the default optimization method. The impact can be rather startling. With the default options the above model takes about 3 hours to fit.

What package is LMER in R?

Maximum likelihood or restricted maximum likelihood (REML) estimates of the pa- rameters in linear mixed-effects models can be determined using the lmer function in the lme4 package for R.

What is lme4 R?

lme4: Linear Mixed-Effects Models using 'Eigen' and S4 The models and their components are represented using S4 classes and methods. The core computational algorithms are implemented using the 'Eigen' C++ library for numerical linear algebra and 'RcppEigen' "glue". Version: 1.1-30.


1 Answers

The lmerControl function allows you to choose an optimizer and pass controls parameters to it. The parameters that control numbers of iterations or evaluations vary from function to function (as described in the help page for lmerControl). The default optimizer is "Nelder_Mead" and for that optimizer choice the maximum number of evaluations can be changed by specifying "maxfun" in the 'optCtrl' parameter list:

m <- lmer(RT ~ Factor1*Factor2 + (0+Factor1+Factor2|Subject) + 
               (1|Subject)  + (1|Item) + (0+Factor1+Factor2|Item),
          data= data, control=lmerControl(optCtrl=list(maxfun=20000) ) )

This is not a guarantee that convergence will be reached. (My experience is that the default maximum is usually sufficient.) It's perfectly possible that your data is insufficient to support the complexity of the model or the model is incorrectly constructed for the design of the study.

And belated thanks to @NBrouwer for his note to extend this advice to glmer with glmControl.

like image 90
IRTFM Avatar answered Oct 01 '22 01:10

IRTFM