Deviance &
Goodness-of-Fit
Understand how deviance measures model quality, compare nested models using likelihood ratios, and assess fit with the chi-squared distribution.
What Is Deviance?
Deviance is a measure of how well a statistical model fits the observed data. It is based on the likelihood function and is defined as negative two times the log-likelihood of the fitted model:
Think of deviance as the "distance" between what your model predicts and what the data actually show. It generalizes the residual sum of squares from linear regression to any likelihood-based model.
The Saturated Model Baseline
Why Deviance Matters
Core Formula: Scaled Deviance
The \( \chi^2 \) Reference Distribution
Deviance vs. Pearson \( \chi^2 \)
| Deviance \( D \) | Pearson \( X^2 \) | |
|---|---|---|
| Formula | \( -2 \ln \frac{L(\hat{\theta})}{L_s} \) | \( \sum \frac{(O_i - E_i)^2}{E_i} \) |
| Basis | Likelihood ratio | Squared residuals |
| Decomposition | Additive in deviance residuals | Additive in Pearson residuals |
| Null dist. | \( \chi^2_{n-p} \) (approx.) | \( \chi^2_{n-p} \) (approx.) |
| Preferred when | Comparing nested models | Checking individual cell fit |
The Likelihood Ratio Test
To compare a reduced model (null, \( p_0 \) parameters) against a full model (alternative, \( p_1 \) parameters), compute the deviance difference:
How to Apply the Deviance Test
Example 1: Logistic Regression
A logistic regression predicting disease status (\( n = 200 \)) with age alone gives deviance \( D_0 = 245.3 \) (\( p_0 = 2 \)). Adding smoking status gives \( D_1 = 231.8 \) (\( p_1 = 3 \)).
Example 2: Poisson Regression
Modeling insect counts (\( n = 50 \) traps): an intercept-only Poisson model has \( D_0 = 78.6 \) (\( p_0 = 1 \)). Adding temperature and humidity gives \( D_1 = 52.1 \) (\( p_1 = 3 \)).
Example 3: Absolute Goodness-of-Fit
Unlike the likelihood ratio test (which compares two models), the absolute goodness-of-fit test checks whether a single model fits the data at all, using the residual deviance directly.
Deviance Residuals
The total deviance decomposes into contributions from each observation. The deviance residual for observation \( i \) is:
Detecting Overdispersion
When the residual deviance is much larger than its degrees of freedom, the variance in the data exceeds what the model assumes: this is overdispersion.
Common Mistakes
Summary of Key Quantities
| Quantity | Formula | Used For |
|---|---|---|
| Deviance | \( -2 \ln \frac{L(\hat{\theta})}{L_s} \) | Absolute GOF test |
| Deviance difference | \( \Delta D = D_0 - D_1 \) | Likelihood ratio test |
| Pearson \( X^2 \) | \( \sum \frac{(O - E)^2}{E} \) | Cell-level GOF |
| Dispersion \( \hat{\phi} \) | \( D / (n - p) \) | Overdispersion check |
| AIC | \( D + 2p \) | Model selection |
Question 1 of 5
A logistic regression model has deviance \( D_0 = 180.2 \) with 3 parameters, and adding a predictor gives \( D_1 = 172.6 \) with 4 parameters. What is the test statistic for the likelihood ratio test?
Question 2 of 5
Under the null hypothesis that a model fits well, what is the approximate distribution of the residual deviance \( D \)?
Question 3 of 5
A Poisson GLM gives residual deviance \( D = 142.7 \) on 60 degrees of freedom. What does the ratio \( D / \text{df} \approx 2.38 \) suggest?
Question 4 of 5
Which of the following is a valid use of the deviance difference test (\( \Delta D \))?
Question 5 of 5
If a model's AIC is defined as \( \text{AIC} = D + 2p \), what happens to the AIC when you add a parameter that reduces the deviance by exactly 2?