Bins predicted probabilities and plots the observed event rate in each bin against the mean prediction, with the diagonal marking perfect calibration. Points off the diagonal show over- or under-confidence.

geom_calibration(
  mapping = NULL,
  data = NULL,
  bins = 10,
  color = NULL,
  diagonal = TRUE
)

Arguments

mapping, data

Standard layer overrides. Map the predicted probability to x and the binary outcome (0/1) to y.

bins

Number of probability bins.

color

Curve color.

diagonal

Draw the perfect-calibration reference line.

Value

A Layer to add with +.

Examples

set.seed(1)
p <- runif(300)
d <- data.frame(pred = p, obs = rbinom(300, 1, p^1.3))
ggnext(d, aes(pred, obs)) + geom_calibration()
#> <ggnext plot>
#>   data:  300 x 2
#>   aes:   x = pred, y = obs
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static