Deviance: A Measure of Model Fit
You'll learn how deviance extends the idea of measuring model error from linear regression to generalized linear models.
The Core Idea
In ordinary linear regression, we measure how well our model fits by calculating the residual sum of squares (RSS)—essentially, how far our predictions are from the actual values. But what about logistic regression or Poisson regression? We can't just subtract predicted probabilities from binary outcomes or compare counts in the same way.
Deviance is the generalization of RSS for all GLMs. It measures how well your fitted model explains the data compared to a "perfect" model (called the saturated model) that fits the data exactly.
How Deviance Works
Deviance is calculated using likelihood—the probability of observing your data given the model. The formula compares two models:
- Saturated model: Perfect fit with one parameter per observation
- Your fitted model: The GLM you actually built
Deviance = -2 × (log-likelihood of your model - log-likelihood of saturated model)
A lower deviance means better fit. The "-2 log" part makes deviance behave similarly to RSS: bigger values = worse fit, and it follows a chi-squared distribution under certain conditions, letting us perform hypothesis tests.
Why It Matters
Deviance lets you:
- Compare nested models (like the partial F-tests and likelihood ratio tests you've seen)
- Assess overall model fit across different GLM types
- Detect patterns like overdispersion in Poisson models
Key Takeaway: Deviance is the GLM equivalent of residual sum of squares—a single number that quantifies model fit by comparing your model's likelihood to a perfect fit, enabling model comparison across all generalized linear models.