if (FALSE) {
# stepwise regression
model <- lm(y ~ ., data = surgical)
ols_step_both_p(model)
# stepwise regression plot
model <- lm(y ~ ., data = surgical)
k <- ols_step_both_p(model)
plot(k)
# selection metrics
k$metrics
# final model
k$model
# include or exclude variables
model <- lm(y ~ ., data = stepdata)
# force variable to be included in selection process
ols_step_both_p(model, include = c("x6"))
# use index of variable instead of name
ols_step_both_p(model, include = c(6))
# force variable to be excluded from selection process
ols_step_both_p(model, exclude = c("x1"))
# use index of variable instead of name
ols_step_both_p(model, exclude = c(1))
}
Run the code above in your browser using DataLab