Skip to contents

Automates PopulationSim runs across combinations of max_expansion_factor and absolute_upper_bound (grid search), saving household weights and computing diagnostics for each scenario. Use to optimize PopulationSim parameters for synthetic population weighting.

Usage

popsim_search(
  run_label,
  settings,
  exp_factors = NULL,
  bounds = NULL,
  save = TRUE
)

Source

PopulationSim grid search and diagnostics logic.

Arguments

run_label

character(1). Label used to locate working directories and configuration files.

settings

list. Global project settings; must include working_dir (character).

exp_factors

numeric vector. Expansion factors to test (for grid search).

bounds

numeric vector. Absolute upper bounds to test (for grid search).

save

logical(1). If TRUE, saves results to disk. Default TRUE.

Value

list. Contains:

  • weights_df — merged weights across runs (data.table)

  • stats_df — diagnostic statistics for each combo (data.table) Returns invisible() if results are up to date.

Details

  • Copies working directory and configuration files for each grid search combo.

  • Iterates over all combinations of expansion factors and bounds.

  • For each combo:

    • Updates settings.yaml with current parameters.

    • Runs PopulationSim and saves output weights.

    • Merges results into a single weights data.table.

    • Computes diagnostics (MAPE, CV, ESS, percent capped, etc.).

  • Skips rerun if results are up to date.

  • Assumes settings include working_dir and valid PopulationSim configuration.

  • Error handling: messages for failed runs, skips if results are current.

Settings

  • working_dir (direct): output directory for PopulationSim files.

  • max_expansion_factor (direct): tested in grid search.

  • absolute_upper_bound (direct): tested in grid search.

See also

Examples

## Not run:
popsim_search('run1', settings, exp_factors = c(3, 5), bounds = c(1000, 2000))
#> Error: object 'settings' not found
## End(Not run)