# stepwise backward regression
model <- lm(y ~ ., data = surgical)
ols_step_backward_sbic(model)
# stepwise backward regression plot
model <- lm(y ~ ., data = surgical)
k <- ols_step_backward_sbic(model)
plot(k)
# selection metrics
k$metrics
# final model
k$model
# include or exclude variable
# force variables to be included in the selection process
ols_step_backward_sbic(model, include = c("alc_mod", "gender"))
# use index of variable instead of name
ols_step_backward_sbic(model, include = c(7, 6))
# force variable to be excluded from selection process
ols_step_backward_sbic(model, exclude = c("alc_heavy", "bcs"))
# use index of variable instead of name
ols_step_backward_sbic(model, exclude = c(8, 1))
Run the code above in your browser using DataLab