Learn R Programming

SynthesizerPlus (version 0.4.0)

simulate.sp_synthesizer: Simulate several synthetic data sets

Description

Draws nsim independent synthetic data sets from a fitted model, for example to account for synthesis uncertainty with multiple synthetic data sets (Raghunathan, Reiter and Rubin, 2003).

Usage

# S3 method for sp_synthesizer
simulate(object, nsim = 1, seed = NULL, ...)

# S3 method for sp_ts_synthesizer simulate(object, nsim = 1, seed = NULL, ...)

Value

A list of nsim synthetic data sets.

Arguments

object

A fitted sp_synthesizer or sp_ts_synthesizer.

nsim

Number of synthetic data sets.

seed

Optional random seed.

...

Passed to generate(), e.g. n.

References

Raghunathan, T. E., Reiter, J. P. and Rubin, D. B. (2003). Multiple imputation for statistical disclosure limitation. Journal of Official Statistics, 19(1), 1--16.

Examples

Run this code
fit <- fit_synthesizer(mtcars)
sims <- simulate(fit, nsim = 3, seed = 1)
vapply(sims, function(d) mean(d$mpg), numeric(1))

Run the code above in your browser using DataLab