View source: R/plot.gg_beta_varpro.R
| plot.gg_beta_varpro | R Documentation |
gg_beta_varpro objectHorizontal bar chart of the mean absolute coefficient
\mathrm{mean}(|\hat{\beta}|) per variable, sorted
descending so
the eye lands on the top variable first. Bars filled blue when above the
selection cutoff, grey otherwise. Dashed red line marks the cutoff.
## S3 method for class 'gg_beta_varpro'
plot(x, ...)
x |
A |
... |
Not currently used. |
A ggplot object.
Each bar is the average magnitude of a per-rule lasso coefficient for that variable. The numeric scale carries the predictor's units. If "age" is in years and "creatinine" is in mg/dL, a longer bar for age does not mean age is "more important" in any unit-free sense. Comparisons across data sets or across variables with very different units require keeping the units context in mind. Within one data set, bars are comparable up to that unit caveat.
Variables above the cutoff are coloured blue and flagged selected;
variables below are grey. Lasso shrinkage can drive a rule's
\hat{\beta} to
exactly zero; those rules are kept in the average, so a variable
with many shrunk-to-zero rules will sit lower in the ranking than
one whose released coefficients are consistently non-zero.
For a classification fit, variables are sorted by
mean(|sum-of-class-beta|) descending and that ordering is shared
across every facet, so rows line up between classes for visual
comparison. Each facet has its own cutoff line.
Use the bar chart as a selection ranking, not as an effect-size axis.
Pair it with gg_varpro() to see where split-strength importance and
local lasso-beta importance agree or disagree; disagreement is often the
interesting signal.
gg_beta_varpro().
if (requireNamespace("varPro", quietly = TRUE)) {
set.seed(1)
v <- varPro::varpro(mpg ~ ., data = mtcars, ntree = 50)
plot(gg_beta_varpro(v))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.