Skip to contents

generate_mock_data_simstudy() consumes a validated mock_spec and generates baseline valid values through the optional simstudy package for supported uniform continuous and categorical variables. MockData remains responsible for missing-code injection, garbage values, and diagnostics through postprocess_mock_data().

Usage

generate_mock_data_simstudy(spec, n, seed = NULL)

Arguments

spec

A mock_spec object.

n

Non-negative whole number of rows to generate.

seed

Optional whole-number seed. Generation uses an isolated L'Ecuyer-CMRG sub-stream and restores the caller's RNG state and kind on exit, so output is reproducible for a given seed and package version without perturbing the caller's RNG.

Value

A data frame with n rows and one column per non-formula mock_spec variable (type = "formula" variables are appended afterwards by evaluate_mock_formulas()).

Details

Variables that need MockData semantics not covered by this milestone, such as truncated normal ranges and calendar dates, are generated by MockData's native path inside the same seeded call.

simstudy is an optional Suggests dependency and is GPL-3 licensed; MockData remains MIT licensed by keeping this backend soft-gated and by retaining generate_mock_data_native() as the default engine. Use this backend when simstudy is installed and you want to exercise the optional engine path. It currently delegates only categorical and uniform continuous baseline generation to simstudy; unsupported variables are routed through MockData's native backend so that a single specification can mix capabilities.

Missing-code assignment, garbage values, and diagnostics are not delegated to simstudy. They remain MockData-owned post-processing so both backends share the same auditability contract.

Like generate_mock_data_native(), this backend skips type = "formula" variables — they carry no distribution to sample from. They are computed post-baseline by evaluate_mock_formulas(), which works over either backend's output.

Examples

spec <- mock_continuous("age", range = c(18, 85), rtype = "integer")
if (requireNamespace("simstudy", quietly = TRUE)) {
  data <- generate_mock_data_simstudy(spec, n = 10, seed = 1)
  head(data)
}
#>   age
#> 1  63
#> 2  47
#> 3  79
#> 4  82
#> 5  74
#> 6  41