Deviance goodness-of-fit test (source code)

= Deviance goodness-of-fit test
{title2=$D\approx\chi^2_{n-p}$}

For a suitably regular <generalized linear model>, a residual deviance $D$ can be compared approximately with a <chi-squared distribution> on $n-p$ degrees of freedom to assess fit relative to the saturated model. Sparse or very small expected cell counts can invalidate this reference distribution. A large <p-value> means no detected lack of fit, not proof of correctness; dependence, wrong mean structure or <overdispersion> still require diagnostics.