Learn R Programming

scoringutils (version 2.3.0)

plot_discrimination: Plot discrimination for binary forecasts

Description

Visualise the discrimination ability of binary forecasts by plotting the distribution of predicted probabilities, stratified by the observed outcome. A well-discriminating model will show clearly separated distributions for the two observed levels.

Usage

plot_discrimination(forecast, type = c("histogram", "density"), ...)

Value

A ggplot object showing the distribution of predicted probabilities, coloured by observed outcome level.

Arguments

forecast

A forecast_binary object (see as_forecast_binary()).

type

Character, either "histogram" (default) or "density". "histogram" shows a histogram with proportions on the y-axis; "density" shows kernel density curves.

...

Additional arguments passed to ggplot2::geom_histogram() or ggplot2::geom_density(), depending on type. For example, bins or binwidth for histograms, or bw and adjust for density plots.

Examples

Run this code
library(ggplot2)
forecast <- as_forecast_binary(na.omit(example_binary))

plot_discrimination(forecast)

plot_discrimination(forecast, type = "density")

plot_discrimination(forecast, bins = 10)

plot_discrimination(forecast) +
  facet_wrap(~model)

Run the code above in your browser using DataLab