cal_plot: Generate a single calibration plot with error bars showing 95...

View source: R/cal_plots.R

cal_plotR Documentation

Generate a single calibration plot with error bars showing 95 percent confidence intervals

Description

This code builds off of code written by Darren Dahly, PhD in this blog post: https://darrendahly.github.io/post/homr/.

Usage

cal_plot(
  df,
  outcome,
  prediction,
  n_bins = 10,
  show_loess = FALSE,
  plot_title = "",
  ...
)

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.

n_bins

Number of bins. Defaults to 10. Set to 0 to hide binned calibration.

show_loess

Whether to show loess smoothed calibration estimates. Defaults to FALSE. For cal_plot(), you can display both a binned calibration plot and a loess curve. In contrast, for cal_plot_multi(), these options are mutually exclusive.

plot_title

A character string containing the title for the resulting plot.

Value

A ggplot containing the calibration plot

Examples

data(single_model_dataset)
cal_plot(single_model_dataset, outcome = 'outcomes', prediction = 'predictions', n_bins = 5)

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