Generate correlated design replicates for a set of groups
sb_resample_groups(
X_norm,
groups,
B = 100,
jitter = 1e-06,
seed = NULL,
use.parallel = FALSE,
cache = NULL
)An object of class sb_resamples, i.e. a list of length B whose
elements are resampled design matrices. The object exposes per-group
diagnostics in its "diagnostics" attribute and returns the cache via the
"cache" attribute for reuse.
Normalised design matrix.
Correlation structure. Either a list as returned by
sb_group_variables() or a vector of group labels matching the columns of
X_norm.
Number of replicates to generate.
Numeric value added to covariance diagonals for stability.
Optional integer seed for reproducibility. The seed is scoped via
withr::with_seed() so the caller's RNG state is restored on exit.
Logical; when TRUE, compute the resampled designs using
a parallel backend when available.
Optional environment or named list used to cache previously generated surrogates. Passing the same cache across calls reuses draws for identical groups.
When every group has size one (no correlated variables) the function
simply returns B copies of X_norm. A warning is issued in that situation
so downstream code can avoid mistaking the replicated designs for genuinely
resampled surrogates. The covariance matrices underpinning each correlated
draw are cached in the supplied cache environment; reusing the environment
across calls lets sb_resample_groups() skip redundant covariance
decompositions for identical groups and speeds up iterative workflows.