Creates an unevaluated {} expression that calls pick_val_v() with the
correct arguments for base case, PSA, DSA, and scenario analyses.
The expression is meant to be passed directly to run_sim() or
run_sim_parallel() as a *_inputs argument.
Usage
input_block(
.data = NULL,
base,
psa,
sens,
names_out,
psa_indicators = NULL,
sens_indicators = NULL,
indicator_sens_binary = FALSE,
dsa_names = NULL,
distributions = NULL,
covariances = NULL
)Arguments
- .data
Optional existing
{}block to prepend (for pipe chaining).- base
A list of base case values, one entry per parameter.
- psa
An unevaluated expression producing PSA draws (e.g.
pick_psa(...)), evaluated at runtime per simulation.- sens
The sensitivity data object (e.g.
l_inputs). At runtime the engine indexes it assens[[sens_name_used]]to pick the active column.- names_out
Character vector or list of strings of output parameter names.
- psa_indicators
List of 0/1 indicators controlling which parameters draw from PSA.
NULLmeans all parameters draw from PSA.- sens_indicators
List of indicators, one entry per parameter (may be a scalar or a vector for vector-valued parameters). In binary mode: 0 = inactive, 1 = active. In grouped mode: 0 = inactive, same integer = varied together.
NULLmeans all parameters are active. Only in grouped mode can subparameters (e.g., elements of a vector parameter) be varied at different steps of a DSA.- indicator_sens_binary
Logical.
TRUE= binary (0/1) mode; each active parameter is varied independently viacreate_indicators().FALSE(default) = grouped integer mode whensens_indicatorsanddistributionsare supplied; otherwise falls back to binary mode.- dsa_names
Character vector of
sensitivity_namesvalues that are DSA directions (e.g.c("DSA_min","DSA_max")). Those names iterate through active parameters/groups one at a time. All other names passed tosensitivty_namesinrun_sim()are treated as scenarios.NULL(the default) means all sensitivity names are scenarios.- distributions
List of distribution names (e.g.
"rnorm","mvrnorm","rdirichlet"), required in grouped mode to determine which parameters are vectors and require conditional distributions.- covariances
List of covariance matrices or scalars, required for
"mvrnorm"/"rdirichlet"distributions.
Value
A {} language object (same type as add_item()) with a
warden_block_meta attribute used by the engine to build the iteration
schedule.
Details
Supports two modes:
Binary (
indicator_sens_binary = TRUE):sens_indicatorsare 0/1 per parameter. Each non-zero parameter is varied independently viacreate_indicators().Grouped (
indicator_sens_binary = FALSE, the default whensens_indicatorsanddistributionsare supplied):sens_indicatorsare integer group labels. Parameters sharing the same integer are varied together; 0 means the parameter is never varied.
DSA vs scenario analyses
Supply dsa_names with the subset of sensitivity_names that correspond
to DSA directions (e.g. c("DSA_min","DSA_max")). Each DSA name runs one
iteration per active parameter/group; other names (scenarios) apply all
active parameters simultaneously in a single iteration.
When dsa_names = NULL (the default) every sensitivity name is treated as a
scenario — all active parameters take their scenario value at once, one
iteration per sensitivity_names entry. This is the correct default when
there is no DSA.
Examples
l_inputs <- list(
parameter_name = list("util.sick", "util.sicker"),
base_value = list(0.8, 0.5),
PSA_dist = list("rnorm", "rbeta_mse"),
a = list(0.8, 0.5),
b = list(0.04, 0.025),
n = list(1, 1),
DSA_min = list(0.6, 0.3),
DSA_max = list(0.9, 0.7),
psa_indicators = list(1, 1)
)
blk <- input_block(
base = l_inputs[["base_value"]],
psa = pick_psa(l_inputs[["PSA_dist"]], l_inputs[["n"]],
l_inputs[["a"]], l_inputs[["b"]]),
sens = l_inputs,
names_out = l_inputs[["parameter_name"]],
psa_indicators = l_inputs[["psa_indicators"]],
indicator_sens_binary = TRUE,
dsa_names = c("DSA_min", "DSA_max")
)
stopifnot(is.call(blk))
stopifnot(!is.null(attr(blk, "warden_block_meta")))
