| plot.StepReg | R Documentation |
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.
## S3 method for class 'StepReg'
plot(
x,
strategy = attr(x, "nonhidden"),
process = c("overview", "detail"),
num_digits = 6,
...
)
x |
A StepReg object containing the results of stepwise regression analysis. |
strategy |
Character. Specifies which selection strategy to visualize:
Default is the first strategy name in the StepReg object. |
process |
Character. Specifies the type of visualization to display:
Default is "overview". |
num_digits |
Integer. Number of decimal places to display in the plots. Default is 6. |
... |
Additional argument passed to plotting functions (currently not used). |
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
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
stepwise for creating StepReg objects
## Not run:
# 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)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.