leaps (version 2.4)

leaps: all-subsets regressiom

Description

leaps() performs an exhaustive search for the best subsets of the variables in x for predicting y in linear regression, using an efficient branch-and-bound algorithm. It is a compatibility wrapper for regsubsets does the same thing better.

Usage

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)

Arguments

x
A matrix of predictors
y
A response vector
wt
Optional weight vector
int
Add an intercept to the model
method
Calculate Cp, adjusted R-squared or R-squared
nbest
Number of subsets of each size to report
names
vector of names for columns of x
df
Total degrees of freedom to use instead of nrow(x) in calculating Cp and adjusted R-squared
strictly.compatible
Implement misfeatures of leaps() in S

Value

  • A list with components
  • whichlogical matrix. Each row can be used to select the columns of x in the respective model
  • sizeNumber of variables, including intercept if any, in the model
  • cpor adjr2 or r2 is the value of the chosen model selectionstatistic for each model
  • labelvector of names for the columns of x

References

Alan Miller "Subset Selection in Regression" Chapman & Hall

See Also

regsubsets, regsubsets.formula, regsubsets.default

Examples

Run this code
x<-matrix(rnorm(100),ncol=4)
y<-rnorm(25)
leaps(x,y)

Run the code above in your browser using DataCamp Workspace