I am removing unnecessary/spurious variables from my data using 'step' function. I am using the folloeing code:
state.x77
st = as.data.frame(state.x77)
colnames(st)[4] = "Life.Exp" # no spaces in variable names, please
colnames(st)[6] = "HS.Grad"
model1 = lm(Life.Exp ~ Population + Income + Illiteracy + Murder +
+ HS.Grad + Frost + Area, data=st)
summary(model1)
modelStep = step(model1, direction="backward")
How do I know the final variables selected by 'step' method?
Edit: I am using the following to find the same. I am looking for any other simpler method.
rownames(summary(modelStep)$coefficients)