Why do the deviance residuals produced by -predict- (using the option deviance) after -logit- differ from the deviance residuals I calculate following the formula in [R]Base Reference (p. 11 or 1273)?
See the following example:
The deviance residuals calculated "manually" seem to be OK, the deviance residuals produced by -predict- not. Any ideas?
See the following example:
Code:
sysuse auto logit foreign mpg predict pr, pr predict dev, dev * Calculate the deviance residuals "manually" according to the formula given in the manual: gen d = -sqrt(2*abs(ln(1-pr))) if foreign==0 replace d = sqrt(2*abs(ln(pr))) if foreign==1 * If everything is correct the sum of the squared deviance residuals should be equal to -2*ll : gen d2 = d^2 qui sum d2 di "Deviance = " r(sum) " ~= " -2*e(ll) * However, using the deviance residuals produced by -predict dev, dev- are different and (seemingly?) wrong: gen dev2 = dev^2 qui sum dev2 di "Deviance = " r(sum) " ~= " -2*e(ll)
Comment