Skip to contents

Collects the fine-grained knobs for the sequential synthesis engine. Strong defaults mean beginners can ignore this; power users can tune the utility / privacy / speed trade-off. Returns a validated synth_control object consumed by synth() and synth_linked().

Usage

synth_control(
  visit_sequence = NULL,
  predictor_matrix = NULL,
  method = NULL,
  smoothing = NULL,
  proper = FALSE,
  count_model = c("marginal", "conditional"),
  k = NULL,
  cart = list(),
  forest = list(),
  constraint_max_tries = 50L,
  temporal = temporal_control(),
  parallel = FALSE
)

Arguments

visit_sequence

Optional character vector giving the order in which variables are synthesised. NULL uses the natural (left-to-right) order.

predictor_matrix

Optional 0/1 matrix marking, for each variable, which variables may predict it (including cross-table predictors). NULL lets the engine derive a sensible default.

method

Optional per-variable method override; a single string applies globally. NULL uses the call-level method.

smoothing

Numeric-variable kernel smoothing. NULL (default) is auto: smooth numeric variables that look continuous (more than 20 distinct values), so their draws are not confined to the observed values – improving marginal realism and reducing exact-value replication. TRUE / "density" smooths every numeric variable; FALSE / "none" disables smoothing; a character vector smooths exactly the named variables. Auto resolution applies to single-table synth(); synth_linked() children are unsmoothed unless named explicitly.

proper

Logical; use proper (TRUE) vs improper (FALSE) synthesis.

count_model

How the number of rows per unit is drawn for nested / longitudinal data. "marginal" (default) resamples the observed unit sizes independently of any covariate. "conditional" synthesises the subject-level covariates first and draws each unit's size from a CART model of size on those covariates, so a dependence such as "sicker patients have more visits" is preserved. Only takes effect when the structure is nested and there are subject-level covariates; ignored for flat single-row-per-unit data.

k

Optional size of each synthetic dataset. NULL matches the input.

cart, forest

Named lists of hyperparameters passed to the CART / random forest backends. For forest, ntree (number of trees, default 10) and mtry (predictors tried per tree, default all) are recognised.

constraint_max_tries

Integer; how many times synth() may regenerate while rejection-sampling to satisfy constraints. Defaults to 50.

temporal

A temporal_control() object (or "auto", "codec_only", "off") governing native Date, POSIXct, POSIXlt, difftime, and hms synthesis. Defaults to temporal_control().

parallel

Controls parallel generation of the m synthetic replicates. FALSE (default) synthesises serially. TRUE uses all available workers (getOption("mc.cores"), else parallel::detectCores()); a positive integer sets an explicit worker count. Parallelism spreads the independent replicates over a cluster, so it only helps when m > 1. A parallel run is reproducible for a fixed (seed, worker count) via independent L'Ecuyer RNG streams, but its output differs from a serial run with the same seed.

Value

An object of class synth_control (a validated list).

Examples

ctrl <- synth_control(proper = TRUE, cart = list(minbucket = 5))
ctrl
#> <synth_control>
#>   proper           : TRUE 
#>   count_model      : marginal 
#>   k                : match input 
#>   method           : call-level 
#>   smoothing        : none 
#>   predictor_matrix : default 
#>   cart params      : 1 
#>   forest params    : 0 
#>   constraint tries : 50 
#>   parallel         : serial