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.

best_subset(model, ...)

Arguments

model
an object of class lm
...
other inputs

Value

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

References

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

Examples

model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars) best_subset(model)
#> Best Subsets Regression #> ------------------------------ #> Model Index Predictors #> ------------------------------ #> 1 wt #> 2 hp wt #> 3 hp wt qsec #> 4 disp hp wt qsec #> ------------------------------ #> #> Subsets Regression Summary #> ------------------------------------------------------------------------------------------------------------------------------- #> Adj. Pred #> Model R-Square R-Square R-Square C(p) AIC SBIC SBC GMSEP Jp Sp PC #> ------------------------------------------------------------------------------------------------------------------------------- #> 1 0.7530 0.7450 0.7087 12.4809 166.0294 74.2916 170.4266 9.8972 9.8572 0.3199 0.2801 #> 2 0.8270 0.8150 0.7811 2.3690 156.6523 66.5755 162.5153 7.4314 7.3563 0.2402 0.2090 #> 3 0.8350 0.8170 0.782 3.0617 157.1426 67.7238 164.4713 7.6140 7.4756 0.2461 0.2124 #> 4 0.8350 0.8110 0.771 5.0000 159.0696 70.0408 167.8640 8.1810 7.9497 0.2644 0.2259 #> -------------------------------------------------------------------------------------------------------------------------------
# plot model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars) k <- best_subset(model) plot(k)