threshperf_plot: Generate a threshold-performance plot for a single model

View source: R/threshperf_plots.R

threshperf_plotR Documentation

Generate a threshold-performance plot for a single model

Description

Generate a threshold-performance plot for a single model

Usage

threshperf_plot(
  df,
  outcome,
  prediction,
  show_denom = TRUE,
  plot_title = "",
  xmin = 0,
  xmax = 1,
  pre_tp_geoms = NULL,
  pre_dist_geoms = NULL,
  post_tp_geoms = NULL,
  post_dist_geoms = NULL,
  heights = c(10, 1),
  widths = c(1, 2, 1),
  positive = "has_sepsis",
  thresholds = NULL
)

Arguments

df

The df as a data.frame.

outcome

A character string containing the name of the column containing the outcomes (expressed as 0/1s).

prediction

A character string containing the name of the column containing the predictions.

show_denom

Show the denominator (as a fraction of the maximum positives/negatives) for the positive predictive value (PPV) and negative predictive value (NPV).

plot_title

A character string containing the title for the resulting plot.

xmin

The minimum possible prediction. Defaults to 0.

xmax

The maximum possible prediction. Defaults to 1.

pre_tp_geoms

A ggplot geom_* (or a list of geoms) that should be drawn on the threshold-performance plot prior to rendering it.

pre_dist_geoms

A ggplot geom_* (or a list of geoms) that should be drawn on the distribution plot prior to rendering it.

post_tp_geoms

A ggplot geom_* (or a list of geoms) that should be drawn on the threshold-performance plot after rendering it.

post_dist_geoms

A ggplot geom_* (or a list of geoms) that should be drawn on the distribution plot after rendering it.

heights

A numeric vector of length 2 with ratio of heights of plots. Defaults to c(10, 1).

widths

A numeric vector of length 3 with ratio of widths of plots. The first and third elements refer to padding. Defaults to c(1, 2, 1).

Value

A ggplot containing the threshold-performance plot. The 95 percent confidence intervals are estimated using Wilson's interval from the Hmisc binconf function.

Examples

data(single_model_dataset)
threshperf_plot(single_model_dataset, outcome = 'outcomes', prediction = 'predictions')

ML4LHS/runway documentation built on Sept. 9, 2023, 8:27 p.m.