[R] regsubsets() [leaps package] - please share some good examples of use
tlumley at u.washington.edu
Fri Mar 13 10:02:12 CET 2009
On Fri, 13 Mar 2009, Tal Galili wrote:
> Thanks Thomas.
> Assuming I want to change the "k" factor (used in AIC type procedures), is
> there a way to do that ?
There is no "k" factor in the leaps algorithm. It always reports the best model with one predictor, the best model with two predictors, the best model with three predictors, and so on. When comparing models with the same number of predictors the cost-complexity penalty cancels out and so only the residual sum of squares is needed. You can add any other penalty later.
> Also - is there a way to force the model to make only one "step" in the
> creation of the model ?
For forward selection there is: set nvmax to 1, and only models with one variable will be considered. Then use force.in to force in the one variable you selected and set nvmax=2 to consider models with two variables.
It might well be just as easy to program this yourself -- the leaps package doesn't seem to be a good fit for what you are trying to do.
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help