# [R-sig-ME] Extract correct DF and random variance in GLMM

Alexandre Santos @|ex@ndre@@nto@br @end|ng |rom y@hoo@com@br
Wed Jul 14 17:02:07 CEST 2021

```Hi Everyone,

I'm my "scarab" data set, I have the response variable number of species ("Richness"), and my explanatory variables are lead concentration ("PbPPM") in 9 transects ("Plot") with 5 samples by transects. But the 5 samples by transects are pseudoreplication in each variable "Plot". Explained this, I don't have 43 degress of fredom (DF) (9*5= 45 = 1PbPPM - 1 = 43) and I used GLMM for considering this ((1|Plot)). Im my example:

library(lme4)
str(scarab)
#'data.frame':  45 obs. of  4 variables:
# \$ TrapID  : num  1 2 3 4 5 6 7 8 9 10 ...
# \$ Richness: num  11 10 13 11 10 8 9 8 19 17 ...
# \$ PbPPM   : num  0.045 1.036 1.336 0.616 0.684 ...
# \$ Plot    : Factor w/ 9 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ...

# GLMM model
scara.glmer<-glmer(Richness~PbPPM + (1|Plot),data=scarab,family="poisson")
summary(scara.glmer)
#Generalized linear mixed model fit by maximum likelihood (Laplace
#  Approximation) [glmerMod]
# Family: poisson  ( log )
# Formula: Richness ~ PbPPM + (1 | Plot)
# ...
#Random effects:
# Groups Name        Variance Std.Dev.
# Plot   (Intercept) 0.2978   0.5457
#Number of obs: 45, groups:  Plot, 9
#Fixed effects:
#            Estimate Std. Error z value Pr(>|z|)
#(Intercept)   1.9982     0.2105   9.495  < 2e-16 ***
#PbPPM        -0.5625     0.1198  -4.695 2.66e-06 ***
#---
#Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

#Correlation of Fixed Effects:
(Intr)
#PbPPM -0.368

Based on this analysis, I have two questions:

1) There is no way to find the number of degrees of freedom corrected in the output because, for me is not clear in "Number of obs: 45, groups:  Plot, 9".

2) I'd like to calculate the contribution in the variance of the variable "Plot" because, in lmer models, I have Variance of the Variable/Residual variance + Variance of the Variable. Still, in the glmer I don't have the residual variance.