
Validate the Fit of a Synthetic Population
Source:R/fn_validate.R
validate_synthetic_population_fit.RdCompares a synthetic population against an expected contingency table and evaluates goodness-of-fit.
Usage
validate_synthetic_population_fit(
synthetic_population,
expected,
dimensions,
name,
threshold_1L_dbl = 0.05
)Arguments
- synthetic_population
A synthetic population stored as a data.frame or data.table.
- expected
Reference contingency table containing the expected distribution.
- dimensions
Character vector identifying the variables used to construct the comparison contingency table.
- name
Character string used in validation messages and warning output.
- threshold_1L_dbl
Numeric significance threshold used when generating validation warnings.
Details
The function:
Converts the synthetic population into a contingency table using
synthetic_population_to_contingency.Aligns the observed and expected distributions.
Calculates goodness-of-fit statistics using
calculate_z_squared_score.Emits a warning if the p-value is below 0.05.
Examples
if (FALSE) { # \dontrun{
validate_synthetic_population_fit(
synthetic_population,
expected,
dimensions = c(
"gender",
"education"
),
name = "Education"
)
} # }