Skip to content

Instantly share code, notes, and snippets.

@benjaminrich
benjaminrich / stepwise.R
Created September 25, 2023 00:58
Stepwise regression
stepwise_forward <- function(base_fit, candidates, alpha=0.05, ...) UseMethod("stepwise_forward")
stepwise_backward <- function(base_fit, candidates, alpha=0.01, ...) UseMethod("stepwise_backward")
forward_step <- function(base_fit, candidates, alpha=0.05, ...) UseMethod("forward_step")
backward_step <- function(base_fit, candidates, alpha=0.01, ...) UseMethod("backward_step")
fit_all_models <- function(base_fit, all_formulas, ...) UseMethod("fit_all_models")