Deviance of a model M_{1} is twice the difference
between the loglikelihood of that model and the saturated model, M_{S}.
The saturated model is the model with the maximum number of parameters
that can be estimated. For example, if there are n observations y_{i}, i =
1, 2, ..., n, with potentially different values
for X_{i}^{T}β,
then you can define a saturated model with n parameters.
Let L(b,y) denote the maximum
value of the likelihood function for a model. Then the deviance of
model M_{1} is
where b_{1} are the estimated
parameters for model M_{1} and b_{S} are
the estimated parameters for the saturated model. The deviance has
a chi-square distribution with n – p degrees
of freedom, where n is the number of parameters
in the saturated model and p is the number of parameters
in model M_{1}.
If M_{1} and M_{2} are
two different generalized linear models, then the fit of the models
can be assessed by comparing the deviances D_{1} and D_{2} of
these models. The difference of the deviances is
Asymptotically, this difference has a chi-square distribution with degrees of freedom
v equal to the number of parameters that are estimated in one model
but fixed (typically at 0) in the other. It is equal to the difference in the number of
parameters estimated in M_{1} and M_{2}. You can get
the p-value for this test using
1 - chi2cdf(D,V)
, where D =
D_{2} –
D_{1}.