
Extract a Margin Distribution from a Synthetic Population
Source:R/fn_utils-extractors.R
get_margin_series_from_synthetic_population.RdCalculates a marginal distribution for one or more variables in a synthetic population.
Details
The resulting margin can be used for:
Validation.
Comparison with external data sources.
Iterative proportional fitting (IPF).
Diagnostic reporting.
The function aggregates the synthetic population over the supplied variables and counts the number of agents in each resulting category.
Unlike
synthetic_population_to_contingency,
this function is intended specifically for marginal
distributions rather than higher-dimensional contingency
tables.
Examples
population <- data.frame(
gender = c(
"Male",
"Male",
"Female"
)
)
get_margin_series_from_synthetic_population(
population,
"gender"
)
#> $gender
#> [1] 2 1
#>