[R-sig-ME] Extract correct DF and random variance in GLMM
me @end|ng |rom ph||||p@|d@y@com
Tue Aug 3 22:34:40 CEST 2021
What do you want to use the degrees of freedom for? DF are a bit of a
tricky question in mixed models. In your example, the by-plot random
intercepts actually only introduces *one* parameter into the model (for
the variance of the intercepts between plots) but in some vague sense it
feels like it should count for more than one degree of freedom since
we're able to *predict* (instead of estimate) 9 different intercepts
from this single parameter. So depending on what you're looking at,
somewhere between 1 and 9 seems like the right number, but it's quite
subtle. The GLMM FAQ discusses this a bit at different points, but
perhaps most relevant is the discussion on computing DF for AICc:
Note also that the usual "-1" degree of freedom is for the parameter
covering the residual variance, but the Poisson distribution doesn't
have a separate parameter for the variance / dispersion: the variance
is, by definition, equal to the mean. That's why there's "residual
variance" in the model summary.
That said, it sounds like you're looking for a measure like the
intra-class correlation coefficient (ICC). Timothy Lau posted some
functions to handle this a few years ago:
It also looks like the `performance` package has an implementation:
On 14/07/2021 10:02, Alexandre Santos via R-sig-mixed-models wrote:
> 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:
> scarab <- read.csv("https://raw.githubusercontent.com/Leprechault/PEN-533/master/scarab.csv")
> #'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")
> #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:
> #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.
> Thanks in advance,
> R-sig-mixed-models using r-project.org mailing list
More information about the R-sig-mixed-models