[R] How to force specific variables in all the models using regsubsets

From: <WeiQiang.Li_at_seagate.com>
Date: Wed 02 Mar 2005 - 14:43:36 EST


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]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Mar 02 14:57:27 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:39 EST