regsubsets

0th

Percentile

functions for model selection

Generic function for regression subset selection with methods for formula and matrix arguments.

Keywords
regression
Usage
regsubsets(x=, ...)

regsubsets.formula(x=, data=, weights=rep(1, length(y)), nbest=1, nvmax=8, force.in=NULL, force.out=NULL, intercept=TRUE, method=c("exhaustive", "backward", "forward", "seqrep"), really.big=FALSE,...)

regsubsets.default(x=, y=, weights=rep(1, length(y)), nbest=1, nvmax=8, force.in=NULL, force.out=NULL, intercept=TRUE, method=c("exhaustive", "backward", "forward", "seqrep"), really.big=FALSE,...)

summary.regsubsets(object,all.best=TRUE,matrix=TRUE,matrix.logical=FALSE,df=NULL,...)

Arguments
x
design matrix or model formula for full model
data
Optional data frame
y
response vector
weights
weight vector
nbest
number of subsets of each size to record
nvmax
maximum size of subsets to examine
force.in
index to columns of design matrix that should be in all models
force.out
index to columns of design matrix that should be in no models
intercept
Add an intercept?
method
Use exhaustive search, forward selection, backward selection or sequential replacement to search.
really.big
Must be T to perform exhaustive search on more than 50 variables.
object
regsubsets object
all.best
Show all the best subsets or just one of each size
matrix
Show a matrix of the variables in each model or just summary statistics
matrix.logical
With matrix=TRUE, the matrix is logical TRUE/FALSE or string "*"/code{" "}
df
Specify a number of degrees of freedom for the summary statistics. The default is n-1
...
Other arguments for future methods
Value

  • An object of class "regsubsets" containing no user-serviceable parts. It is designed to be processed by summary.regsubsets.

Note

This function improves on leaps in several ways. The design matrix need not be of full rank. The ability to restrict nvmax speeds up exhaustive searches considerably. There is no hard-coded limit to the number of variables.

See Also

leaps

Aliases
  • regsubsets
  • regsubsets.default
  • print.regsubsets
  • print.summary.regsubsets
  • regsubsets.formula
  • summary.regsubsets
Examples
data(swiss)
a<-regsubsets(as.matrix(swiss[,-1]),swiss[,1])
summary(a)
b<-regsubsets(Fertility~.,data=swiss)
summary(a)
Documentation reproduced from package leaps, version 2.4, License: GPL version 2 or later

Community examples

seydoun at Nov 13, 2017 leaps v3.0

data(swiss) a<-regsubsets(as.matrix(swiss[,-1]),swiss[,1]) summary(a) b<-regsubsets(Fertility~.,data=swiss,nbest=2) summary(b) coef(a, 1:3) vcov(a, 3)