This is, more often that not, statistically speaking a bad idea: you're likely to get a false positive (https://xkcd.com/882/)
But it sounds like something along these lines should work for you to get the models : x <- data.frame(rnorm(50), rnorm(50), rnorm(50), rnorm(50)) m <- vector("list", ncol(x)) # Make a list to hold all the resulting models for(i in seq_along(x)) m[[i]] <- lm(as.formula(paste(names(x)[i], "~.")), data = x) To parse that, loop over the columns of x (that's what seq_along will give you if x is a data frame) -- take the i-th name and model is based on everything else ("~.") -- coerce that thing to a formula and pass it to lm() to do the linear model. Hope this helps, Michael On Sat, Apr 7, 2012 at 11:27 AM, kebrab67 <selamgetac...@gmail.com> wrote: > I have a 11*1562 set of data. I want to regress using ols all combination of > the ten variables on the eleventh. Store the results of the t test of each > regression and the r2 to compare which combination is better. the > combination can use any amount o variables. How can I do that in R? > > -- > View this message in context: > http://r.789695.n4.nabble.com/R-help-tp4539571p4539571.html > Sent from the R help mailing list archive at Nabble.com. > [[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. ______________________________________________ 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.