Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

solution to the warning message using glmer

Tags:

r

warnings

lme4

As many other people, I'm having troubles running a model which uses glmer function from package lme4.

Here is my model:

model = glmer(depvar ~ variety*cover+amplitude+time+ (1|pp) + (1|stim), 
  data = datafile, family=poisson)

And here is the warning I get:

Warning message:
In checkConv(attr(opt, "derivs"), opt$par, 
  ctrl = control$checkConv,  :
    Model failed to converge with max|grad| = 0.00606839 
   (tol = 0.001, component 1)

I read at this link that if I add

control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=100000))

at the end of my model, I solve the issue. I tried, so my model is now:

model = glmer(depvar ~ variety*cover+amplitude+time+ 
   (1|pp) + (1|stim), data = datafile, family=poisson,
    control=glmerControl(optimizer="bobyqa",
            optCtrl=list(maxfun=100000)))

and it works without giving any warning message.

I would like to ask whether someone could explain what I am adding to the model, because I am not sure if I understand it. Also, is this an acceptable solution to solve the warning issue? Or anyone solved it in a different way?

Many thanks.

The output without control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000))) is:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
 Family: poisson  ( log )
Formula: depvar ~ variety * cover + amplitude +  time +      (1 | pp) + (1 | stim)
   Data: datafile

     AIC      BIC   logLik deviance df.resid 
  6916.6   6963.1  -3450.3   6900.6     2473 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-0.8955 -0.4712 -0.2797  0.3163  3.0090 

Random effects:
 Groups Name        Variance Std.Dev.
 stim   (Intercept) 0.031757 0.17821 
 pp     (Intercept) 0.008918 0.09443 
Number of obs: 2481, groups:  stim, 200; pp, 28

Fixed effects:
                       Estimate Std. Error z value Pr(>|z|)    
(Intercept)            0.77480    0.21459   3.611 0.000305 ***
variety2-1             0.04813    0.03096   1.555 0.119969    
cover2-1               0.06725    0.03096   2.172 0.029862 *  
amplitude             -0.04704    0.02685  -1.752 0.079837 .  
time                  -0.02545    0.03747  -0.679 0.496943    
variety2-1:cover2-1    0.01435    0.06170   0.233 0.816128    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
convergence code: 0
Model failed to converge with max|grad| = 0.00606839 (tol = 0.001,     component 1)

The output with control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000))) is:

Generalized linear mixed model fit by maximum likelihood (Laplace     Approximation) ['glmerMod']
Family: poisson  ( log )
Formula: depvar ~ variety * cover + amplitude + time +      (1 | pp) + (1 | stim)
 Data: datafile
Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e+05))

 AIC      BIC   logLik deviance df.resid 
 6916.6   6963.1  -3450.3   6900.6     2473 

    Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-0.8956 -0.4712 -0.2797  0.3163  3.0090 

 Random effects:
 Groups Name        Variance Std.Dev.
 stim   (Intercept) 0.031759 0.17821 
 pp     (Intercept) 0.008917 0.09443 
 Number of obs: 2481, groups:  stim, 200; pp, 28

Fixed effects:
                       Estimate Std. Error z value Pr(>|z|)    
(Intercept)            0.77480    0.21457   3.611 0.000305 ***
variety2-1             0.04813    0.03096   1.555 0.119997    
cover2-1               0.06725    0.03096   2.172 0.029860 *  
amplitude             -0.04703    0.02685  -1.751 0.079861 .  
time                  -0.02545    0.03746  -0.679 0.496889    
variety2-1:cover2-1    0.01434    0.06170   0.232 0.816160    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
like image 238
dede Avatar asked Nov 12 '15 11:11

dede


1 Answers

Since the likelihood differs by <0.1 between the model fits, and the largest relative differences in the parameters are of the order of about 10^(-4), I would say that you have successfully demonstrated that the warning is a false positive and you can proceed with your initial model.

Switching the optimizer to "bobyqa" and extending the maximum number of iterations to suppress the warning is harmless (except in wasting computer time), but not necessary.

like image 107
Ben Bolker Avatar answered Oct 31 '22 00:10

Ben Bolker