Cwomen1 <- read.table("c:/temp/BFox.txt",header=F,skip=1) names(Cwomen1) <- c("year","participation","tfr","menWages","womenWages","debt","parttime") Cwomen1$tfr <- Cwomen1$tfr*(Cwomen1$year != 1973) +1931*(Cwomen1$year == 1973) Cwomen$time <- Cwomen$year - 1945 # use the leaps package to perform model selection library(leaps) ModFit1.SubFit <- regsubsets(participation ~ tfr +menWages +womenWages +debt +parttime +year, data=Cwomen1, nbest=3) # use the car package to make interesting plots of the results # from the regsubsets function library(car) subsets(ModFit1.SubFit,statistic="bic") subsets(ModFit1.SubFit,statistic="adjr2") subsets(ModFit1.SubFit,statistic="bic",min.size=2) # use the MASS package and the stepAIC function to perform # backward selection using an AIC criterion CWMod1 <- lm(participation ~ tfr +menWages +womenWages +debt +parttime +time, data=Cwomen1) library(MASS) stepAIC(CWMod1,k=2)