plot_density: Generate density plots

View source: R/plot_density.R

plot_densityR Documentation

Generate density plots

Description

For each policy alternative, this function generates probability density plots of the highest (or lowest if the threshold is a minimum) projected outcome across simulation runs. The decision threshold is shown directly on the plot as a vertical line. The area under the probability density curve where the threshold value is exceeded is shaded to visually display the downside risk of the policy alternative.

Usage

plot_density(max_min_values_list, D, Dt_max = TRUE, risk_measures)

Arguments

max_min_values_list

A list generated by get_max_min_values()

D

A single threshold value

Dt_max

A logical value indicating whether the decision threshold is a maximum (TRUE) or a minimum (FALSE). The default is TRUE.

risk_measures

A list of risk scores generated by calculate_risk(). The policy alternatives in the risk_measures list must be in the same order as in the max_min_values_list.

Value

A list of ggplots, one for each policy alternative.

Examples

tmin <- "2021-01-01"
tmax <- "2021-04-10"
Dt <- rep(750, nrow(psa_data$Baseline))
D <- 750

risk_measures <- calculate_risk(
  psa_data,
  tmin = tmin,
  tmax = tmax,
  Dt = Dt,
  Dt_max = TRUE
)

peak_values_list <- get_max_min_values(
  psa_data,
  tmin = tmin,
  tmax = tmax,
  Dt_max = TRUE
)

density_plots <- plot_density(
  peak_values_list,
  D = D,
  Dt_max = TRUE,
  risk_measures
)

DUToolkit documentation built on Sept. 14, 2025, 5:09 p.m.