Learn R Programming

olsrr (version 0.4.0)

ols_best_subset: Best Subsets Regression

Description

Select the subset of predictors that do the best at meeting some well-defined objective criterion, such as having the largest R2 value or the smallest MSE, Mallow's Cp or AIC.

Usage

ols_best_subset(model, ...)

# S3 method for ols_best_subset plot(x, model = NA, ...)

Arguments

model

an object of class lm

...

other inputs

x

an object of class ols_best_subset

Value

ols_best_subset returns an object of class "ols_best_subset". An object of class "ols_best_subset" is a data frame containing the following components:

n

model number

predictors

predictors in the model

rsquare

rsquare of the model

adjr

adjusted rsquare of the model

predrsq

predicted rsquare of the model

cp

mallow's Cp

aic

akaike information criteria

sbic

sawa bayesian information criteria

sbc

schwarz bayes information criteria

gmsep

estimated MSE of prediction, assuming multivariate normality

jp

final prediction error

pc

amemiya prediction criteria

sp

hocking's Sp

References

Kutner, MH, Nachtscheim CJ, Neter J and Li W., 2004, Applied Linear Statistical Models (5th edition). Chicago, IL., McGraw Hill/Irwin.

Examples

Run this code
# NOT RUN {
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
ols_best_subset(model)
# }
# NOT RUN {
# }
# NOT RUN {
# plot
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
k <- ols_best_subset(model)
plot(k)
# }

Run the code above in your browser using DataLab