Is there a way to get the null deviance and df for a generalized linear mixed model fit with glmer()? Is there a reason that this is not included in the summary() output, the way that it is with a glm() object?
CodePudding user response:
You can compute the null deviance by re-fitting the model with an intercept term only, e.g.
gm1 <- glmer(cbind(incidence, size - incidence) ~ period (1 | herd),
data = cbpp, family = binomial)
gm0 <- update(gm1, . ~ 1 (1|herd))
deviance(gm1) ## 73.47
deviance(gm0) ## 92.42 (null deviance)
- I'm not sure what you mean by the "null df" for the GLMM; the 'denominator degree of freedom' measure of effective sample size that works perfectly for balanced ANOVAs and questionably for linear mixed models [via inclusion/exclusion, Satterthwaite, Kenward-Roger, etc.] is hard to define for GLMMs.
- I can think of a couple of reasons that
lme4
doesn't automatically do this computation for you:- it could be an expensive re-fit (even for GLMs it does require refitting the model, see here for the code in
glm
that does it) - it's less obvious for GLMMs what the appropriate null model for comparison is. Do you remove both random and fixed effects and reduce the model to a GLM? Do you keep all of the random effects, or only intercept-level random effects, or some other mixture depending on the context of the question? Making the user do it themselves forces them to make this choice.
- it could be an expensive re-fit (even for GLMs it does require refitting the model, see here for the code in
(That said, I don't believe that omitting the null deviance was an explicit choice.)
If you do choose to discard all of the random effects (i.e. comparing to deviance(glm(cbind(incidence, size - incidence) ~ period, data =cbpp, family = binomial))
in the example above, you should be able to do a meaningful comparison with a glmer
fit, but there are some subtleties: you might want to read the section on Deviance and log-likelihood of GLMMs in ?deviance.merMod
.