On Jan 8, 2010, at 3:26 PM, Richardson, Patrick wrote:
Let's say I have 8 variables and I want to generate all combinations
of those variables (In pairs, threes fours, etc) to run in multiple
linear regression. Is there a built-in function to do that in R?
The formula syntax allows that.
y ~ (x1 + x2 + x3 + x4 + x5)^2 for instance, would give you all 5
of the main effects and the ten two way interaction estimates. With
the "exponent set to three you also get the three way interactions
(although I have never tried this particular level of dredging.)
Unless you have scientific arguments for higher level interactions,
they are a major threat to interpretability and validity as well as a
threat to convergence.
(With 8 variables you are going to experience a combinatorial
explosion: 28 two-way terms, 56 3-way, 70 4-way and then down the
other side of Pascal's triangle.)
Or at a minimum, how could I take those variables and generate all
possible combinations.
Thank you for any assistance.
--
David Winsemius, MD
Heritage Laboratories
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.