allReg: All Subsets Regression

View source: R/allreg.R

allRegR Documentation

All Subsets Regression

Description

Creates a table of the best subsets of explanatory variables for a response variable.

Usage

allReg(x, y, wt = rep(1, nrow(x)), nmax = ncol(x), nbst = 3,
  na.rm.x = TRUE, lin.dep = 10)

Arguments

x

matrix of candidate explanatory variables.

y

the response variable.

wt

the weight variable if needed.

nmax

the maximum number of explanatory variables to include in the largest model.

nbst

the number of best models to determine for each subset size.

na.rm.x

logical, if TRUE, then rows with missing values in x and the corresponding elements in y will be removed prior to analysis. If FALSE, then missing values are not removed and the analysis will fail if there are missing values in x.

lin.dep

a value to protect against linear dependencies; the number of the number of observations must be greater than the number of columns in x plus lin.dep.

Value

A data frame containing these columns:

model.formula

the subset model formula

nvars

the size (number of variables in the subset model

stderr

the standard error of the subsbet model

R2

the coefficient of determination for the subset model

adjr2

the adjusted r-squared of the subbset model

Cp

Mallow's Cp for the subset model

press

the press statistic for the subset model

Note

This function is a wrapper for the regsubsets function in the leaps package.

References

Helsel, D.R. and Hirsch, R.M., 2002, Statistical methods in water resources: U.S. Geological Survey Techniques of Water-Resources Investigations, book 4, chap. A3, 522 p.

Mallow, C.L., 1973, Come comments of Cp: Technometrics, v. 15, p. 661–675.

Miller, A.J., 1990, Subset selection in regression in Monographs on Statistics and Applied Probability 40: London, Chapman and Hall.

See Also

regsubsets

Examples

# See the regression vignette for examples
.pager <- options("pager")
options(pager="console")
vignette(package="smwrStats")
options(.pager)

USGS-R/smwrStats documentation built on Oct. 11, 2022, 6:15 a.m.