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.
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.
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
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.
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.
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ᵢ − μ̂ᵢ)/μ̂ᵢ] |
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.
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. |
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. |
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.
Practice Problems
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.