Skip to contents

Create Sobol sampling matrices using sensobol::sobol_matrices() and an mctable definition. The function generates quasi-random draws in [0, 1] and then maps them to the target distributions defined in mctable$mc_func (or mctable$func) and mctable$sample_space.

Usage

mctable_sobol_matrices(
  mctable = set_mctable(),
  N,
  matrices = c("A", "B", "AB"),
  order = c("first", "second", "third", "fourth"),
  type = c("QRN", "LHS", "R"),
  mc_names = NULL,
  transformation = TRUE,
  drop_constant = TRUE,
  ...
)

Arguments

mctable

(data frame). Table containing at least mcnode and sample_space; may also contain mc_func / func and transformation.

N

(integer). Base sample size (see sensobol::sobol_matrices()).

matrices

(character). Which Sobol matrices to create (see sensobol::sobol_matrices()). Default: c("A", "B", "AB").

order

(character). Either "first", "second", "third", or "fourth" (see sensobol::sobol_matrices()).

type

(character). Sampling design used by sensobol::sobol_matrices(). In sensobol 1.1.6, options include "QRN" (default), "LHS", and "R".

mc_names

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

transformation

(logical). Whether to apply mctable$transformation rules after mapping, so values are on the same scale as the bounds returned by mctable_bounds(). Required for categorical sample_space. Default: TRUE.

drop_constant

(logical). If TRUE, exclude nodes that take a single value before building the matrices. Dropped node names are stored in attr(X, "dropped"). Default: TRUE.

...

Additional arguments passed to sensobol::sobol_matrices() (and potentially to randtoolbox::sobol() when type = "QRN").

Value

A numeric matrix where each column is a model input after mapping to the distributions defined in the mctable (and transformation, if applied), and each row is a sampling point. The matrix has the same layout/row binding as sensobol::sobol_matrices(). Attribute "dropped" contains the names of nodes removed by drop_constant.

Details

If the distribution function is missing but numeric bounds are available in sample_space (e.g. min = 0, max = 1 or c(0, 1)), the function assumes a uniform distribution (stats::runif). Supported distribution functions are runif, rnorm (mean, sd) and rpert (min, mode, max, optional shape), also when namespace-qualified (e.g. mc2d::rpert). Categorical sample_space vectors (e.g. c('always', 'sometimes', 'never')) are supported when a numeric transformation is provided. A single numeric value (e.g. 1, c(1), c('1') or value = 1) defines a constant input (min = max), which is dropped when drop_constant = TRUE.