While performing Poisson regression in R, I realized that the residuals, as given in the object slot (model$residuals
), differ both from the values returned by the residuals()
function and from the differences between the observed and predicted counts. See the figure below ("diff" refers to the difference between the observed and the predicted counts, "fn.res" to the values from the function, and "obj.res" to object values).
I also found that object values are related to the actual and the fitted values by the formula:
$$ r = \frac{o}{f} - 1 $$
($r$ being the residual values in the object, $o$ the observed counts, and $f$ the fitted values). Why it is so?
I could not find a relationship between the values returned by residuals()
and the other two. The R's help()
function is, unfortunately, of no help here.
So, when trying to validate Poisson regression, as described here, which "residuals" should I use and why?
I've taken a look at the answers to "Diagnostics and residual analysis for Poisson regression", but they don't satisfy my curiosity. I don't want to use some package as a black box, but to know what is happening and why. What are the residuals given by the glm and residuals()
, if not the differences between the observations and the fitted values? Why are they defined so?
residuals.glm
and study the options for thetype
argument. To satisfy your curiosity, check out some of the hits in a search for deviance residuals on this site. $\endgroup$