Skip to contents

Calculates diagnostic statistics (MAPE, mean, SD, CV, ESS, percent capped, max error, dip statistic, top 1% share, etc.) for each PopulationSim run variant from a grid search result. Use to evaluate and compare weighting scenarios.

Usage

popsim_search_stats(run_label, settings)

Source

PopulationSim diagnostics and grid search logic.

Arguments

run_label

character(1). Identifier used to construct file paths for results.

settings

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

Value

data.table. One row per search combo with columns:

  • search_label — combo label (e.g., 'exp3_cap1000')

  • mape, mean, max, sd, cv, pct_capped, ess, max_error, max_error_var, dip_statistic, top_1pct_share, exp_factor, cap

Details

  • Loads weights, incidence, and target tables for each search combo.

  • For each combo:

    • Computes percent of population carried by top 1% of weights.

    • Calculates MAPE, mean, SD, CV, max, percent capped, effective sample size (ESS), dip statistic, and max error.

    • Uses helper functions calc_weight_mape and calc_max_error for diagnostics.

  • Splits search label into expansion factor and cap columns if grid search.

  • Returns a data.table with one row per combo and diagnostic columns.

  • Assumes settings include working_dir and valid PopulationSim output files.

  • Error handling: skips missing or failed runs; returns diagnostics for available combos.

Settings

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

See also

popsim_search, calc_weight_mape, calc_max_error

Other PopulationSim IO: popsim_make_control_config(), popsim_make_geoxwalk(), popsim_make_input_data(), popsim_make_settings(), popsim_make_weights(), popsim_search(), popsim_settings_updates()

Examples

## Not run:
stats_df <- popsim_search_stats('run1', settings)
#> Error: object 'settings' not found
## End(Not run)