Build regression model from a set of candidate predictor variables by removing predictors based on akaike information criterion, in a stepwise manner until there is no variable left to remove any more.

ols_step_backward_aic(model, ...)

# S3 method for default
ols_step_backward_aic(model, details = FALSE, ...)

# S3 method for ols_step_backward_aic
plot(x, ...)

Arguments

model

An object of class lm; the model should include all candidate predictor variables.

...

Other arguments.

details

Logical; if TRUE, will print the regression result at each step.

x

An object of class ols_step_backward_aic.

Value

ols_step_backward_aic returns an object of class "ols_step_backward_aic". An object of class "ols_step_backward_aic" is a list containing the following components:

steps

total number of steps

predictors

variables removed from the model

aics

akaike information criteria

ess

error sum of squares

rss

regression sum of squares

rsq

rsquare

arsq

adjusted rsquare

Deprecated Function

ols_stepaic_backward() has been deprecated. Instead use ols_step_backward_aic().

References

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.

See also

Other variable selection procedures: ols_step_all_possible, ols_step_backward_p, ols_step_best_subset, ols_step_both_aic, ols_step_forward_aic, ols_step_forward_p

Examples

# stepwise backward regression model <- lm(y ~ ., data = surgical) ols_step_backward_aic(model)
#> Backward Elimination Method #> --------------------------- #> #> Candidate Terms: #> #> 1 . bcs #> 2 . pindex #> 3 . enzyme_test #> 4 . liver_test #> 5 . age #> 6 . gender #> 7 . alc_mod #> 8 . alc_heavy #> #> #> Variables Removed: #> #> <U+2716> alc_mod #> <U+2716> gender #> <U+2716> age #> #> No more variables to be removed.
#> #> #> Backward Elimination Summary #> --------------------------------------------------------------------------- #> Variable AIC RSS Sum Sq R-Sq Adj. R-Sq #> --------------------------------------------------------------------------- #> Full Model 736.390 1825905.713 6543614.824 0.78184 0.74305 #> alc_mod 734.407 1826477.828 6543042.709 0.78177 0.74856 #> gender 732.494 1829435.617 6540084.920 0.78142 0.75351 #> age 730.620 1833716.447 6535804.090 0.78091 0.75808 #> --------------------------------------------------------------------------- #>
# stepwise backward regression plot model <- lm(y ~ ., data = surgical) k <- ols_step_backward_aic(model)
#> Backward Elimination Method #> --------------------------- #> #> Candidate Terms: #> #> 1 . bcs #> 2 . pindex #> 3 . enzyme_test #> 4 . liver_test #> 5 . age #> 6 . gender #> 7 . alc_mod #> 8 . alc_heavy #> #> #> Variables Removed: #> #> <U+2716> alc_mod #> <U+2716> gender #> <U+2716> age #> #> No more variables to be removed.
plot(k)