Quantifies how faithfully synthetic data reproduces the real data's
distributions and dependence structure. Because Track A output carries no
formal privacy guarantee, these utility diagnostics (and the risk
diagnostics in disclosure_risk()) are how synthesis quality is judged.
Arguments
- real
The real
data.frame(or a named list of them for linked data).- syn
The synthetic data: a
data.frame, asynth()synth_result, a named list of tables, or asynth_linked()synth_linked_result.- vars
Optional character vector restricting the variables compared; defaults to all columns present in both.
- propensity
Propensity model for the pMSE,
"logistic"(default) or"cart"(needs therpartpackage).- ...
Unused.
Value
A flexsynth_diagnostics object (or a flexsynth_diagnostics_list
for linked / list input). Has print() and plot() methods.
Details
Four views are reported:
Univariate – per-variable marginal fit: a Kolmogorov-Smirnov statistic for numeric variables and a total-variation distance for categorical ones (both in \([0, 1]\); smaller is better).
Correlation – the Frobenius and mean absolute difference between the real and synthetic numeric correlation matrices.
Association – the mean and maximum absolute difference between the real and synthetic categorical association (Cramer's V) matrices, so dependence between factor variables is checked, not just numeric ones.
Propensity (pMSE) – a descriptive utility score: a model is fitted to tell real from synthetic records; when they are indistinguishable the propensity mean squared error sits near its null expectation, so the logistic model's
ratiois near 1 (larger means more distinguishable). This is an in-sample, row-level diagnostic: the default logistic model has main effects only, and repeated rows in longitudinal data are not treated as independent inferential evidence. CART does not have an analytic null ratio. Treat all results as descriptive rather than hypothesis tests.
If real and syn are named lists (or syn is a synth_linked_result),
each table is diagnosed and a per-table result is returned.
See also
disclosure_risk() for privacy risk.
Examples
df <- data.frame(
id = 1:200,
age = round(rnorm(200, 60, 10)),
sbp = round(rnorm(200, 130, 15))
)
res <- synth(df, ~ id, seed = 1)
diagnose(df, res)
#> <flexsynth_diagnostics>
#> rows : real 200 synthetic 200
#> variables : 3
#>
#> Univariate fit (smaller = closer):
#> variable type metric distance
#> id numeric ks 0.000
#> age numeric ks 0.075
#> sbp numeric ks 0.050
#> mean distance: 0.0417 worst: age (0.0750)
#>
#> Correlation structure (3 numeric vars):
#> Frobenius diff: 0.1784 mean |diff|: 0.0572 max |diff|: 0.1186
#>
#> Propensity utility (pMSE, logistic; descriptive, in-sample):
#> pMSE: 0.00010 expected: 0.00094 ratio: 0.11 (1 = indistinguishable)