source('../../Data/data_loaders.R') DF = load_appendix_steel_production_data() # Part (a): # m = lm( PROD ~ WID + DENS + STR, data=DF ) print( summary( m ) ) # Part (b): # print( cor( DF ) ) # Part (c): # #postscript("../../WriteUp/Graphics/Chapter4/ex_4_3_pairs_plot.eps", onefile=FALSE, horizontal=FALSE) pairs( DF ) #dev.off() #postscript("../../WriteUp/Graphics/Chapter4/ex_4_3_boxplot.eps", onefile=FALSE, horizontal=FALSE) boxplot( DF ) #dev.off() # Part (d): # #postscript("../../WriteUp/Graphics/Chapter4/ex_4_3_residuals_vs_fitted.eps", onefile=FALSE, horizontal=FALSE) plot( m, which=1 ) #dev.off() r = m$residuals #postscript("../../WriteUp/Graphics/Chapter4/ex_4_3_residuals_vs_features.eps", onefile=FALSE, horizontal=FALSE) par(mfrow=c(1, 3)) plot( DF$WID, r, type='p', pch=19, xlab='WID', ylab='residuals' ) grid() plot( DF$DENS, r, type='p', pch=19, xlab='DENS', ylab='residuals' ) grid() plot( DF$STR, r, type='p', pch=19, xlab='STR', ylab='residuals' ) grid() par(mfrow=c(1, 1)) #dev.off() # Part (e): # plot( m, which=2 )