Thomas A. Groen
2009-Jul-22 12:28 UTC
[R] All possible linear models given multiple explaining variables
Hi, I would like to have a script/function (or write one) that can calculate the linear models for all possible combinations of explaining variables. Eventually I would like to end up with a data base (or data frame) giving for each model the R2, R2adj, AIC etc. Currently I'm a bit stuck while writing my own script using the lm() function from the base package. Also, I haven't fund any function (yet) that can do this as well. Perhaps these functions/scripts already exist? I would be very grateful to any suggestions and thoughts. kind regards, Thomas [[alternative HTML version deleted]]
hadley wickham
2009-Jul-22 12:32 UTC
[R] All possible linear models given multiple explaining variables
Have a look at the meifly package, which also includes tools for visualising the resulting models. Hadley On Wed, Jul 22, 2009 at 7:28 AM, Thomas A. Groen<tagroen at gmail.com> wrote:> Hi, > > I would like to have a script/function (or write one) that can calculate the > linear models for all possible combinations of explaining variables. > Eventually I would like to end up with a data base (or data frame) giving > for each model the R2, R2adj, AIC etc. > Currently I'm a bit stuck while writing my own script using the lm() > function from the base package. Also, I haven't fund any function (yet) that > can do this as well. Perhaps these functions/scripts already exist? I would > be very grateful to any suggestions and thoughts. > > kind regards, > Thomas > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- http://had.co.nz/
Paul Hiemstra
2009-Jul-22 15:15 UTC
[R] All possible linear models given multiple explaining variables
Thomas A. Groen wrote:> Hi, > > I would like to have a script/function (or write one) that can calculate the > linear models for all possible combinations of explaining variables. > Eventually I would like to end up with a data base (or data frame) giving > for each model the R2, R2adj, AIC etc. > Currently I'm a bit stuck while writing my own script using the lm() > function from the base package. Also, I haven't fund any function (yet) that > can do this as well. Perhaps these functions/scripts already exist? I would > be very grateful to any suggestions and thoughts. > > kind regards, > Thomas > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >Hi, Take a look at the step() command. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul