[R] find lowest AIC of a LM

Fabio Berzaghi fabe at dmu.dk
Thu Apr 18 14:41:44 CEST 2013

hello all,

I have a simple linear model with 4/5 variables that I am trying to fit. 
I would like to find the lowest AIC value with any combination of all 
the variables. I would like to implement this with a while/for loop. 
Possibly I would like to generalize this so then I can use it when I 
have many more variables. I do not want to use step AIC. At the moment I 
am doing it manually but I would like to automate the process because I 
have many species. I want to compute all possible combinations with all 
the variables and know which combination gives the lowest AIC.
My function looks like this 

I cannot seem to find a library that has a function that does this 

Thank you

More information about the R-help mailing list