/knowledge/notes/glm-goodness-of-fit
Concept note · ML
Goodness of Fit in GLM
Statistical Models
- Studied
- Statistical ModellingMAST90139
- When
- 2024 S1
- Applied in
- Studied
- Read / Refreshed
- ~5 min read2026-10-15
A fitted GLM predicts means for grouped data (e.g., success rates across 20 treatment groups). Two statistics—Pearson's X² and deviance—both test whether observed counts match fitted means. They can disagree when group sizes or variances differ.
01
The idea
Pearson's X² = Σ (observed - fitted)² / fitted sums squared standardised residuals. Deviance = 2 Σ observed × log(observed / fitted) sums likelihood ratios. Both follow χ² with df = groups - parameters under the null hypothesis that the model fits.
X² weights each group by fitted variance. Deviance weights by observed counts. When group sizes vary widely, X² down-weights small groups; deviance treats them equally if counts are similar. Neither is universally better—compare both and check residual plots.
02
The maths
03
Try it
04
Where I used it
05
Easy to get wrong
06
Sources
MAST90139 Statistical Modelling (2024). Deviance and Pearson X² for model diagnostics.