Duncan1 <- read.table("c:/temp/Duncan.txt",header=T) names(Duncan1) Duncan1.lmedinc <- lm(prestige ~ income +education , data=Duncan1) summary(Duncan1.lmedinc) # automatically generates several useful plots par(mfrow=c(2,2)) plot(Duncan1.lmedinc) par(mfrow=c(1,1)) # this plots Studentized residuals vs. Predicted values plot(fitted.values(Duncan1.lmedinc),rstudent(Duncan1.lmedinc), main=c("Studentized Residuals vs. Predicted values")) # this creates an index plot of hat values plot(hatvalues(Duncan1.lmedinc)) # this plots Studentized residuals vs. Leverage values, with reference lines # to help identify points that have high leverage and are outliers plot(hatvalues(Duncan1.lmedinc),rstudent(Duncan1.lmedinc),xlim=c(0,.4), main=c("Studentized Residuals vs. Hat values")) abline(h=-2) abline(h=2) abline(v=2*length(Duncan1.lmedinc$coefficients)/ length(Duncan1.lmedinc$residuals)) # reference line at 2p/n # additional plots from the car package by the author of our text library(car) plot(cookd(Duncan1.lmedinc)) # this plot allows you to interactively identify observations by clicking on them with the mouse. # to stop identifying points, right click and select 'stop' influencePlot(Duncan1.lmedinc) # bubble plot of studentized residuals by hat values with bubbles proportional to Cook's distance influencePlot(Duncan1.lmedinc) # get the hat value for ministers hatvalues(Duncan1.lmedinc)["minister"] # minister # 0.1730582