Calculates the deviance of a model of class merMod. Some important details regarding the calculation of the deviance is found below.
# S3 method for merMod
deviance(object, REML = NULL, ...)
an R object of class merMod, i.e.,
as resulting from lmer(), or glmer(),
etc.
Logical. If TRUE, return the restricted log-likelihood
rather than the log-likelihood. If NULL (the default),
set REML to isREML(object) (see isREML).
Optional additional arguments.
One must be careful when defining the deviance of a GLM. For example, should the deviance be defined as minus twice the log-likelihood or does it involve subtracting the deviance for a saturated model? To distinguish these two possibilities we refer to absolute deviance (minus twice the log-likelihood) and relative deviance (relative to a saturated model, e.g. Section 2.3.1 in McCullagh and Nelder 1989).
With GLMMs however, there is an additional complication involving the
distinction between the likelihood and the conditional likelihood.
The latter is the likelihood obtained by conditioning on the estimates
of the conditional modes of the spherical random effects coefficients,
whereas the likelihood itself (i.e. the unconditional likelihood)
involves integrating out these coefficients. The following table
summarizes how to extract the various types of deviance for a
glmerMod object:
| conditional | unconditional | |
| relative | deviance(object) | NA in lme4 |
| absolute | object@resp$aic() | -2*logLik(object) |
This table requires two caveats:
If the link function involves a scale parameter
(e.g. Gamma) then object@resp$aic() - 2 * getME(object,
"devcomp")$dims["useSc"] is required for the absolute-conditional
case.
If adaptive Gauss-Hermite quadrature is used, then
logLik(object) is currently only proportional to the
absolute-unconditional log-likelihood.
Note that summary() reports the unconditional absolute deviance,
-2*logLik(object).
For more information about this topic see the misc/logLikGLMM
directory in the package source.