regsubsets does the same thing better.Since the algorithm returns a best model of each size, the results do not depend on a penalty model for model size: it doesn't make any difference whether you want to use AIC, BIC, CIC, DIC, ...
leaps(x=, y=, wt=rep(1, NROW(x)), int=TRUE, method=c("Cp", "adjr2", "r2"), nbest=10, names=NULL, df=NROW(x), strictly.compatible=TRUE)xnrow(x) in calculating Cp and adjusted R-squaredx in the respective modeladjr2 or r2 is the value of the chosen model
selection statistic for each modelregsubsets, regsubsets.formula,
regsubsets.default
x<-matrix(rnorm(100),ncol=4)
y<-rnorm(25)
leaps(x,y)
Run the code above in your browser using DataLab