library(car) save_figs = FALSE source('../../Data/data_loaders.R') DF = load_appendix_bodyfat_data() #pairs(DF) scatterplotMatrix(DF) print(summary(DF)) m = lm(FAT ~ ., data=DF) print(summary(m)) if( save_figs ){ postscript("../../WriteUp/Graphics/Chapter5/ex_5_4_residuals_vs_fitted.eps", onefile=FALSE, horizontal=FALSE) } plot(m, which=1) if( save_figs ){ dev.off() } if( save_figs ){ postscript("../../WriteUp/Graphics/Chapter5/ex_5_4_qq_plot.eps", onefile=FALSE, horizontal=FALSE) } plot(m, which=2) if( save_figs ){ dev.off() } # The added variable plots: # if( save_figs ){ postscript("../../WriteUp/Graphics/Chapter5/ex_5_4_av_plots.eps", onefile=FALSE, horizontal=FALSE) } avPlots(m ) if( save_figs ){ dev.off() } XTX = cor(DF) # Duplicates the numbers in Table 5.1 print(XTX) # notice no r_ij > 0.95 print(vif(m)) # gives the VIFs near the middle of Page 168 all of which are larger than the heuristic of 10 ES = eigen(XTX[ 1:3, 1:3 ]) print('Eigenvalues:') print(ES$values) # one eigenvalue is less than 0.05