# # EPage 214 # # 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. # #----- save_plots = F library(DAAG) # Part (a): # nihills.lm = lm( time ~ dist + climb, data=nihills ) nihills2.lm = lm( time ~ dist + climb + dist:climb, data=nihills ) anova( nihills.lm, nihills2.lm ) # Part (b): # if( save_plots ){ postscript("../../WriteUp/Graphics/Chapter6/prob_6_res_vs_fitted.eps", onefile=FALSE, horizontal=FALSE) } plot( nihills2.lm, which=1 ) if( save_plots ){ dev.off() } # Lets remove the outlieres and then refit the two models: # use = ! ( row.names( nihills ) %in% c("Slieve Donard", "Meelbeg Meelmore") ) nihills.lm = lm( time ~ dist + climb, data=nihills[use,] ) nihills2.lm = lm( time ~ dist + climb + dist:climb, data=nihills[use,] ) anova( nihills.lm, nihills2.lm )