31
$\begingroup$

I have seen questions about this on this forum, and I have also asked it myself in a previous post but I still haven't been able to solve my problem. Therefore I am trying again, formulating the question as clearly as I can this time, with as much detailed information as possible.

My data set has a binomial dependent variable, 3 categorical fixed effects and 2 categorical random effects (item and subject). I am using a mixed effects model using glmer(). Here is what I entered in R:

modelall<- glmer(moodR ~ group * context * condition + (1|subject) + (1|item),
                 data = RprodHSNS, family = "binomial")

I get 2 warnings:

Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 0.02081 (tol = 0.001, component 11)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?`

My summary looks like this:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: binomial  ( logit )
Formula: moodR ~ group * context * condition + (1 | subject) + (1 | item)
Data: RprodHSNS`


AIC      BIC   logLik deviance df.resid
1400.0   1479.8   -686.0   1372.0     2195 `

Scaled residuals: 
Min      1Q  Median      3Q     Max 
-8.0346 -0.2827 -0.0152  0.2038 20.6578 `

Random effects:
Groups  Name        Variance Std.Dev.
item    (Intercept) 1.475    1.215   
subject (Intercept) 1.900    1.378   
Number of obs: 2209, groups:  item, 54; subject, 45
Fixed effects:`
Estimate Std. Error z value Pr(>|z|)`                             
(Intercept)                -0.61448   42.93639  -0.014 0.988582  
group1                     -1.29254   42.93612  -0.030 0.975984    
context1                    0.09359   42.93587   0.002 0.998261   
context2                   -0.77262    0.22894  -3.375 0.000739***
condition1                  4.99219   46.32672   0.108 0.914186
group1:context1            -0.17781   42.93585  -0.004 0.996696
group1:context2            -0.10551    0.09925  -1.063 0.287741
group1:condition1          -3.07516   46.32653  -0.066 0.947075
context1:condition1        -3.47541   46.32648  -0.075 0.940199
context2:condition1        -0.07293    0.22802  -0.320 0.749087
group1:context1:condition1  2.47882   46.32656   0.054 0.957328
group1:context2:condition1  0.30360    0.09900   3.067 0.002165 **

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
            (Intr) group1 cntxt1 cntxt2 cndtn1 grp1:cnt1 grp1:2 grp1:cnd1 cnt1:1 cnt2:1 g1:1:1
group1      -1.000                                                                            
context1    -1.000  1.000                                                                
context2     0.001  0.000 -0.001                                                              
condition1  -0.297  0.297  0.297  0.000                                                       
grp1:cntxt1  1.000 -1.000 -1.000  0.001 -0.297                                                
grp1:cntxt2  0.001  0.000  0.000 -0.123  0.000  0.000                                       
grp1:cndtn1  0.297 -0.297 -0.297 -0.001 -1.000  0.297     0.000                               
cntxt1:cnd1  0.297 -0.297 -0.297 -0.001 -1.000  0.297     0.001  1.000                        
cntxt2:cnd1  0.000  0.000 -0.001  0.011  0.001  0.000    -0.197 -0.001    -0.001              
grp1:cnt1:1 -0.297  0.297  0.297  0.001  1.000 -0.297    -0.001 -1.000    -1.000  0.001       
grp1:cnt2:1  0.000  0.000  0.001 -0.198  0.000 -0.001     0.252  0.000     0.001 -0.136  0.000

Extremely high p-values, which does not seem to be possible.

In a previous post I read that one of the problems could be fixed by increasing the amount of iterations by inserting the following in the command:

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

So that's what I did:

modelall <- glmer(moodR ~ group * context * condition + (1|subject) + (1|item),
                  data = RprodHSNS, family = "binomial", 
                  glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 100000)))

Now, the second warning is gone, but the first one is still there:

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

The summary also still looks odd:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
 Family: binomial  ( logit )
Formula: moodR ~ group * context * condition + (1 | subject) + (1 | item)
   Data: RprodHSNS
Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e+05))`

AIC      BIC   logLik deviance df.resid 
1400.0   1479.8   -686.0   1372.0     2195

Scaled residuals: 
Min      1Q  Median      3Q     Max 
-8.0334 -0.2827 -0.0152  0.2038 20.6610 

Random effects:
Groups  Name        Variance Std.Dev.
item    (Intercept) 1.474    1.214   
subject (Intercept) 1.901    1.379   
Number of obs: 2209, groups:  item, 54; subject, 45

Fixed effects:
                        Estimate Std. Error z value Pr(>|z|)    
(Intercept)                -0.64869   26.29368  -0.025 0.980317    
group1                     -1.25835   26.29352  -0.048 0.961830    
context1                    0.12772   26.29316   0.005 0.996124    
context2                   -0.77265    0.22886  -3.376 0.000735 ***
condition1                  4.97325   22.80050   0.218 0.827335    
group1:context1            -0.21198   26.29303  -0.008 0.993567    
group1:context2            -0.10552    0.09924  -1.063 0.287681    
group1:condition1          -3.05629   22.80004  -0.134 0.893365    
context1:condition1        -3.45656   22.80017  -0.152 0.879500    
context2:condition1        -0.07305    0.22794  -0.320 0.748612    
group1:context1:condition1  2.45996   22.80001   0.108 0.914081    
group1:context2:condition1  0.30347    0.09899   3.066 0.002172 ** 

---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
        (Intr) group1 cntxt1 cntxt2 cndtn1 grp1:cnt1 grp1:2 grp1:cnd1 cnt1:1 cnt2:1 g1:1:1
group1      -1.000                                                                            
context1    -1.000  1.000                                                                     
context2     0.000  0.000  0.000                                                              
condition1   0.123 -0.123 -0.123 -0.001                                                       
grp1:cntxt1  1.000 -1.000 -1.000  0.001  0.123                                                
grp1:cntxt2  0.001  0.000  0.000 -0.123  0.001  0.000                                         
grp1:cndtn1 -0.123  0.123  0.123  0.000 -1.000 -0.123    -0.001                               
cntxt1:cnd1 -0.123  0.123  0.123  0.000 -1.000 -0.123     0.000  1.000                        
cntxt2:cnd1  0.000  0.000  0.000  0.011 -0.001  0.000    -0.197  0.001     0.001              
grp1:cnt1:1  0.123 -0.123 -0.123  0.000  1.000  0.123     0.000 -1.000    -1.000 -0.001      
grp1:cnt2:1  0.000 -0.001  0.001 -0.198  0.001 -0.001     0.252 -0.001     0.000 -0.136  0.000

What I can do to solve this? Or can anyone tell me what this warning even means (in a way that an R-newbie like myself can understand)?

$\endgroup$
1
  • $\begingroup$ I have no solution to this, but a similar problem right now. As has been suggested before, I think this arises due to correlations between the independent variables in my model. Those with high correlations are a factor (two levels) with its own interaction, which, in my mind, is to be expected? $\endgroup$ Commented Mar 6 at 11:54

2 Answers 2

27
$\begingroup$

There is a nice description of how to troubleshoot this issue here: https://rstudio-pubs-static.s3.amazonaws.com/33653_57fc7b8e5d484c909b615d8633c01d51.html

Basically, the recommendations are to rescale and center your variables, check for singularity, double-check gradient calculations, add more iterations by restarting from previous fit, and try different optimizers. The last recommendation (i.e., optimizers) has worked for me in the past:

e.g., add control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)) to your glmer call.

Edit: This chapter may also be helpful: https://www.learn-mlms.com/07-module-7.html

$\endgroup$
1
  • 7
    $\begingroup$ As a follow-up three years later, you can also check out Bayesian mixed effects models using the rstan or brms packages. Setting priors on the model parameters can really help convergence (especially for complex random effects structures). $\endgroup$ Commented Aug 9, 2020 at 5:55
12
$\begingroup$

The correlation of fixed effects in your last output suggests that there is a problem of multicollinearity. Some of the fixed effects are almost perfectly correlated (r = 1 or r = -1). Especially, group1 and its interactions seem to be problematic. You could check some descriptive statistics and plots of your fixed effect variables and the interactions. Maybe it's just a simple coding error in constructing the group categories.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.