Skip to contents

Retrieves pre-calculated confidence intervals for targets and survey data, calculates fit statistics, and prepares data for plotting and analysis.

Usage

calc_weight_fit(run_label, settings, day_group_agg = FALSE)

Arguments

run_label

character(1). Run label for output files.

settings

list. Must include:

  • outputs_dir — output directory

day_group_agg

logical. If TRUE, aggregates day groups to zone groups.

Value

list with two data.tables:

  • zone_group: fit statistics by zone group. Columns:

    • variable — variable name

    • day_group — day group label

    • target — target value

    • target_low — lower bound for target

    • target_upp — upper bound for target

    • survey — survey value

    • survey_low — lower bound for survey

    • survey_upp — upper bound for survey

    • abs_diff — absolute difference

    • pct_diff — percent difference

    • Additional columns as needed for reporting

  • region: fit statistics by region. Columns:

    • variable — variable name

    • day_group — day group label

    • target — target value

    • target_low — lower bound for target

    • target_upp — upper bound for target

    • survey — survey value

    • survey_low — lower bound for survey

    • survey_upp — upper bound for survey

    • abs_diff — absolute difference

    • pct_diff — percent difference

    • Additional columns as needed for reporting

Details

  • Reads target and survey confidence intervals from output files.

  • Joins by geography level and aggregates day groups if requested.

  • Calculates absolute and percent differences, error bars.

  • Checks for missing values and stops if found.

  • Returns a list of data.tables for zone group and region.

Settings

  • outputs_dir (direct): Output directory. Default from settings.

See also

  • calc_survey_ci

  • scripts/weighting/fit_analysis.R

Other survey analysis: calc_max_error(), calc_survey_ci()

Examples

## Not run:
run_label <- "test"
settings <- list(outputs_dir = "out")
calc_weight_fit(run_label, settings)
#> Error in get("weight_dow_groups", settings): object 'weight_dow_groups' not found
## End(Not run)