# Summary of residuals in R Disregarding "Deviance" in the image, the output of multiple regression analysis in R looks pretty much like this. As far as I understand, residuals are errors. Do the 5 value summary refer to residuals as errors of estimate, or are these different? Or is my understanding of residuals mistaken?

• Just in case you do not know it, you can look at all of the residuals by using model$residuals. – nico Mar 17, 2013 at 21:41 • resid(model) is preferred to model$residuals. Sometimes they will be the same and sometimes they won't. Sep 26, 2013 at 9:30

The 5 number summary of the residuals that you see are the values that would be used to construct a boxplot. The residuals are not necessarily errors of the estimate, although you could think of them that way; it depends on what you are trying to estimate / predict.

• The value people typically use as a 'prediction' is $\hat y$. This is actually the predicted mean of the conditional distribution of $y$, that is $\mathcal N(\mu_Y|x_i, \sigma^2_\varepsilon)$. In this case, the residuals help you understand the rest of that conditional distribution (for example, its variance).
• Alternatively, you can use $\hat y$ as a point prediction for the value of a new observation when $X=x_i$. This is reasonable because, a-priori, the mean of a normal distribution is the single most likely point value to occur. However, you will nonetheless pretty much always be wrong. The distribution of your residuals can tell you how far off the value of a new observation will be on average from $\hat y$ (i.e., their SD).
• Residuals are also useful in helping you estimate properties of the sampling distributions of your sample statistics (specifically, your betas), and in diagnosing possible problems with your model.

No matter how you think about / use your residuals, those values are simply a non-parametric summary of their distribution. (Note that the above discussion is generic, and is disregarding the fact that the model displayed in the question is a Poisson regression and the residuals displayed are deviance residuals.)

Those numbers are deviance residuals.

$$r_{d_i} = \operatorname{sign}(y_i -\hat{\mu_i}) \sqrt{d_i}$$

where $d_i$ is the individual observations contribution to the deviance.

They are NOT like residuals in ordinary regression, which would be $y_i -\hat{\mu_i}$

Conceptually, Pearson residuals are more like a notion of a regression residual - a scaled $y_i -\hat{\mu_i}$.

However, Pearson residuals may tend to be quite skewed in GLMs and have other issues, while deviance residuals tend to be more normal.

The glm function in R returns a function that defines $d_i$ for each model.

e.g. 1

utils::data(anorexia, package="MASS")
anorex.1 <- glm(Postwt ~ Prewt + Treat + offset(Prewt),
family = gaussian, data = anorexia)

anorex.1$family$dev.resids
function (y, mu, wt)
wt * ((y - mu)^2)      #<---- d(i) for a gaussian model
<bytecode: 0x0bef2398>
<environment: 0x0d214114>


e.g. 2

clotting <- data.frame(
u = c(5,10,15,20,30,40,60,80,100),
lot1 = c(118,58,42,35,27,25,21,19,18),
lot2 = c(69,35,26,21,18,16,13,12,12))
glm(lot1 ~ log(u), data=clotting, family=Gamma)$family$dev.resids
function (y, mu, wt)
-2 * wt * (log(ifelse(y == 0, 1, y/mu)) - (y - mu)/mu) #<- d(i) for Gamma model
<bytecode: 0x0cd3d11c>
<environment: 0x0cd3fd94>

• Could you please explain the meaning of the wt parameter for dev.resids()? Thanks! Jul 25, 2013 at 10:50
• @a11msp The values in "wt" are the weights passed to the glm via the 'weights' argument. Jul 25, 2013 at 14:22