data(mtcars)
# Fit a linear model
regression_model <- lm(cyl ~ ., data = mtcars)
# Perform backward stepwise, forcing "wt" and "hp" to remain
stepwise <- step_bw_p(
regression_model,
forced = c("wt", "hp"),
trace = FALSE
)
# Extract final model and view summary
final_model <- stepwise$final_model
summary(final_model)
Run the code above in your browser using DataLab