calculate_risk: Calculate risk measures

View source: R/calculate_risk.R

calculate_riskR Documentation

Calculate risk measures

Description

This function calculates the expected risk measure for each policy alternative using the outputs from multiple model runs with different input parameter sets (e.g., probabilistic sensitivity, uncertainty, or Bayesian inference analysis).

Usage

calculate_risk(data, tmin, tmax, Dt, Dt_max = TRUE, W = FALSE, weight = NULL)

Arguments

data

A list of data.frames (one data.frame for each policy alternative).

tmin

A numeric value or a date specifying the minimum simulation time to include in the analysis (ex. 1 or "2021-01-01"). This should correspond to a value in the first column of each data.frame in data.

tmax

A numeric value or a date specifying the maximum simulation time to include in the analysis (ex. 100 or "2021-04-10"). This should correspond to a value in the first column of each data.frame in data.

Dt

A numeric vector of decision thresholds, one for each model time step between tmin and tmax.

Dt_max

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

W

A logical value indicating whether the risk calculation should be weighted (TRUE) or not (FALSE). The default is FALSE (an equal weight of 1 is assumed for all simulation runs).

weight

A list of numeric vectors of weights for the risk calculation, with one weight corresponding to each time step. Required if W is TRUE.

Value

A list of risk scores, one for each policy alternative.

data format

Each data.frame in data contains the results from multiple model runs using different parameter sets (e.g., from probabilistic sensitivity, uncertainty, or Bayesian inference analysis). The first column contains the model time and subsequent columns contain the predicted output for each simulation run at the respective time. The model time in the first column must contain numeric values indicating a simulation time (ex. 1, 2, 3,...) or dates (ex. "2021-01-01", "2021-01-02") which must be in R Date format (i.e., class="Date"). To ensure a consistent basis for comparison, the model time in the first column should be the same for each policy alternative (data.frame).

Examples

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

calculate_risk(
  psa_data,
  tmin = tmin,
  tmax = tmax,
  Dt = Dt,
  Dt_max = TRUE
)

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