[R] stepAIC

David martin vilanew at gmail.com
Mon Nov 21 14:59:05 CET 2011


Hi,
I'm trying to select the best model for a particular problem. So far i 
have managed to identify a set of variables that woudl explain my model

lm1 <- lm(Group ~ . , data=dataf))
 > summary(lm1)
                     Df Sum Sq Mean Sq F value    Pr(>F)
`A`     1 2.3963  2.3963 24.0390 7.328e-06 ***
`B`     1 0.7145  0.7145  7.1672  0.009525 **
`C`    1 0.6916  0.6916  6.9379  0.010680 *
`D`      1 5.7042  5.7042 57.2223 2.473e-10 ***
`E`      1 0.8928  0.8928  8.9563  0.003988 **
`F`      1 0.0036  0.0036  0.0359  0.850301
`G`      1 0.3817  0.3817  3.8295  0.054939 .
`H`      1 0.0581  0.0581  0.5833  0.447962
`I`  1 0.1371  0.1371  1.3756  0.245408
`J`      1 0.0504  0.0504  0.5052  0.479936
Residuals           61 6.0808  0.0997
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I would like to run a stepwise analysis with the significant variables 
from the previous lm. Can i input a filter to the stepAIC so that only 
significant variables are used as the initial model to start step 
analysis for ?

stepAIC(lm1,direction="both",)  # How do i filter so that the initial 
model start with the significant ones from lm testing.


thanks,



More information about the R-help mailing list