Dear R users,

I'm new in R and couldn't find the solution to this in the postings. I want
to be able to use the "leaps" package to perform an "exhaustive" regression.
Most of my variables are categorical with many levels. I'd like to restrict
the candidate subsets to either all levels included or all excluded in the
list. Here's the current and desired output from a dummy example:


#Generate random data
y <- rnorm(n=1000, mean=100, sd=10) #normal distribution
a <- gl(n=4, k=1, length=1000, label=c("F1", "F2", "F3", "F4"))
b <- gl(n=4, k=3, length=1000, label=c("G1", "G2", "G3", "G4"))
mydata <- data.frame(y, a, b)
require("leaps")
subsets <- regsubsets(y ~ . , data=mydata, method="exhaustive")
subsets
subset.models <- summary(subsets)$which
subset.models
  (Intercept)      aF2       aF3     aF4    bG2     bG3    bG4
1        TRUE FALSE FALSE FALSE TRUE FALSE FALSE
2        TRUE FALSE FALSE FALSE TRUE FALSE  TRUE
3        TRUE FALSE FALSE FALSE TRUE  TRUE  TRUE
4        TRUE FALSE  TRUE FALSE TRUE  TRUE  TRUE
5        TRUE  TRUE  TRUE FALSE TRUE  TRUE  TRUE
6        TRUE  TRUE  TRUE  TRUE TRUE  TRUE  TRUE

My desired output is:

  (Intercept)      aF2       aF3     aF4    bG2     bG3    bG4
3        TRUE FALSE FALSE FALSE TRUE  TRUE  TRUE
3        TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE
6        TRUE  TRUE  TRUE  TRUE TRUE  TRUE  TRUE

Thanks in advance for your help.

Axel.

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to