lmSelect: Best-Subsets Regression

Description Usage Arguments Details Value References See Also Examples

View source: R/generic.R

Description

Best-subsets regression for ordinary linear models.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
lmSelect(formula, ...)

## Default S3 method:
lmSelect(formula, data, subset, weights, na.action,
  model = TRUE, x = FALSE, y = FALSE, contrasts = NULL, offset, ...)

## S3 method for class 'lmSubsets'
lmSelect(formula, ...)

lmSelect_fit(x, y, weights = NULL, offset = NULL,
  include = NULL, exclude = NULL, penalty = "BIC", tolerance = 0,
  pradius = NULL, nbest = 1, ..., .algo = "phbba")

lmSubsets_select(object, penalty = "BIC", ...)

Arguments

object

An object of class lmSubsets.

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

Standard formula interface.

x, y

The model matrix and response.

include, exclude

Force regressors in or out.

penalty

Penalty per parameter (see AIC).

tolerance

Heuristic tolerance.

pradius

Preordering radius.

nbest

Number of best subsets.

...

Ignored.

.algo

Internal use.

Details

The generic lmSelect computes best-variable-subsets regression for ordinary linear models: The nbest best subset models are computed according to an information criterion of the AIC family.

See lmSubsets for further information.

Value

An object of class "lmSelect", i.e. a list with the following components:

nobs

Number of observations.

nvar

Number of variables (not including intercept, if any).

weights

Weights vector.

offset

Offset component.

intercept

TRUE if model has intercept term; FALSE otherwise.

include

Included variables.

exclude

Excluded variables.

nmin, nmax

Minimum and maximum subset sizes.

penalty

Penalty per parameter.

tolerance

Heuristic tolerance.

nbest

Number of best subsets.

df

Degrees of freedom.

rss

Residual sum of squares.

val

Subset values.

which

Selected variables.

References

Hofmann M, Gatu C, Kontoghiorghes EJ (2007). Efficient Algorithms for Computing the Best Subset Regression Models for Large-Scale Problems. Computational Statistics \& Data Analysis, 52, 16–29.

Gatu C, Kontoghiorghes EJ (2006). Branch-and-Bound Algorithms for Computing the Best Subset Regression Models. Journal of Computational and Graphical Statistics, 15, 139–156.

See Also

lmSubsets, summary, methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## load data (with logs for relative potentials)
data("AirPollution", package = "lmSubsets")

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

## canonical example: fit best subsets
best.AirPoll <- lmSelect(mortality ~ ., data = AirPollution, nbest = 20)

## equivalent to:
## Not run: 
all.AirPoll <- lmSubsets(mortality ~ ., data = AirPollution, nbest = 20)
best.AirPoll <- lmSelect(all.AirPoll)

## End(Not run)

## visualize RSS
plot(best.AirPoll)

## summarize
summary(best.AirPoll)

Example output

Call:
  lmSelect(formula = mortality ~ ., data = AirPollution, nbest = 20, 
    penalty = "BIC")

Statistics:
   SIZE BEST sigma    R2        R2adj     pval       Cp       AIC      BIC     
   5     1   35.45910 0.6971012 0.6750722 1.0975e-13 6.683675 605.2575 617.8236
   6     2   34.59656 0.7169005 0.6906875 1.1157e-13 4.978493 603.2015 617.8619
   7     3   33.79705 0.7348369 0.7048185 1.1482e-13 3.621912 601.2743 618.0290
   6     4   34.87009 0.7124062 0.6857771 1.6918e-13 5.819540 604.1465 618.8069
   6     5   35.10688 0.7084870 0.6814951 2.4190e-13 6.552961 604.9587 619.6191
   7     6   34.28204 0.7271721 0.6962859 2.3951e-13 5.056290 602.9841 619.7388
   6     7   35.18135 0.7072491 0.6801425 2.7055e-13 6.784624 605.2129 619.8733
   8     8   33.50824 0.7442674 0.7098418 2.4093e-13 3.857124 601.1015 619.9506
   7     9   34.46458 0.7242590 0.6930431 3.1495e-13 5.601433 603.6213 620.3761
   7    10   34.47918 0.7240254 0.6927829 3.2190e-13 5.645161 603.6721 620.4269
   8    11   33.64706 0.7421441 0.7074327 2.9669e-13 4.254470 601.5977 620.4468
   5    12   36.24421 0.6835396 0.6605243 3.5924e-13 9.221560 607.8855 620.4516
   6    13   35.38715 0.7038141 0.6763895 3.6815e-13 7.427446 605.9128 620.5732
   7    14   34.53343 0.7231562 0.6918154 3.4908e-13 5.807818 603.8608 620.6156
   6    15   35.45422 0.7026903 0.6751616 4.0686e-13 7.637752 606.1401 620.8005
   6    16   35.49316 0.7020369 0.6744477 4.3113e-13 7.760027 606.2718 620.9322
   7    17   34.64911 0.7212983 0.6897472 4.1474e-13 6.155493 604.2621 621.0169
   7    18   34.67023 0.7209585 0.6893689 4.2797e-13 6.219089 604.3352 621.0900
   7    19   34.68636 0.7206987 0.6890797 4.3835e-13 6.267703 604.3911 621.1458
   6    20   35.55912 0.7009283 0.6732365 4.7553e-13 7.967486 606.4946 621.1550

lmSubsets documentation built on May 31, 2017, 3:55 a.m.