increase iterations for new version of lmer?
Asked Answered
S

1

15

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!

Stubborn answered 20/10, 2013 at 14:42 Comment(1)
It's not an error message. It's a warning.Swift
S
24

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.

Swift answered 20/10, 2013 at 16:26 Comment(3)
Thanks! I tried it, and I get this message: Warning message: In checkArgs("lmer", optCtrl = list(maxfun = 20000)) : extra argument(s) ‘optCtrl’ disregardedStubborn
Sorry, it needed to be passed to lmerControl.Swift
Note: for generalized linear mixed models (glmer, glmer.nb) use glmerControlQuetzalcoatl

© 2022 - 2024 — McMap. All rights reserved.