Solution (source code)

= Solution

The saturated model estimates each Poisson mean separately as $Y_i$, permitting the boundary value zero when $Y_i=0$. Subtracting fitted from saturated <log-likelihood> gives the <Poisson deviance>
$$
\boxed{D=2\sum_i\left[Y_i\log\frac{Y_i}{\widehat\mu_i}-(Y_i-\widehat\mu_i)\right],}
$$
with $0\log(0/\widehat\mu_i)=0$. A zero observation contributes $2\widehat\mu_i$. If the model includes an intercept, the score equation gives $\sum_iY_i=\sum_i\widehat\mu_i$, so the summed linear terms cancel; the unsimplified expression applies generally.

For <goodness of fit>, the <null hypothesis> is that the specified independent Poisson mean model is correct; the alternative is an unrestricted collection of means. When a quadratic likelihood approximation is valid, for example with fixed $n$ and large expected counts, $D$ has approximately a <chi-squared distribution> with $n-p$ <statistical degrees of freedom>. Reject for a large upper-tail deviance. Merely increasing the number of sparse observations does not make this saturated-model reference reliable: the alternative dimension also increases. With small fitted means, replication-based checks or a <parametric bootstrap> are more defensible. This qualification concerns the absolute goodness-of-fit deviance; a fixed-dimensional nested likelihood-ratio comparison can have a better chi-squared approximation.