# # 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 # # EPage 140 # DF = read.csv( "../../Data/used_car_prices.csv", header=TRUE ) # Show year is important in determining price but mileage is not: # m = lm( Price ~ Year + Mileage, data=DF ) summary(m) # Refit our model using only Year: # m = lm( Price ~ Year, data=DF ) summary(m) # Perform the regression for each model class: # for( l in levels(DF$Class) ){ print( l ) print( summary ( lm( Price ~ Year + Mileage, data=DF[ DF$Class==l, ] ) ) ) } # Determine if color is important: # DF$isBlack = 0 DF$isBlack[ DF$Color == 'black' ] = 1 m2 = lm( Price ~ Year + isBlack, data=DF ) summary(m2) if( save_plots ){ postscript("../../WriteUp/Graphics/Chapter6/ucp_residual_plot.eps", onefile=FALSE, horizontal=FALSE) } plot(m, which=1) if( save_plots ){ dev.off() }