# # 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(datasets) #postscript("../../WriteUp/Graphics/Chapter5/prob_3_plot.eps", onefile=FALSE, horizontal=FALSE) plot( dist ~ speed, data=cars, ylab="distance" ) m1 = lm( dist ~ speed, data=cars ) abline( m1 ) m2 = lm( dist ~ speed + I(speed^2), data=cars ) lines( cars$speed, fitted(m2), col="blue" ) #dev.off() summary(m2) anova(m1,m2) #plot( diff(dist) ~ speed[1:(length(speed)-1)], data=cars )