source('../../Data/get_car_data.R') DF = get_car_data() pairs(DF) m1 = lm(mpg ~ cyl + disp + wt, data=DF) print(summary(m1)) plot(m1, which=1) ## Plot the hat matrix diagonal against the fitted values: ## inf = influence(m1) plot(m1$fitted.values, inf$hat, type='p', pch=19, xlab='Fitted values', ylab='Hat diagonals') ext = match(sort(inf$hat)[dim(DF)[1] - (0:3)], inf$hat) text(m1$fitted.values[ext], inf$hat[ext], labels=row.names(DF)[ext], pos=c(1, 4, 4, 4)) grid()