On Feb 4, 2011, at 11:56 AM, Soyeon Kim wrote:
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.
I am not sure that what you ask here is actually what you eventually
ask and will limit my answer to only what you ask below.
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" ?
Have you tried what would seem to be the obvious answer (assuming that
is a faithful console output):
attr(step_glm$terms, "term.labels")
?attr
?attributes
(And the usual caveats: stepwise methods are often invalid.)
--
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.