[R] Combination of variables
David Barron
mothsailor at googlemail.com
Mon Jan 22 14:22:57 CET 2007
You don't say what model you want to do. It isn't necessary to store
each combination of predictors in a separate matrix unless you really
need to do this for some other reason, in which case I imagine you
could adopt this idea. I dare say there are better ways, but this
should work (assuming you want a linear model):
x<-matrix(runif(30*6),ncol=6)
y <- rnorm(30)
cmbs <- list()
for (i in 1:6) cmbs <- c(cmbs,combn(6,i,simplify=FALSE))
for (i in 1:length(cmbs)) print(summary(lm(y ~ x[,cmbs[[i]]])))
On 22 Jan 2007 08:51:22 -0000, anil kumar rohilla
<anil_rohilla at rediffmail.com> wrote:
>
> Hi,
> List , i have 6 predictor variables and i want to make possible combinations of these 6 predictors ,all the data is in matrix form ,
> if i am having 6 predictors than possible combination of sets are 64 2 power 6, or 63 ,whatever it may be i want to store the result in another variable to each combination and that i want to put in some model ,
>
> i want to put every combination in some model ,please help me how to find suitable combinations of these variables ........
>
> i was not able to do this .
> Any package is there in R which can help me in this regards
> any help .
> thanks in Advance
>
>
> ANIL KUMAR( METEOROLOGIST)
> LRF SECTION
> NATIONAL CLIMATE CENTER
> ADGM(RESEARCH)
> INDIA METEOROLOGICAL DEPARTMENT
> SHIVIJI NAGAR
> PUNE-411005 INDIA
> MOBILE +919422023277
> anilkumar at imdpune.gov.in
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
>
--
=================================
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP
More information about the R-help
mailing list