SECTION 1
Historical Context & Motivation
In classical linear regression, assessing model fit is relatively straightforward: residual sums of squares and the coefficient of determination R² provide intuitive summaries of how well predicted values track observed outcomes. However, as statisticians began extending regression techniques to non-normal response distributions—binary outcomes, count data, survival times—the familiar least-squares machinery no longer applied. The fundamental challenge was clear: how does one measure the discrepancy between a fitted model and observed data when the error structure is no longer Gaussian and the response is no longer continuous? The answer emerged through the unifying framework of maximum likelihood estimation and the concept of deviance, which generalizes the residual sum of squares by comparing log-likelihoods rather than squared residuals.
1922 • Fisher's Likelihood Framework
1938 • Neyman–Pearson Likelihood Ratio Tests
1972 • Nelder & Wedderburn's GLM Unification
1983 • McCullagh & Nelder's Treatise
1990s–Present • Information-Theoretic Extensions
The central question that deviance addresses is deceptively simple: given a fitted model, how much information is lost compared to a model that perfectly reproduces the observed data? By framing goodness-of-fit as a comparison of log-likelihoods, deviance provides a single, interpretable statistic that works uniformly across all members of the exponential family—normal, binomial, Poisson, gamma, and beyond. Understanding deviance is therefore essential for anyone working with GLMs, as it underpins model diagnostics, nested model comparisons via likelihood ratio tests, and the broader logic of statistical model selection.
SECTION 2
Core Principles & Definitions
The conceptual architecture of deviance rests on a few interconnected ideas. At its core, deviance measures the distance between two models using the language of likelihood. To appreciate this, one must first understand the roles played by the saturated model, the fitted model, and the null model. These three reference points define the landscape within which goodness-of-fit is assessed.
Saturated Model
Deviance (D)
Null Deviance
Likelihood Ratio Test (LRT)
Scaled Deviance
KEY TAKEAWAY
SECTION 3
Visual Explanation
The Deviance Landscape: Saturated, Fitted, and Null Models
The diagram above illustrates the fundamental geometry of deviance. The saturated model sits at the top, representing the best any model from the same distributional family could achieve. It has n parameters for n observations, so it reproduces the data exactly. Below it, the fitted model uses p < n parameters, trading perfect fit for parsimony. The gap between these two log-likelihoods, multiplied by −2, gives the residual deviance. At the bottom lies the null model, which ignores all predictors. The null deviance captures the total amount of 'explainable' discrepancy, analogous to the total sum of squares in OLS. By comparing residual deviance to null deviance, one can gauge how much predictive power the covariates contribute.
SECTION 4
Mathematical Framework
The mathematical formulation of deviance is rooted in the exponential family of distributions. Recall that for a response Y with probability density or mass function belonging to the exponential dispersion family, the log-likelihood contribution of a single observation can be written in canonical form. The deviance statistic emerges naturally as twice the log-likelihood ratio between the saturated and fitted models.
EXPONENTIAL FAMILY LOG-LIKELIHOOD
Here θ is the canonical parameter, ϕ is the dispersion parameter, b(θ) is the cumulant function, and a(ϕ) and c(y, ϕ) are known functions. The mean is μ = b′(θ) and Var(Y) = b″(θ) · a(ϕ).
DEVIANCE (GENERAL FORM)
Equivalently, D = 2 Σᵢ [ yᵢ(θ̃ᵢ − θ̂ᵢ) − b(θ̃ᵢ) + b(θ̂ᵢ) ], where θ̃ᵢ is the canonical parameter under the saturated model (setting μ̃ᵢ = yᵢ) and θ̂ᵢ is the canonical parameter under the fitted model. The factor a(ϕ) is typically absorbed when ϕ is known.
DEVIANCE FOR POISSON GLM
For Poisson data with log link, the canonical parameter is θ = ln(μ). When yᵢ = 0, the convention 0 · ln(0) = 0 is applied. The dispersion parameter ϕ = 1 for Poisson, so scaled and unscaled deviance coincide.
DEVIANCE FOR BINOMIAL GLM
Here yᵢ is the number of successes, nᵢ is the number of trials, and μ̂ᵢ = nᵢπ̂ᵢ where π̂ᵢ is the estimated success probability. Again ϕ = 1 for binomial, so D is directly comparable to a χ² distribution under regularity conditions.
Asymptotic Distribution
SECTION 5
Deviance Across Exponential Family Members
One of the most elegant features of the deviance framework is its universality: every member of the exponential dispersion family has a specific deviance formula derived from the general expression. Understanding these family-specific forms builds intuition for what deviance is actually measuring in each context, and reveals why deviance reduces to familiar quantities in certain special cases.
| Family | Canonical Link | ϕ | Deviance Unit Contribution dᵢ |
|---|---|---|---|
| Normal | Identity: g(μ) = μ | σ² (estimated) | (yᵢ − μ̂ᵢ)² |
| Poisson | Log: g(μ) = ln(μ) | 1 (fixed) | 2[yᵢ ln(yᵢ/μ̂ᵢ) − (yᵢ − μ̂ᵢ)] |
| Binomial | Logit: g(π) = ln[π/(1−π)] | 1 (fixed) | 2[yᵢ ln(yᵢ/μ̂ᵢ) + (nᵢ−yᵢ)ln((nᵢ−yᵢ)/(nᵢ−μ̂ᵢ))] |
| Gamma | Inverse: g(μ) = 1/μ | 1/ν (estimated) | 2[−ln(yᵢ/μ̂ᵢ) + (yᵢ − μ̂ᵢ)/μ̂ᵢ] |
Deviance contributions by exponential family member
SECTION 6
Worked Example: Poisson Regression Deviance
Suppose a researcher models the count of insurance claims yᵢ as a function of driver age using a Poisson GLM with a log link. The model is fitted to n = 5 age groups with observed counts y = (2, 5, 8, 4, 1) and fitted values μ̂ = (2.5, 4.2, 6.8, 3.8, 1.7). We will compute the residual deviance, compare it to a χ² distribution, and interpret the result.
Computing Poisson Deviance
- 1
Step 1 — State the Deviance Formula
For a Poisson GLM, the deviance is D = 2 Σᵢ [ yᵢ ln(yᵢ / μ̂ᵢ) − (yᵢ − μ̂ᵢ) ]. We evaluate this sum over i = 1, …, 5 using the observed and fitted values. - 2
Step 2 — Compute Each Unit Deviance dᵢ
For observation 1: d₁ = 2[2 ln(2/2.5) − (2 − 2.5)] = 2[2(−0.2231) + 0.5] = 2[−0.4463 + 0.5] = 2(0.0537) = 0.1075. For observation 2: d₂ = 2[5 ln(5/4.2) − (5 − 4.2)] = 2[5(0.1744) − 0.8] = 2[0.8720 − 0.8] = 2(0.0720) = 0.1440. For observation 3: d₃ = 2[8 ln(8/6.8) − (8 − 6.8)] = 2[8(0.1625) − 1.2] = 2[1.3000 − 1.2] = 2(0.1000) = 0.2000. For observation 4: d₄ = 2[4 ln(4/3.8) − (4 − 3.8)] = 2[4(0.0513) − 0.2] = 2[0.2053 − 0.2] = 2(0.0053) = 0.0105. For observation 5: d₅ = 2[1 ln(1/1.7) − (1 − 1.7)] = 2[1(−0.5306) + 0.7] = 2(0.1694) = 0.3388.d = (0.1075, 0.1440, 0.2000, 0.0105, 0.3388) - 3
Step 3 — Sum to Get Residual Deviance
D = Σ dᵢ = 0.1075 + 0.1440 + 0.2000 + 0.0105 + 0.3388 = 0.8008.D = 0.801 - 4
Step 4 — Determine Degrees of Freedom
The model has n = 5 observations and p = 2 parameters (intercept + age coefficient). The residual degrees of freedom are n − p = 5 − 2 = 3.df = 3 - 5
Step 5 — Compare to χ²(3) and Interpret
Under the null hypothesis that the Poisson model is adequate, D ~ χ²(3) approximately. The critical value at α = 0.05 is χ²₀.₉₅(3) = 7.815. Since D = 0.801 ≪ 7.815, we have no evidence of lack of fit. The p-value is P(χ²(3) > 0.801) ≈ 0.849, indicating excellent model adequacy. The ratio D/df = 0.801/3 = 0.267 is well below 1, suggesting no overdispersion.p ≈ 0.849 — No evidence of lack of fit
SECTION 7
Deviance vs. Alternative Goodness-of-Fit Measures
Deviance is not the only goodness-of-fit statistic available for GLMs. The Pearson chi-squared statistic, Akaike Information Criterion (AIC), and Hosmer–Lemeshow test all serve related but distinct purposes. Understanding when each measure is appropriate prevents misdiagnosis of model problems.
| Criterion | Strengths | Limitations |
|---|---|---|
| Deviance | Directly linked to likelihood ratio tests; additive over nested models; canonical measure in GLM theory; provides individual deviance residuals for diagnostics. | χ² approximation can be poor for sparse binary data; not meaningful for comparing non-nested models; requires known ϕ for exact test. |
| Pearson χ² | More robust to sparse data than deviance; familiar quadratic form; useful for estimating dispersion via X²/(n−p). | Not additive for nested model comparisons; less directly tied to likelihood theory; same asymptotic distribution as deviance under regularity conditions. |
| AIC | Allows comparison of non-nested models; penalizes complexity; grounded in information theory (Kullback–Leibler divergence). | No formal hypothesis test; sensitive to sample size; requires models fit to the same data. |
| Hosmer–Lemeshow | Specifically designed for logistic regression with binary outcomes; circumvents sparse-data problem by grouping observations. | Arbitrary choice of number of groups; low power; test result depends on grouping strategy; not generalizable beyond binomial models. |
Comparison of major goodness-of-fit measures for GLMs
KEY TAKEAWAY
SECTION 8
Connections to Advanced Theory
Deviance sits at a crossroads between classical hypothesis testing and modern model selection theory. Its connections extend in several important directions: toward information criteria, quasi-likelihood methods, Bayesian model comparison, and the analysis of deviance (ANODEV) for factor effects in GLMs.
| Core Concept | Advanced Extension | Key Relationship |
|---|---|---|
| Deviance D | AIC = D + 2p | AIC is deviance plus a complexity penalty; minimizing AIC trades fit against parsimony via an asymptotic estimate of out-of-sample prediction loss. |
| Scaled deviance D/ϕ | Quasi-likelihood | When the full distribution is unknown, quasi-likelihood methods estimate ϕ from the data and use scaled deviance for inference, relaxing distributional assumptions. |
| Deviance residuals rᵢᴰ | Residual diagnostics | Deviance residuals rᵢᴰ = sign(yᵢ − μ̂ᵢ)√dᵢ are more symmetrically distributed than Pearson residuals, making QQ-plots and influence diagnostics more reliable. |
| ΔD for nested models | Analysis of Deviance (ANODEV) | Sequential deviance reduction by adding terms mirrors sequential ANOVA. Type I and Type III deviance tables decompose the contribution of each predictor or factor. |
| −2 log-likelihood | DIC (Bayesian) | The Deviance Information Criterion extends deviance to Bayesian hierarchical models by replacing p with the effective number of parameters pD estimated from the posterior. |
From deviance fundamentals to advanced extensions
A particularly important extension is the concept of deviance residuals. Defined as rᵢᴰ = sign(yᵢ − μ̂ᵢ) × √dᵢ, where dᵢ is the unit deviance for observation i, these residuals decompose the total deviance into per-observation contributions. Unlike raw or Pearson residuals, deviance residuals tend to be more normally distributed, particularly for Poisson and binomial models. This property makes them invaluable for diagnostic plots: a QQ-plot of deviance residuals against normal quantiles should approximate a straight line when the model is correctly specified. Systematic departures indicate misspecified link functions, omitted predictors, or distributional inadequacy.
Looking Ahead
SECTION 9
Practice Problems
Question 1: CONCEPTUAL
Show answer
Question 2: BASIC CALCULATION
Show answer
Question 3: INTERMEDIATE
Show answer
Question 4: APPLIED
Show answer
Question 5: CRITICAL THINKING
Show answer
SUMMARY
Summary
Summary
Deviance is the fundamental goodness-of-fit measure for generalized linear models, defined as D = −2[ℓ(fitted) − ℓ(saturated)]. It generalizes the residual sum of squares from ordinary least squares by measuring discrepancy in log-likelihood units rather than squared Euclidean distance. Each member of the exponential family (Normal, Poisson, Binomial, Gamma) produces a specific deviance formula derived from the general canonical-form expression. Under regularity conditions, the residual deviance follows an asymptotic χ² distribution with n − p degrees of freedom, though this approximation can be unreliable for sparse binary data.
The difference in deviances between nested models yields the likelihood ratio test statistic, providing a principled approach to variable selection and model simplification. Complementary measures include the Pearson χ² statistic (better for sparse data), AIC (for non-nested model comparison), and the Hosmer–Lemeshow test (for ungrouped binary outcomes). Deviance residuals decompose the total deviance into per-observation contributions and provide superior distributional properties for diagnostic plots. Mastery of deviance is essential for anyone working with GLMs, as it underpins model comparison, diagnostics, dispersion estimation, and the broader logic of likelihood-based statistical inference.