# Regression diagnostics library(car) data(Duncan) head(Duncan) # first few observations scatterplotMatrix(~prestige + income + education, data=Duncan, id.n=2) # fit the model duncan.mod <- lm(prestige ~ income + education, data=Duncan) summary(duncan.mod) # standard regression diagnostic plots op <- par(mfrow=c(2,2)) plot(duncan.mod) par(op) # other plots: residuals against predictors and fitted values residualPlots(duncan.mod, id.n=2) # normal QQ plot qqPlot(duncan.mod, id.n=2) # spread-level plot -- doesn't help here spreadLevelPlot(duncan.mod) # influence plot influencePlot(duncan.mod, id.n=2) # added-variable (partial residual) plots avPlots(duncan.mod, id.n=2) # fancier version avPlots(duncan.mod, id.n=2, ellipse=TRUE, ellipse.args=list(levels=0.68, fill=TRUE)) # 3D plot scatter3d(prestige ~ income + education, data=Duncan, id.n=2)