Re: [R] Combination of variables

From: David Barron <mothsailor_at_googlemail.com>
Date: Mon 22 Jan 2007 - 13:22:57 GMT

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@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@imdpune.gov.in
>
> [[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
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
=================================
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Jan 23 00:33:53 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 22 Jan 2007 - 14:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.