Skip to contents

Fit the same analysis on the real data and on the synthetic data and compare the estimates. This is the analysis-specific utility measure – "does my regression come out the same?" – complementing the general marginal / pMSE diagnostics of diagnose(). For each term it reports the confidence-interval overlap (Karr et al. 2006; 1 = identical intervals, 0 = just touching, negative = disjoint) and the standardised difference of the estimates on the real standard-error scale (smaller is better).

Usage

compare_estimates(
  real,
  syn,
  analysis,
  rule = c("synthpop", "reiter"),
  population_inference = TRUE,
  conf.level = 0.95,
  ...
)

Arguments

real

The real data.frame (or named list of tables for linked data).

syn

A synth_result or synth_linked_result (pooled), or a single synthetic data.frame / table list.

analysis

A function of one data.frame returning a fitted model (coef()/vcov()) or a list(estimate =, variance =).

rule, population_inference

Passed to pool_synth() when syn is a multi-dataset result.

conf.level

Confidence level for both intervals (default 0.95).

...

Reserved.

Value

A flexsynth_utility object; $estimates has term, est_real, est_syn, overlap, std_diff, and both intervals.

Details

When syn is a multi-dataset synth() result its estimates are pooled with pool_synth() (so the synthetic standard errors reflect synthesis); a single synthetic data.frame is analysed directly. analysis uses the same contract as pool_synth().

Examples

d <- data.frame(id = 1:500, x = rnorm(500))
d$y <- 1 + 2 * d$x + rnorm(500)
res <- synth(d, ~ id, m = 5, seed = 1)
compare_estimates(d, res, function(dat) lm(y ~ x, dat))
#> <flexsynth_utility> real-vs-synthetic estimate comparison (synthetic pooled) 
#>   CI overlap (1 = identical, <0 = disjoint) at 95%; std_diff = |est_real - est_syn| / se_real
#>         term est_real est_syn overlap std_diff
#>  (Intercept)   0.9507  0.9502   0.894    0.011
#>            x   1.9774  1.9521   0.891    0.538
#>   mean overlap: 0.892