# # Epage 65 # # 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(water) attach(water) # # # plot the scatter plot matrix: BSAAM will be the y-axis of the first row postscript("../../WriteUp/Graphics/Chapter3/prob_5.eps", onefile=FALSE, horizontal=FALSE) pairs(BSAAM~OPBPC+OPRC+OPSLAKE) dev.off() f = water[,c(8,5,6,7)] summary(f) round(cor(f),4) m = lm( BSAAM ~ OPBPC+OPRC+OPSLAKE) summary(m) # 3.5.3: # m1 <- lm( BSAAM ~ OPBPC + OPRC + OPSLAKE ) anova(m1) m2 <- lm( BSAAM ~ OPBPC + OPSLAKE + OPRC ) anova(m2) m3 <- lm( BSAAM ~ OPSLAKE + OPRC + OPBPC ) anova(m3) # show that the t-statistics squared for each coefficient are the F-statistics # of the {\em last} variable added in the sequential ANOVA table # s <- summary(m1) t <- s$coefficients[,3]^2 # <- the t values squared t # 3.5.4: # mLarger = m3 # all three inputs mSmaller = lm( BSAAM ~ OPSLAKE ) anova(mSmaller,mLarger)