6

I run a simple GLMM with lme4 ...

model1  <- glmer.nb(S ~ Days*Grazing*Biome + (Days|Site), data=mydata, verbose=T, control=ctrl)

...and run into the convergence code 1 from bobyqa: "bobyqa -- maximum number of function evaluations exceeded". So I looked up stackoverflow and found this interesting thread.

I overhauled my control object which now looks like this:

ctrl = glmerControl(optimizer = "bobyqa",
                    #restart_edge=T,
                    boundary.tol = 1e-5,
                    calc.derivs=TRUE,
                    use.last.params=FALSE,
                    sparseX = FALSE,
                    tolPwrss=1e-7,
                    compDev=TRUE,
                    nAGQ0initStep=TRUE, 
                    ## optimizer args
                    optCtrl = list(maxfun = 1e5))

But I still get the same error. Then I followed the adivse of another link where it is said that

  • you can use control=glmerControl(optCtrl=list(maxfun=1e5)) to adjust the maximum number of function evaluations. CHECK
  • if @optinfo$feval will tell you how many function evaluations were actually used. TBD

So I did model1@optinfo$feval and it says ... 172

I must admit that I was expecting something else, so I tried everything from 1e3 to 1e8 but I am still stuck.

My lme4 version is 1.1-10; I am using a Win10 64bit R3.1.3 (maybe I should upgrade my R?)

Any (!) help or comments are most appreciated! cheers

Community
  • 1
  • 1
Jens
  • 2,363
  • 3
  • 28
  • 44
  • What happens if you use a different optimizer? – Dason Oct 28 '15 at 20:45
  • setting optCtrl = list(maxfun = 1)) ... leads to --> model1.s@optinfo$feval = 7535 why ? – Jens Oct 28 '15 at 20:45
  • @Dason when I switch to Nelder_Mead I yield "1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| = 0.0809893 (tol = 0.001, component 1)" but I will try some others, thanks for that idea ! – Jens Oct 28 '15 at 20:48
  • How big is your total parameter vector (fixed effects + random effects)? I wonder if the distinction is between BOBYQA iterations and actual function evaluations. (Having just checked the BOBYQA source code, that doesn't seem to be the case though ...) – Ben Bolker Oct 28 '15 at 20:59
  • any chance of a reproducible example ... ?? – Ben Bolker Oct 28 '15 at 20:59
  • @Ben hmm how do I know how big the parameter vector is? I fear it is hard to make the example reproducable, but I will try . – Jens Oct 28 '15 at 21:08
  • assuming `Days` is numeric and not a factor, `ncol(model.matrix(~Days*Grazing*Biome, data=mydata))+2` should be about right ... (the fixed effects vector length is the product of the number of parameters per input variable, which is 2 for a numeric variable or n for a factor ...) – Ben Bolker Oct 28 '15 at 21:10
  • (if `Days` were a factor instead that could make the model very big ...) – Ben Bolker Oct 28 '15 at 21:10
  • The answer is: 18 Days is indeed numeric. – Jens Oct 28 '15 at 21:16
  • @Dason I also tried optimx with nlminb etc. nothing helped. – Jens Oct 28 '15 at 21:18
  • Hmm. Maybe this is a `glmer.nb` bug where the controls don't get passed through to the optimizer properly. What happens if you fit a Poisson model with the same structure? – Ben Bolker Oct 28 '15 at 21:22
  • @BenBolker works fine with poisson and took 5 seconds. I could live with poisson as well, but fitdistr showed me that poisson did not fit the species richness data well at all. – Jens Oct 28 '15 at 21:26
  • 3
    OK, it's probably a `glmer.nb` bug. Are you willing to send me data? – Ben Bolker Oct 28 '15 at 21:29
  • @BenBolker Sure, will do. Thank you very much for your help already! – Jens Oct 28 '15 at 21:30
  • 2
    I am very interested by the outcome of your research. What came out of your investigation ? – Yohan Obadia May 04 '16 at 13:54

0 Answers0