# # 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) library(MASS) # get rlm and lqs # Fit the models suggested in the book in section 6.1 (without an intercept but comparing regression methods): allbacks.lm0 = lm( weight ~ -1 + volume + area, data=allbacks ) if( save_plots ){ postscript("../../WriteUp/Graphics/Chapter6/prob_5_res_vs_fitted.eps", onefile=FALSE, horizontal=FALSE) } oldpar = par(mfrow=c(1,3)) plot( allbacks.lm0$fitted.values, allbacks.lm0$residuals, main="lm", ylim=c(-200,+250) ) allbacks.rlm = rlm( weight ~ -1 + volume + area, data=allbacks ) plot( allbacks.rlm$fitted.values, allbacks.rlm$residuals, main="rlm", ylim=c(-200,+250) ) allbacks.lqs = lqs( weight ~ -1 + volume + area, data=allbacks ) plot( allbacks.lqs$fitted.values, allbacks.lqs$residuals, main="lqs", ylim=c(-200,+250) ) par(oldpar) if( save_plots ){ dev.off() } # Lets look at what the coefficients look like under each of these models: # coefficients(allbacks.lm0) coefficients(allbacks.rlm) coefficients(allbacks.lqs) coefficients( lm( weight ~ -1 + volume + area, data=allbacks[-c(11,13),] ) ) coefficients( rlm( weight ~ -1 + volume + area, data=allbacks[-c(11,13),] ) ) coefficients( lqs( weight ~ -1 + volume + area, data=allbacks[-c(11,13),] ) )