calib_plot: Produce a calibration plot for a set of predicted...

View source: R/calib_plot.R

calib_plotR Documentation

Produce a calibration plot for a set of predicted probabilities for a binary classifier.

Description

Produce a calibration plot for a set of predicted probabilities for a binary classifier.

Usage

calib_plot(
  form,
  data,
  cuts = 10,
  refline = TRUE,
  smooth = FALSE,
  fitline = FALSE,
  rug = FALSE
)

Arguments

form

A formula where the left-hand side is the variable representing the observed outcome, 0 or 1, and the right-hand side represents the column names of the different model probabilities.

data

A data frame that contains at least two columns, one of which is the observed outcome and the others that are predicted probabilities.

cuts

The number of bins of probabilities. Default = 10.

refline

Whether or not to include a 45 degree reference line. Default = TRUE.

smooth

Whether or not to include a smoothed loess curve for each models' probabilities. Default = FALSE.

fitline

Whether or not to include a best-fit line for each models' probabilities. Default = FALSE.

rug

Whether or not to include a rug plot of the observed probabilities. Usually works best with only one model. Default = FALSE.

Examples

m1 <- glm(mpg > 20 ~ cyl + disp + hp, family = 'binomial', data = mtcars)
results <- data.frame(outcome = mtcars$mpg > 20, lr_1 = predict(m1, type = 'response'))
calib_plot(outcome ~ lr_1, data = results, cuts = 5)

gweissman/gmish documentation built on Feb. 16, 2025, 8:38 a.m.