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).

Three variants of Poisson regression residuals in R

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?


marked as duplicate by kjetil b halvorsen, mdewey, gung r Aug 1 '18 at 14:35


  • 1
    $\begingroup$ Please read the help page for residuals.glm and study the options for the type argument. To satisfy your curiosity, check out some of the hits in a search for deviance residuals on this site. $\endgroup$ – whuber Aug 1 '18 at 12:24
  • $\begingroup$ Questions about software, functions, how they work, etc, are generally off topic here. The on topic Q's inherent in this post are too broad to be well answered in a single thread. However, there is a great deal of information already on the site on these topics; most, possibly all, can be gleaned from the linked threads. Searching & reading should cover the rest, but if you have a specific question afterwards, ask a new Q stating what you learned & what you still need to know. Then we can provide the information you need without duplicating material elsewhere that already didn't help you. $\endgroup$ – gung Aug 1 '18 at 14:50
  • 1
    $\begingroup$ Actually, only the last of the "old questions" leads to somewhere near the answer. Theodore Lytras provides a link to a book by Hardin and Hilbe, available online, which clarifies some details---and still, as John commented, there are apparently some differences in the terminology. As for the "software" part, I beg to differ. Many questions and answers, including some linked here, refer specifically to R and its packages. $\endgroup$ – Igor F. Aug 1 '18 at 19:24