regsubsets
does the same thing better.leaps(x=, y=, wt=rep(1, NROW(x)), int=TRUE, method=c("Cp", "adjr2", "r2"), nbest=10, names=NULL, df=NROW(x), strictly.compatible=T)
x
nrow(x)
in calculating Cp and adjusted R-squaredx
in the respective modeladjr2
or r2
is the value of the chosen model selectionstatistic 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