0
$\begingroup$

Update on the study design and data: I am testing whether increased temperatures will affect dung burial by dung beetles. The beetle species that I have used makes balls of dung and buries each dung ball. So each dung ball is a separate data point. I am trying to predict whether the dung ball is buried or not (a binary outcome). The dung beetles and dung are kept in large climate controlled chambers, and each chamber is set to an offset (+0, +2 deg or +4 deg higher than ambient field temperature). Offset therefore is my treatment, and is a 3 level fixed effect. There are 27 chambers that were randomly assigned an offset (i.e. +0= 9 chambers +2 deg=9 chambers or +4 deg n= 9 chambers). I collected 165 dung balls across the 27 chambers, so my sample size is 165 (with 2 - 12 dung balls from each chamber). Because multiple dung balls came from the same chamber and are not independent, I want to control for that by including chamber as a random effect. The model runs fine with random intercepts that vary across Chambers, but I run into trouble when I include random slopes.

I am fitting a mixed effects model with a binary outcome. I have one fixed effect (Offset, a 3 level factor) and one random effect (chamber, with multiple data points coming from each chamber). I have included random intercepts that vary across chambers to account for the non-independence of data points that come from the same chamber. My code is as follows:

ball1=glmer(Buried~Offset+(1|Chamber), family=binomial, data=rubrusballs)

Output:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
 Family: binomial  ( logit )
Formula: Buried ~ Offset + (1 | Chamber)
   Data: rubrusballs

     AIC      BIC   logLik deviance df.resid 
   207.5    219.9    -99.8    199.5      161 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-0.7884 -0.6049 -0.5695  1.2683  1.7559 

Random effects:
 Groups  Name        Variance  Std.Dev. 
 Chamber (Intercept) 8.989e-18 2.998e-09
Number of obs: 165, groups:  Chamber, 27

Fixed effects:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -1.0055     0.3018  -3.332 0.000862 ***
Offset2      -0.1205     0.4488  -0.268 0.788335    
Offset3       0.5301     0.4019   1.319 0.187229    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
        (Intr) Offst2
Offset2 -0.672       
Offset3 -0.751  0.505

I then added random slopes to my model to see if I could improve the fit of the model. My code for this second model was:

ball2=glmer(Buried~Offset+(Offset|Chamber), family=binomial, data=rubrusballs)

This second model gave me an error, as seen in the output below:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
 Family: binomial  ( logit )
Formula: Buried ~ Offset + (Offset | Chamber)
   Data: rubrusballs

     AIC      BIC   logLik deviance df.resid 
   215.3    243.3    -98.7    197.3      156 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-0.9191 -0.6282 -0.6052  1.2697  2.1458 

Random effects:
 Groups  Name        Variance  Std.Dev. Corr       
 Chamber (Intercept) 2.535e-05 0.005035            
         Offset2     9.156e-01 0.956895 -0.52      
         Offset3     5.704e-05 0.007553 -0.90  0.17
Number of obs: 165, groups:  Chamber, 27

Fixed effects:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept) -1.004476   0.003277 -306.56   <2e-16 ***
Offset2     -0.458192   0.003277 -139.83   <2e-16 ***
Offset3      0.526834   0.265622    1.98   0.0473 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
        (Intr) Offst2
Offset2 -0.250       
Offset3 -0.012  0.003
convergence code: 0
Model failed to converge with max|grad| = 0.0230258 (tol = 0.001, component 1)

I have had a similar problem with a previous data set (here), so apologies for posting a similar question. This is a different error message from last time however. I have tried a few different optimizers and these have not resolved the issue. Last time, it was suggested that the model showed a singular fit and could be reduced to include only random intercepts. I would appreciate if someone could have a look at the output of the 2nd model and offer any solutions to get the model to converge, or by looking at the output, do I even need to include random slopes?

Another question while I am here. To assess if I even need to include random intercepts/slopes, I would like to compare model fit between a glm (no random effects) and a glmer model (random effects) using the log likelihoods. However as I understand it, I can only comapre models this way if they were estimated using maximum likelihood (ML). Im pretty sure that glmer uses ML, but what about glms? Are they estimated using ML and therefore can I compare the fit of glm and glmer models?

$\endgroup$
4
  • $\begingroup$ Questions that are about software (eg, error messages) are generally off topic here. It's possible that this is a statistical question, but you need to provide more information about your data & your study. $\endgroup$ Oct 22, 2017 at 1:45
  • $\begingroup$ @gung what extra info do you need? Happy to provide extra info $\endgroup$ Oct 23, 2017 at 5:13
  • $\begingroup$ You need to tell us about your data & your study. What are your variables? How is the study designed? Etc. $\endgroup$ Oct 23, 2017 at 11:47
  • 1
    $\begingroup$ @gung I have added in some more information, I hope that makes more sense now. $\endgroup$ Oct 30, 2017 at 19:37

0

Your Answer

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