Source: Hedderich, Sachs and Reynarowych, Applied Statistics: Methods Using R, section 8.4.5 "Residual Analysis", printed pages 837-838, equations (8.67), (8.68) and (8.69).
Details
Pearson residuals (8.67):
r_i = (y_i - n_i p_i) / sqrt(n_i p_i (1 - p_i)).
Model deviance and deviance residuals (8.68):
D = sum d_i^2 with
\(d_i = sign(y_i - n_i p_i) sqrt(2 [y_i log(y_i / (n_i p_i)) +
(n_i - y_i) log((n_i - y_i) / (n_i (1 - p_i)))])\).
BOOK ERRATUM in (8.68): the printed radicand is
-2(y log(y/(n p))) + (n - y) log(...). Read literally the
leading factor is -2 on the first term only, which makes the radicand
negative for a well-fitting observation and the square root
imaginary. The bracket is the Kullback-Leibler divergence of the
saturated model from the fitted one and is non-negative, so the
factor is +2 over the whole bracket – the standard published
binomial deviance residual, and the one base R returns from
residuals(fit, "deviance"), against which this is anchored.
The sign is sign(y_i - n_i p_i), which the book writes as the
leading +/-.
Influence measure (8.69):
Delta D_i = d_i^2 + r_i^2 h_ii / (1 - h_ii), given on page 838
as R code \(idev <- deviance.resid^2 + pearson.resid^2 *
hats/(1-hats)\).
Terms 0 log 0 arising when y_i = 0 or y_i = n_i are taken as 0.
