# # Epage 41 # # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- library(alr3) data(wblake) attach(wblake) m <- lm( Length ~ Age ) plot(Age,Length) abline(m) summary( m ) anova(m) # 2.5.1: # predict(m,data.frame(Age=c(2,4,6)), interval="confidence", level=0.95) # 2.5.2: # predict(m,data.frame(Age=c(9)), interval="confidence", level=0.95) # 2.5.3: # data(wblake2) attach(wblake2) postscript("../../WriteUp/Graphics/Chapter2/prob_5_wblake2.eps", onefile=FALSE, horizontal=FALSE) plot( Age, Length, xlab="Age", ylab="Length" ) abline( m2 ) dev.off() m2 <- lm( Length ~ Age ) y_hat <- predict( m2 ) res <- m2$residuals postscript("../../WriteUp/Graphics/Chapter2/prob_5_wblake2_residuals.eps", onefile=FALSE, horizontal=FALSE) plot( y_hat, res, xlab="Fitted values", ylab="Residuals" ) dev.off()