Skip to contents

Reports how faithfully a synthetic cohort reproduces its seed, per variable, so a replica can be judged before it is released. Categorical columns are compared by total variation distance between their proportion tables; numeric columns by standardised difference in means and by the Kolmogorov-Smirnov statistic.

Usage

sdt_synthesis_utility(original, synthetic)

Arguments

original

The real seed cohort.

synthetic

A replica, e.g. from sdt_synthesise().

Value

A tibble::tibble() with one row per shared column and statistic: variable, type, statistic, value, and flag, which is TRUE where the divergence exceeds a conventional 0.1 and the column deserves a look. Returns a 0-row tibble of the same shape when nothing is shared.

Examples

seed_cohort <- sdt_synthetic_cohort(n = 80, seed = 1)
replica <- sdt_synthetic_cohort(n = 80, seed = 2)
sdt_synthesis_utility(seed_cohort, replica)
#> # A tibble: 9 × 5
#>   variable      type        statistic        value flag 
#>   <chr>         <chr>       <chr>            <dbl> <lgl>
#> 1 age           numeric     std_mean_diff   0.0262 FALSE
#> 2 age           numeric     ks              0.15   TRUE 
#> 3 sex           categorical total_variation 0.0875 FALSE
#> 4 life_points   numeric     std_mean_diff   0.183  TRUE 
#> 5 life_points   numeric     ks              0.0875 FALSE
#> 6 ventilated    categorical total_variation 0.0125 FALSE
#> 7 injury_region categorical total_variation 0.1    TRUE 
#> 8 triage        categorical total_variation 0.0625 FALSE
#> 9 therapy       categorical total_variation 0.05   FALSE