# # Epage 137 # # 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. # #----- # version$language == "R" for R version$language == NULL for SPlus if(is.null(version$language) == FALSE){ require(alr3) }else{ library(alr3) } data(dwaste) attach(dwaste) a <- dwaste a$logO2UP <- log(O2UP) logO2UP <- a$logO2UP # do some data analysis on the scatter plots of this data: # pairs(O2UP~+BOD+TKN+TS+TVS+COD) plot( TVS, O2UP, xlab="TVS", ylab="O2UP" ) pairs(log(O2UP)~+BOD+TKN+TS+TVS+COD) plot( TVS, log(O2UP), xlab="TVS", ylab="log(O2UP)" ) # the simplest and most complicated model: # m0 <- lm( logO2UP ~ +1 ) m1 <- lm( logO2UP ~ +1+BOD+TKN+TS+TVS+COD ) if(is.null(version$language) == FALSE) {require (xtable); xtable(m1)} else m1 # Lets start with forward selection for this problem: # ansf1 <- step(m0,scope=list(lower=~+1, upper=~+1+BOD+TKN+TS+TVS+COD), direction="forward", data=a) ansf2 <- step(m1,scope=list(lower=~+1, upper=~+1+BOD+TKN+TS+TVS+COD), direction="backward", data=a)