[R] Extracting variable names of final model in stepAIC

Chua Siang Li siang.li.chua at acceval-intl.com
Tue Aug 5 08:16:22 CEST 2008


   Hello  there.   I uses the following codes for the purpose of variable
   selection.
   > lmModel <- lm(y~.,data.frame(y=y, x=x))
   > step <- stepAIC(lmModel, direction="both")
   > step$anova
   Stepwise Model Path
   Analysis of Deviance Table

   Initial Model:
   y ~ x.Market.Price + x.Quantity + x.Country + x.Incoterm + x.Channel +
       x.PaymentTerm

   Final Model:
   y ~ x.Quantity + x.Country + x.Incoterm + x.PaymentTerm

                 Step Df Deviance Resid. Df Resid. Dev      AIC
   1                                   1067   852257.2 7268.945
   2      - x.Channel  1 127.9724      1068   852385.2 7267.108
   3 - x.Market.Price  1 858.2886      1069   853243.5 7266.200
   question:
   Now, $anova list the final model only on the console.  How do I retrieve the
   variable names of final model (to be written into a text file later)?
   Thanks.
   ----
   Chua Siang Li
   Consultant - Operations Research
   Acceval Pte Ltd
   Tel: 6297 8740
   Email: siang.li.chua at acceval-intl.com
   Website: www.acceval-intl.com
   This message and any attachments (the "message"...{{dropped:13}}


More information about the R-help mailing list