Creates informative visualizations of the variable selection process from a StepReg object. This function generates two types of plots: detailed step-by-step selection process and an overview of the final selected variables.
A StepReg object containing the results of stepwise regression analysis.
Character. Specifies which selection strategy to visualize:
"forward" - Forward selection
"backward" - Backward elimination
"bidirection" - Bidirectional selection
"subset" - Best subset selection
Default is the first strategy name in the StepReg object.
Character. Specifies the type of visualization to display:
"detail" - Shows detailed step-by-step selection process with variable entry/removal
"overview" - Shows summary of the selection process with metric values
Default is "overview".
Integer. Number of decimal places to display in the plots. Default is 6.
Additional argument passed to plotting functions (currently not used).
A ggplot object showing either:
For "detail" process: A heatmap showing variable selection status at each step
For "overview" process: A line plot showing metric values across steps
The function creates different types of visualizations based on the selection strategy:
For forward/backward/bidirectional selection:
detail view shows a heatmap with green tiles for added variables, tan tiles for removed variables, and gray tiles for non-selected variables
Overview shows metric values across steps with variable labels
For subset selection:
detail view shows a heatmap of selected variables at each step
Overview shows metric values for different subset sizes
stepwise for creating StepReg objects
if (FALSE) { # \dontrun{
# Load example data
data(mtcars)
# Run stepwise regression with multiple strategies
formula <- mpg ~ .
result <- stepwise(
formula = formula,
data = mtcars,
type = "linear",
strategy = c("forward", "bidirection", "subset"),
metric = c("AIC", "BIC", "SL")
)
# Generate default overview plot
plot(result)
# Generate detailed plot for forward selection
plot(result, strategy = "forward", process = "detail")
# Generate overview plot with 3 decimal places
plot(result, strategy = "bidirection", process = "overview", num_digits = 3)
} # }