lmSubsets {lmSubsets} | R Documentation |
All-subsets regression
Description
All-variable-subsets selection in ordinary linear regression.
Usage
lmSubsets(formula, ...)
## Default S3 method:
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 |
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()
.
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.
See Also
lmSubsets.matrix()
for the"matrix"
interfacelmSubsets_fit()
for the low-level interfacelmSelect()
for best-subset regression
Examples
## 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