Tutorials › Generalized Linear Models › Residual Deviance as an Overdispersion Diagnostic

Detecting Overdispersion · Tutorial 657 of 981

Residual Deviance as an Overdispersion Diagnostic

Learn how residual deviance is assembled from binomial or Poisson responses, and when an unusually large value may indicate overdispersion.

Intermediate 10 min read

What You'll Learn

  • Define deviance as the likelihood-ratio comparison with a saturated model
  • Calculate binomial and Poisson deviance contributions, including zero-count cases
  • Construct signed deviance residuals and residual deviance
  • Interpret a large residual deviance relative to residual degrees of freedom
  • Recognize why a large value is a diagnostic signal, not proof of overdispersion

Why Residual Deviance Is Useful

A fitted binomial or Poisson GLM supplies a mean for each response unit. Deviance measures how much worse the fitted model explains the observed responses than a saturated model, which assigns a separate mean to each unit. Adding the units’ contributions gives the residual deviance, a single summary of the discrepancy left after fitting.

For binomial and Poisson models, unusually large residual deviance compared with its residual degrees of freedom can signal extra variation, but it can also signal that the mean structure or distributional assumptions are inadequate. The comparison is a diagnostic, not a stand-alone proof of overdispersion.

Deviance Contributions and Residual Deviance

Suppose there are \(n\) independent response units. Write \(y_i\) for the observed response and \(\hat\mu_i\) for its fitted mean. The saturated model is the model that fits each response unit as closely as possible by assigning it its own mean. The deviance is twice the log-likelihood difference between that saturated fit and the fitted model.

Definition: The deviance contribution for unit \(i\), denoted \(d_i\), is twice the saturated-model log-likelihood for that unit minus twice the fitted-model log-likelihood for that unit. The residual deviance is \(D=\sum_{i=1}^n d_i\). A signed deviance residual is \(r_{D,i}=\operatorname{sign}(y_i-\hat\mu_i)\sqrt{d_i}\), so \(D=\sum_i r_{D,i}^2\). When \(y_i=\hat\mu_i\), the residual is zero.

For a binomial response, let \(y_i\) be the number of successes in \(m_i\) trials and let \(\hat p_i=\hat\mu_i/m_i\) be the fitted success probability. The fitted success and failure means are \(m_i\hat p_i\) and \(m_i(1-\hat p_i)\). For a Poisson response, \(\hat\mu_i\) is the fitted count mean; it may incorporate an exposure through an offset. The resulting standard contributions are:

$$ d_i^{\mathrm{Bin}} = 2\left[ y_i\log\left(\frac{y_i}{m_i\hat p_i}\right) +(m_i-y_i)\log\left(\frac{m_i-y_i}{m_i(1-\hat p_i)}\right) \right], \qquad d_i^{\mathrm{Pois}} = 2\left[ y_i\log\left(\frac{y_i}{\hat\mu_i}\right) -(y_i-\hat\mu_i) \right]. $$

In these expressions, a term of the form \(0\log(0/a)\) is defined to be zero for \(a>0\). This convention covers observed zeros and, for binomial data, observed all-success or all-failure groups. The ordinary formulas assume fitted probabilities strictly between zero and one for binomial data, and positive fitted means for Poisson data. Boundary cases are handled by limits when the likelihood is well-defined.

Why These Formulas Are Deviance Contributions

The formulas follow directly by comparing each response’s fitted likelihood with its saturated likelihood. The likelihood terms that do not depend on the fitted mean cancel in the comparison.

Derivation: For a binomial response, the log-likelihood terms involving \(p_i\) are \(y_i\log p_i+(m_i-y_i)\log(1-p_i)\). The saturated value uses \(p_i=y_i/m_i\), while the fitted value uses \(p_i=\hat p_i\). Twice their difference gives \(d_i^{\mathrm{Bin}}\). For a Poisson response, the mean-dependent terms are \(y_i\log\mu_i-\mu_i\). Subtracting the fitted value at \(\hat\mu_i\) from the saturated value at \(\mu_i=y_i\), and multiplying by two, gives \(d_i^{\mathrm{Pois}}\). For \(y_i=0\), the saturated Poisson term \(y_i\log y_i\) is interpreted by its limit, zero.

Each contribution is nonnegative. One way to see this is that the saturated model maximizes the likelihood for that response unit over its possible mean or probability, so its log-likelihood cannot be smaller than the fitted log-likelihood. More explicitly, when all relevant means are positive, the Poisson contribution is \(2\hat\mu_i[x\log x-x+1]\), where \(x=y_i/\hat\mu_i\). The function \(x\log x-x+1\) is nonnegative for \(x\geq 0\), with its continuous value at zero equal to 1. For binomial data, nonnegativity follows from the corresponding likelihood maximization over \(p_i\in[0,1]\). Thus the deviance residual is real-valued, and a small \(d_i\) means that unit \(i\) is close to its saturated fit.

Worked Examples

Worked Example: A Poisson Contribution and Its Residual

A Poisson GLM gives a fitted mean of \(\hat\mu=2\) for an observed count \(y=0\). Calculate the deviance contribution and signed deviance residual.

For \(y=0\), the logarithmic term is zero by convention. Therefore,

$$ d=2[0\log(0/2)-(0-2)]=2(2)=4. $$

The observed count is below its fitted mean, so the residual is negative:

$$ r_D=\operatorname{sign}(0-2)\sqrt{4}=-2. $$

The contribution to residual deviance is \(r_D^2=4\). The sign tells us the direction of the discrepancy; squaring the residual gives the contribution to \(D\).

Worked Example: A Grouped-Binomial Contribution

In one group, 8 of 10 trials are successes. A fitted binomial model gives \(\hat p=0.5\). Find the group’s deviance contribution and signed deviance residual.

The fitted means are 5 successes and 5 failures. Substituting \(y=8\), \(m-y=2\), and \(\hat p=0.5\) gives

$$ \begin{aligned} d &=2\left[8\log\left(\frac{8}{5}\right)+2\log\left(\frac{2}{5}\right)\right]\\ &=2[8(0.470003629)+2(-0.916290732)]\\ &\approx 2[3.760029032-1.832581464]\\ &\approx 3.854895. \end{aligned} $$

Since \(8-10(0.5)=3>0\), the signed residual is positive:

$$ r_D=+\sqrt{3.854895}\approx 1.9634. $$

The group’s contribution to the total residual deviance is about 3.855. It is not the raw difference \(8-5\); the likelihood comparison accounts for the binomial response scale.

Worked Example: Adding Contributions to Obtain Residual Deviance

Suppose a fitted model has three response units. The first is a Poisson count \(y_1=0\) with \(\hat\mu_1=0.36\), giving \(d_1=2(0.36)=0.72\). The other two units have binomial deviance contributions evaluated from their fitted likelihoods as

$$ \begin{aligned} d_2&=2\left[\log(1/0.4)+9\log(0.9/0.6)\right] =9.130953409695\ldots,\\ d_3&=2\left[9\log(0.9/0.6)+\log(0.1/0.4)\right] =4.525783223707\ldots. \end{aligned} $$

The first contribution is \(d_1=0.72\), so the total is

$$ D=0.72+9.130953409695\ldots+4.525783223707\ldots =14.376736633402\ldots. $$

Each unit contributes a nonnegative amount, and the total is their sum. In practice, software calculates the contributions from the fitted model; checking individual contributions and their sum can help identify calculation or data-entry errors.

Using Residual Deviance as a Diagnostic

For a standard GLM with \(p\) estimated regression coefficients and a full-rank design matrix, the residual degrees of freedom are \(n-p\), where \(n\) counts independent response units. With a rank-deficient design, replace \(p\) by the design matrix rank. In grouped-binomial data, a response unit is a group, not each individual trial; the number of trials affects its contribution but does not turn the group into multiple independent rows.

When the binomial or Poisson model is correctly specified, the observations are independent, the parameters are identifiable and away from boundaries, and sample sizes are sufficiently large for the likelihood approximation to be reliable, residual deviance is often compared with a chi-square reference having approximately \(n-p\) degrees of freedom. This is an asymptotic benchmark, not an exact distributional identity for every fitted GLM. Sparse counts, small binomial denominators, or boundary estimates can make the approximation poor.

A residual deviance that is unusually large relative to this benchmark means the fitted model leaves more discrepancy than would ordinarily be expected under the assumed model. That is consistent with extra variation, but it is not specific to it. A wrong mean structure, dependence between responses, influential observations, or a poorly chosen response distribution can also inflate the deviance. The size of \(D\) should therefore prompt investigation of the model and data rather than an automatic change to the variance assumption.

1
Calculate contributions.
Use the appropriate binomial or Poisson formula for each response unit, including the zero-term convention.
2
Sum the contributions.
Compute \(D=\sum_i d_i\); equivalently, sum the squared signed deviance residuals.
3
Make a qualified comparison.
Compare the residual deviance with its residual degrees of freedom, keeping the asymptotic assumptions and possible alternative sources of misfit in view.

Common Pitfall

  • Wrong reasoning: “The residual deviance exceeds its residual degrees of freedom, so the data are definitely overdispersed.”
  • Correction: A large value is a warning that observed responses depart more than expected under the fitted model. Overdispersion is one possible explanation; misspecified means, dependence, influential observations, sparse data, and family mismatch can produce a similar signal. Examine those possibilities before interpreting the discrepancy as extra variation.
  • Another error: Treating \(D\) as a signed quantity. Individual residuals have signs, but each contribution is their square and the total deviance is nonnegative.
Key takeaway: Residual deviance is the sum of likelihood-based discrepancies between each observed response and its fitted mean. An unusually large value relative to residual degrees of freedom is evidence of lack of fit that warrants investigation; it does not by itself identify the cause.

Check Your Understanding

Answer each question using the definitions and conditions above.

  1. For a Poisson observation with \(y=0\) and \(\hat\mu=1.5\), calculate its deviance contribution.
  2. Why is the deviance contribution nonnegative, and what does a contribution of zero indicate?
  3. For grouped-binomial data, what does \(n\) count when calculating residual degrees of freedom?
  4. What does the sign of a signed deviance residual tell you, and what does its square contribute?
  5. Name two explanations other than overdispersion for an unusually large residual deviance.
Clinical Biostats