generate() draws synthetic records from a fitted model such as an
sp_synthesizer (see fit_synthesizer()) or an sp_ts_synthesizer (see
fit_synthesizer.ts()).
generate(object, ...)# S3 method for sp_synthesizer
generate(
object,
n = object$n_train,
seed = NULL,
dependence = 1,
closeness = 1,
perturb = NULL,
stratum_sizes = c("multinomial", "proportional"),
...
)
# S3 method for sp_ts_synthesizer
generate(object, n = object$n_train, seed = NULL, start = object$start, ...)
Synthetic data of the same type as the training data: a data
frame, matrix, vector or ts object.
A fitted model.
Further arguments passed to methods.
Number of records (rows) to generate. Defaults to the number of rows in the training data.
Optional random seed. The global random number generator state is restored afterwards.
Number in [0, 1] scaling the strength of the dependence between variables: 1 (default) reproduces the fitted copula, 0 generates independent columns. Intermediate values shrink the copula correlation matrix towards the identity; the marginal distributions are unaffected.
Number in [0, 1] controlling how close the synthetic
data are to the real data: 1 (default) reproduces the fitted model as
closely as possible; smaller values move records away from the real
ones (noise on continuous variables, random re-drawing of categories) and
loosen the distributions (flatter category probabilities, weaker
dependence). With closeness = 0 the variables are independent and
strongly smoothed. See perturbation() for the exact mapping and
calibrate_closeness() to choose a value that reaches a target distance.
Optional perturbation() for fine control: record-level
noise and swapping, and distribution-level shifts, spread, category
temperature and dependence strength. Combined with closeness and
dependence.
For stratified models: "multinomial" (default;
random stratum sizes) or "proportional" (deterministic sizes
proportional to the training data).
Start time of the generated series (default: the start of the training series).
For a fit with nonlinear_target or nominal_target, that one response is
generated from its conditional model given the copula-generated
predictors, rather than directly from the fitted copula. The fitted copula
correlation is therefore a baseline model, not necessarily the final
synthetic joint dependence. The missingness of the response still follows
the copula. Non-default dependence, closeness and perturb are not
supported for such fits.
fit_synthesizer(), synthesize(), generate_to_file()
fit <- fit_synthesizer(mtcars)
generate(fit, n = 5, seed = 42)
# weaker dependence
syn <- generate(fit, n = 500, dependence = 0.5, seed = 1)
Run the code above in your browser using DataLab