Page 294 - Applied Statistics with R
P. 294
294 CHAPTER 13. MODEL DIAGNOSTICS
## 11
## FALSE
cooks.distance(model_3)[11] > 4 / length(cooks.distance(model_3))
## 11
## TRUE
And, as expected, the added point in the third plot, with high leverage and a
large residual is considered influential!
13.4 Data Analysis Examples
13.4.1 Good Diagnostics
Last chapter we fit an additive regression to the mtcars data with mpg as the
response and hp and am as predictors. Let’s perform some diagnostics on this
model.
First, fit the model as we did last chapter.
mpg_hp_add = lm(mpg ~ hp + am, data = mtcars)
plot(fitted(mpg_hp_add), resid(mpg_hp_add), col = "grey", pch = 20,
xlab = "Fitted", ylab = "Residual",
main = "mtcars: Fitted versus Residuals")
abline(h = 0, col = "darkorange", lwd = 2)

