Skip to contents

Extract the bounds required by sensitivity::morris() and other sampling design functions from an mctable.

Usage

mctable_bounds(
  mctable = set_mctable(),
  mc_names = NULL,
  if_not_sampled = c("exclude", "median", "mean", "max", "min"),
  transformation = TRUE,
  n_probe = 1000,
  drop_constant = TRUE
)

Arguments

mctable

(data frame). Table containing at least mcnode and sample_space; may also contain transformation and mc_func (used to probe transformations). sample_space bounds can be given as min = X, max = Y or c(X, Y); a single numeric value (e.g. 1, c(1) or value = 1) is treated as min = max. Default: set_mctable().

mc_names

(character vector, optional). Node names to include. If NULL, all nodes in mctable$mcnode are used.

if_not_sampled

(character). How to handle nodes not listed in mc_names (and nodes with missing or empty sample_space): "exclude", "median", "mean", "max", or "min". Default: "exclude".

transformation

(logical). Whether to apply transformation rules. Default: TRUE.

n_probe

(integer). Number of grid points used to probe the transformed range when transformation = TRUE. Probes are an evenly spaced grid of probabilities in [0, 1] mapped through the distribution defined by sample_space and mc_func (uniform, rnorm, rpert or categorical), so results are reproducible and do not affect the random number stream. Default: 1000.

drop_constant

(logical). If TRUE, drop factors whose lower and upper bounds are equal (after any transformation). Dropped factors are listed in dropped and, when if_not_sampled != "exclude", added to fixed with their constant value. Dropped inputs are created as fixed nodes by eval_module() and trial_totals() when missing from sample_design. Default: TRUE.

Value

A list bounds with:

  • binf numeric vector of lower bounds (same order as factors).

  • bsup numeric vector of upper bounds (same order as factors).

  • factors character vector of factor names.

  • fixed named numeric vector with fixed values for non-sampled factors when if_not_sampled != "exclude".

  • dropped character vector of factors removed by drop_constant.

Details

Supports sampling only a subset of nodes via mc_names and controls how non-sampled nodes are handled via if_not_sampled. If transformation is enabled and mctable includes a transformation column, the function computes bounds on the transformed values.