[R] How to get the variables used in stepwise logistic regression?
Soyeon Kim
yunni0731 at gmail.com
Fri Feb 4 17:56:09 CET 2011
Dear All,
I used glm and then used step function for stepwise regression.
Now, I want to store the variables used in the stepwise regression.
The code is the following.
m_logistic <- glm(y ~ . + M1:T + M2:T + M3:T+ M4:T +M5:T,
family=binomial("logit"), data = data)
step_glm <- step(m_logistic)
> step_glm$terms
y ~ M1 + T + M1:T
attr(,"variables")
list(y, M1, T)
attr(,"factors")
M1 T M1:T
y 0 0 0
M1 1 0 1
T 0 1 1
attr(,"term.labels")
[1] "M1" "T" "M1:T"
attr(,"order")
[1] 1 1 2
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1
attr(,".Environment")
<environment: R_GlobalEnv>
attr(,"predvars")
list(y, M1, T)
attr(,"dataClasses")
y M1 T
"numeric" "numeric" "numeric"
How can I extract only "term.labels" ?
Thank you,
Soyeon
More information about the R-help
mailing list