get_relative_values: Find output values at time points relative to the peak (or...

View source: R/get_relative_values.R

get_relative_valuesR Documentation

Find output values at time points relative to the peak (or minimum)

Description

For each policy alternative, this function finds the the model output values for each simulation run at the specified time points relative to the peak (or minimum) value.

Usage

get_relative_values(data, max_min_values_list, t_s, t_ss, Dt_max = TRUE)

Arguments

data

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

max_min_values_list

A list generated by get_max_min_values().

t_s

The total time window to examine before and after the peak (or minimum) value.

t_ss

The interval size for sampling time points within the specified time window t_s. For example, if t_s = 20 and t_ss = 10 the function will extract values at peak_time-20, peak_time-10, peak_time, peak_time+10, peak_time+20.

Dt_max

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

Value

A list of nested lists with the following elements: (i) a data.frame of values recorded at specific time steps relative to the peak time (e.g., peak-10, peak, peak+10) for each model run, and (ii) a vector of the names of each time step ex. minus_30,minus_20,...,plus_20, plus_30.

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"
D <- 750
t_s <- 20
t_ss <- 10

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

peak_temporal_list <- get_relative_values(
  psa_data,
  peak_values_list,
  t_s = t_s,
  t_ss = t_ss
)

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