source('../../Data/data_loaders.R') DF = load_appendix_cement_data() # Part (a): # m = lm( Y ~ X1 + X2 + X3 + X4, data=DF ) print( summary( m ) ) # Part (b): # print( cor( DF ) ) # Part (c): # #postscript("../../WriteUp/Graphics/Chapter4/ex_4_4_pairs_plot.eps", onefile=FALSE, horizontal=FALSE) pairs( DF ) #dev.off() #postscript("../../WriteUp/Graphics/Chapter4/ex_4_4_boxplot.eps", onefile=FALSE, horizontal=FALSE) boxplot( DF ) #dev.off() # Part (d): # #postscript("../../WriteUp/Graphics/Chapter4/ex_4_4_residuals_vs_fitted.eps", onefile=FALSE, horizontal=FALSE) plot( m, which=1 ) #dev.off() r = m$residuals #postscript("../../WriteUp/Graphics/Chapter4/ex_4_4_residuals_vs_features.eps", onefile=FALSE, horizontal=FALSE) par(mfrow=c(1, 4)) plot( DF$X1, r, type='p', pch=19, xlab='X1', ylab='residuals' ) grid() plot( DF$X2, r, type='p', pch=19, xlab='X2', ylab='residuals' ) grid() plot( DF$X3, r, type='p', pch=19, xlab='X3', ylab='residuals' ) grid() plot( DF$X4, r, type='p', pch=19, xlab='X4', ylab='residuals' ) grid() par(mfrow=c(1, 1)) #dev.off() # Part (e): # plot( m, which=2 )