regsubsets {leaps}R Documentation

functions for model selection

Description

Model selection by exhaustive search, forward or backward stepwise, or sequential replacement

Usage

regsubsets(x=, ...)

## S3 method for class 'formula':
regsubsets(x=, data=, weights=NULL, nbest=1, nvmax=8, force.in=NULL, force.out=NULL, intercept=TRUE, method=c("exhaustive", "backward", "forward", "seqrep"), really.big=FALSE,...)

## Default S3 method:
regsubsets(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,...)

## S3 method for class 'biglm':
regsubsets(x,nbest=1,nvmax=8,force.in=NULL,
method=c("exhaustive","backward", "forward", "seqrep"), really.big=FALSE,...)

## S3 method for class 'regsubsets':
summary(object,all.best=TRUE,matrix=TRUE,matrix.logical=FALSE,df=NULL,...)

Arguments

x design matrix or model formula for full model, or biglm object
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 TRUE 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 "*"/" "
df Specify a number of degrees of freedom for the summary statistics. The default is n-1
... Other arguments for future methods

Details

Since this function returns separate best models of all sizes up to nvmax and since different model selection criteria such as AIC, BIC, ... differ only in how models of different sizes are compared, the results do not depend on the choice of cost-complexity tradeoff.

When x is a biglm object it is assumed to be the full model, so force.out is not relevant. If there is an intercept it is forced in by default; specify a force.in as a logical vector with FALSE as the first element to allow the intercept to be dropped.

Value

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

See Also

leaps

Examples

data(swiss)
a<-regsubsets(as.matrix(swiss[,-1]),swiss[,1])
summary(a)
b<-regsubsets(Fertility~.,data=swiss)
summary(a)

[Package leaps version 2.8 Index]