Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

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

WeiQiang Li

2005-03-01


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@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.