The real and synthetic records are stacked and a logistic regression
(main effects; categorical variables as dummies, missing values as
indicators) predicts membership of the synthetic set. The propensity
score mean-squared error
$$pMSE = \frac{1}{N}\sum_i (\hat p_i - c)^2,\quad c = n_{syn}/N$$
is 0 when the two sets are indistinguishable. pmse_ratio divides it by
its expectation under the null hypothesis that both sets come from the
same distribution, \((k-1)(1-c)^2 c / N\) with \(k\) model
parameters; values near 1 indicate high utility.
pmse(
real,
synthetic,
vars = NULL,
max_rows = 10000L,
seed = NULL,
model = c("linear", "quadratic")
)A list with pmse, pmse_null, pmse_ratio and n_params.
Data frames with common columns.
Optional subset of variables.
Each data set is subsampled to at most this many rows.
Optional random seed (subsampling).
Propensity model: "linear" (main effects, default) or
"quadratic".
With model = "quadratic", squares and pairwise products of the numeric
variables are added to the logistic model (as recommended by Snoke et
al. for detecting differences in the dependence structure).
Snoke, J., Raab, G. M., Nowok, B., Dibben, C. and Slavkovic, A. (2018). General and specific utility measures for synthetic data. Journal of the Royal Statistical Society A, 181(3), 663--688. tools:::Rd_expr_doi("10.1111/rssa.12358")
syn <- synthesize(iris, seed = 1)
pmse(iris, syn)
Run the code above in your browser using DataLab