lmSubsets (version 0.5-2)

lmSubsets: All-subsets regression

Description

All-variable-subsets selection in ordinary linear regression.

Usage

lmSubsets(formula, ...)

# S3 method for default lmSubsets(formula, data, subset, weights, na.action, model = TRUE, x = FALSE, y = FALSE, contrasts = NULL, offset, ...)

Arguments

formula, data, subset, weights, na.action, model, x, y, contrasts, offset

standard formula interface

...

fowarded to lmSubsets_fit()

Value

"lmSubsets"---a list containing the components returned by lmSubsets_fit()

Further components include call, na.action, weights, offset, contrasts, xlevels, terms, mf, x, and y. See lm() for more information.

Details

The lmSubsets() generic provides various methods to conveniently specify the regressor and response variables. The standard formula interface (see lm()) can be used, or the model information can be extracted from an already fitted "lm" object. The model matrix and response can also be passed in directly.

After processing of the arguments, the call is forwarded to lmSubsets_fit().

See Also

Examples

Run this code
# NOT RUN {
## load data
data("AirPollution", package = "lmSubsets")


###################
##  basic usage  ##
###################

## canonical example: fit all subsets
lm_all <- lmSubsets(mortality ~ ., data = AirPollution, nbest = 5)
lm_all

## plot RSS and BIC
plot(lm_all)

## summary statistics
summary(lm_all)


############################
##  forced in-/exclusion  ##
############################

lm_force <- lmSubsets(lm_all, include = c("nox", "so2"),
                      exclude = "whitecollar")
lm_force
# }

Run the code above in your browser using DataLab