plot_var_stability {nestedcv}R Documentation

Plot variable stability

Description

Produces a ggplot2 plot of stability (as SEM) of variable importance across models trained and tested across outer CV folds. Overlays frequency with which variables are selected across the outer folds and optionally overlays directionality for binary response outcome.

Usage

plot_var_stability(
  x,
  final = TRUE,
  top = NULL,
  direction = 0,
  dir_labels = NULL,
  scheme = c("royalblue", "red"),
  breaks = NULL,
  percent = TRUE,
  level = 1,
  sort = TRUE
)

Arguments

x

a nestcv.glmnet or nestcv.train fitted object

final

Logical whether to restrict variables to only those which ended up in the final fitted model or to include all variables selected across all outer folds.

top

Limits number of variables plotted. Set to NULL to plot all variables.

direction

Integer controlling plotting of directionality for binary or regression models. 0 means no directionality is shown, 1 means directionality is overlaid as a colour, 2 means directionality is reflected in the sign of variable importance. Not available for multiclass caret models.

dir_labels

Character vector for controlling the legend when direction = 1

scheme

Vector of 2 colours for directionality when direction = 1

breaks

Vector of continuous breaks for legend colour/size

percent

Logical for nestcv.glmnet objects only, whether to scale coefficients to percentage of the largest coefficient in each model. If set to FALSE, model coefficients are shown and direction is ignored.

level

For multinomial nestcv.glmnet models only, either an integer specifying which level of outcome is being examined, or the level can be specified as a character value.

sort

Logical whether to sort by mean variable importance. Passed to var_stability().

Value

A ggplot2 plot

See Also

var_stability()


[Package nestedcv version 0.7.9 Index]