Solution (source code)

= Solution

Use $\alpha$ for the intercept, to avoid confusing it with the observation means. Let $e_i=\exp(\widehat\alpha+\widehat\beta^Tx_i)$ be the fitted <Poisson regression> mean. Apart from constants, its <log-likelihood> is
$$
\ell(\alpha,\beta)=\sum_i\{y_i(\alpha+\beta^Tx_i)-\exp(\alpha+\beta^Tx_i)-\log(y_i!)\}.
$$
At a finite interior <maximum-likelihood estimate>, the intercept <score equation> gives the <Poisson regression margin-matching score equations>:
$$
\frac{\partial\ell}{\partial\alpha}=\sum_i(y_i-e_i)=0,\qquad\boxed{\sum_i e_i=\sum_i y_i.}
$$
The <statistical saturated model> fits each mean to $y_i$, taking the boundary mean zero if $y_i=0$. Subtracting fitted from saturated <log-likelihood> gives the <Poisson deviance>
$$
D=2\sum_i\left[y_i\log\frac{y_i}{e_i}-(y_i-e_i)\right].
$$
The intercept balance cancels the sum of linear terms. Consequently
$$
\boxed{D=2\sum_i y_i\log(y_i/e_i),\qquad0\log(0/e_i)=0.}
$$
The unsimplified formula makes nonnegativity transparent; individual terms in the simplified formula need not each be positive.

For the <deviance goodness-of-fit test>, if the fitted design has rank $r$, compare a suitably calibrated $D$ with $\chi^2_{n-r}$, rejecting for large values. This approximation applies in a regular large-count regime, such as a fixed set of cells with increasing exposure and positive fitted proportions. It is not automatically accurate for many sparse <Poisson> observations. Check residual patterns and <overdispersion>; where the approximation is doubtful, simulate independent <Poisson random variables> with fitted means, refit each sample, and use a <parametric bootstrap> distribution of the same statistic. A large <p-value> means no detected lack of fit, not proof of the model. If a finite interior estimate fails to exist, the score proof needs a boundary-limit interpretation; for example all-zero data give a supremum with every fitted mean tending to zero and limiting deviance zero.