methods: Methods for 'lmSubsets' and 'lmSelect' objects

Description Usage Arguments Details See Also Examples

Description

Extractor methods for lmSubsets and lmSelect objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
## S3 method for class 'lmSubsets'
variable.names(object, size, best = 1, ...)
## S3 method for class 'lmSubsets'
formula(x, size, best = 1, ...)
## S3 method for class 'lmSubsets'
model.frame(formula, size, best = 1, ...)
## S3 method for class 'lmSubsets'
model.matrix(object, size, best = 1, ...)
## S3 method for class 'lmSubsets'
model.response(data, ...)
## S3 method for class 'lmSubsets'
refit(object, size, best = 1, ...)
## S3 method for class 'lmSubsets'
deviance(object, size, best = 1, ..., drop = TRUE)
## S3 method for class 'lmSubsets'
logLik(object, size, best = 1, ..., drop = TRUE)
## S3 method for class 'lmSubsets'
AIC(object, size, best = 1, ..., k = 2, drop = TRUE)
## S3 method for class 'lmSubsets'
BIC(object, size, best = 1, ..., drop = TRUE)
## S3 method for class 'lmSubsets'
coef(object, size, best = 1, ...)
## S3 method for class 'lmSubsets'
vcov(object, size, best = 1, ...)
## S3 method for class 'lmSubsets'
fitted(object, size, best = 1, ...)
## S3 method for class 'lmSubsets'
residuals(object, size, best = 1, ...)

## S3 method for class 'lmSelect'
variable.names(object, best = 1, ..., drop = TRUE)
## S3 method for class 'lmSelect'
formula(x, best, ...)
## S3 method for class 'lmSelect'
model.frame(formula, best, ...)
## S3 method for class 'lmSelect'
model.matrix(object, best, ...)
## S3 method for class 'lmSelect'
model.response(data, ...)
## S3 method for class 'lmSelect'
refit(object, best = 1, ...)
## S3 method for class 'lmSelect'
deviance(object, best = 1, ...)
## S3 method for class 'lmSelect'
logLik(object, best = 1, ..., drop = TRUE)
## S3 method for class 'lmSelect'
AIC(object, best = 1, ..., k = 2, drop = TRUE)
## S3 method for class 'lmSelect'
BIC(object, best = 1, ..., drop = TRUE)
## S3 method for class 'lmSelect'
coef(object, best = 1, ...)
## S3 method for class 'lmSelect'
vcov(object, best = 1, ...)
## S3 method for class 'lmSelect'
fitted(object, best = 1, ...)
## S3 method for class 'lmSelect'
residuals(object, best = 1, ...)

Arguments

object, formula, data, x

An object of class lmSubsets or lmSelect.

size

The subset size.

best

The subset rank.

...

Forwarded arguments.

k

AIC penalty.

drop

Reduce dimensionality of returned object.

Details

The extractor methods work for lmSubsets and lmSelect objects that have been generated using the formula interface.

The information is extracted from the model refitted to a given size. If a method is not available, refit can be called explicitly to obtain the lm object.

For convenience, the submodel size can be inferred from the name of an information criterion passed as the size argument. Currently, only "AIC" and "BIC" are recognized.

The method refit returns an lm object fitted to the desired size and rank.

See Also

lmSubsets, lmSelect, refit.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## load data
data("AirPollution", package = "lmSubsets")

## fit subsets (5 best subsets per size)
all.AirPoll <- lmSubsets(mortality ~ ., data = AirPollution, nbest = 5)

## extract information (for best subset of size 3)
coef(all.AirPoll, size = 3)
vcov(all.AirPoll, size = 3)
residuals(all.AirPoll, size = 3)
fitted(all.AirPoll, size = 3)
model.matrix(all.AirPoll, size = 3)

## select best subsets
best.AirPoll <- lmSelect(all.AirPoll)

## extract information (for best BIC subset)
deviance(best.AirPoll)
logLik(best.AirPoll)
AIC(best.AirPoll)
BIC(best.AirPoll, best = 1:5)

## refit model (inferred size)
lm5 <- refit(all.AirPoll, size = "BIC")
summary(lm5)
## (Note that the p-values are not valid due to model selection.)

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