Source: Hedderich, Sachs and Reynarowych, Applied Statistics: Methods Using R,
section 8.5, printed page 843, equations (8.80) and (8.81): D = 2 sum [y_i
log(y_i / lam_i) - (y_i - lam_i)], printed also as 2 sum y_i log(y_i /
lam_i). The two agree only when sum (y_i - lam_i) = 0, which the book states
one paragraph above holds exactly when the model carries an intercept. The general
form is computed; the third printed line is returned as D_nointercept
alongside resid_sum so the identity can be inspected.
Details
BOOK ERRATUM in (8.81): the printed statistic is
D ~= sum (y_i - lam_i) / lam_i. That numerator is not squared,
so with an intercept it sums to (nearly) zero by the identity just
quoted and cannot approximate a positive deviance. The Pearson
chi-squared for a Poisson fit is
sum (y_i - lam_i)^2 / lam_i, which is what is computed; the
literal printed form is not implemented.
0 log 0 is taken as 0.
