WeiQiang.Li@seagate.com
2005-Mar-02 03:43 UTC
[R] How to force specific variables in all the models using regsubsets
Dear friends,
I am trying to use R to do Best Subset Regression, I can not force
seldom variables in all the subsets models. R is always giving wrong
variables when I include force.in option.
For example, I like to include X2 & X4 in all the models, but I always get
X2 & X3. Could anyone please help me on this issue? Thanks in advance.
x<-rnorm(120)
attr(x,'dim')<-c(20,6)
x<-data.frame(x)
regsubsets(X1~X2+X3+X4+X5,data=x,nbest=2,force.in=c(1,3))
Subset selection object
Call: regsubsets.formula(X1 ~ X2 + X3 + X4 + X5, data = x, nbest = 2,
force.in = c(1, 3))
4 Variables (and intercept)
Forced in Forced out
X2 TRUE FALSE
X4 FALSE FALSE
X3 TRUE FALSE
X5 FALSE FALSE
2 subsets of each size up to 4
Selection Algorithm: exhaustive
Best Regards,
WeiQiang Li
[[alternative HTML version deleted]]