Solved – Nested random effects and interaction terms in lme4

lme4-nlmenested datarrandom-effects-model

I have a data set containing various vegetation and geomorphic variables sampled in 3 distances on both sides of 43 drainage ditches (Location). Roughly half of these ditches are occupied by a beaver, the other half is empty. Now I want to run a model with the binomial response variable Status ("beaver == 1" / "beaver == 0")

I'm struggling with the order and layout of the nested and interaction effects using glmer. So far I've got

fit <- glmer(Status ~ BankslopeScaled + Connectivity + 
                      Canal_width + Distance:Food_crops + 
                      Distance:Edible_trees + 
                (1 | Distance/Side/Location), 
              data, family=binomial(link="logit")

but I'm not sure if I still have pseudoreplication in my data or whether I correctly applied the formula in order to estimate the influence of the predictors in every distance on both sides in each Location.

Like, if food_crops in the 3rd distance on the left side is lower than edible_trees in the 2nd distance on the right side, then …

I feel like there's something wrong with my random effects-term.

My output looks like this:

summary(fit)

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: binomial  ( logit )
Formula: Status ~ BankslopeScaled + Connectivity + Canal_width + Distance:Food_crops +  
Distance:Edible_trees + (1 | Distance/Side/Location)
Data: Satz

     AIC      BIC   logLik deviance df.resid 
   314.6    360.8   -144.3    288.6      245 

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-2.18541 -0.71205  0.07243  0.82483  1.75303 

Random effects:
 Groups                   Name        Variance  Std.Dev. 
 Location:(Side:Distance) (Intercept) 2.834e-02 1.683e-01
 Side:Distance            (Intercept) 2.074e-10 1.440e-05
 Distance                 (Intercept) 2.085e-10 1.444e-05
 Number of obs: 258, groups:  Location:(Side:Distance), 258; Side:Distance, 6; Distance, 3

 Fixed effects:
                        Estimate Std. Error z value Pr(>|z|)    
 (Intercept)            -2.86517    0.79747  -3.593 0.000327 ***
 BankslopeScaled         1.76475    0.62541   2.822 0.004776 ** 
 Connectivity            0.10394    0.02729   3.809 0.000140 ***
 Canal_width             0.19138    0.11089   1.726 0.084364 .  
 Distance1:Food_crops    0.03667    0.09366   0.391 0.695441    
 Distance2:Food_crops    0.10852    0.08996   1.206 0.227694    
 Distance3:Food_crops    0.06303    0.08502   0.741 0.458510    
 Distance1:Edible_trees  0.02273    0.01327   1.712 0.086818 .  
 Distance2:Edible_trees -0.01750    0.02992  -0.585 0.558738    
 Distance3:Edible_trees  0.09769    0.07986   1.223 0.221201    
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 [correlation of fixed effects snipped]    

A point into the right direction is much appreciated!

Best Answer

A few things to keep in mind:

  • You probably shouldn't treat Distance as a random effect in any case (estimates of random effects with only 3 levels are very unreliable)
  • You already implicitly have the main effects of Distance in your model through the Distance:Food_crops and Distance:Edible_trees interactions.
  • ... for both these reasons, you should leave Distance out of your random-effects specification: (1 | Distance:Side) + (1 | Distance:Side:Location) should work to include the two lower nested levels.
  • you will still probably find that the (1|Distance:Side) random effect has variance of effectively zero ... but you might as well leave it in.
Related Question