Skip to contents

Calculates initial expansion weights for survey households or persons using block group reference counts and survey data. Use for first-stage weighting and sample blending in travel survey expansion workflows.

Usage

calc_initial_weights(sample_plan, seed, targets, settings, blend = TRUE)

Arguments

sample_plan

data.table with required columns:

  • segment_name — segment name

  • bg_geoid — block group GEOID

  • ref_count_per — reference person count

  • ref_count_hh — reference household count

  • client_zone_id — client zone identifier Rows: one per block group. Keys: (segment_name, bg_geoid). Modified by reference: no (returns copy).

seed

data.table with required columns:

  • segment_name — segment name

  • bg_geoid — block group GEOID

  • invitation — sample type (ABS/NPS)

  • day_group — day group label Rows: one per household/person. Keys: (segment_name, bg_geoid, invitation, day_group). Modified by reference: no (returns copy).

targets

data.table with required columns:

  • segment_name — segment name

  • h_total — total households (if household-level)

  • client_zone_id — client zone identifier Rows: one per segment. Keys: (segment_name, client_zone_id). Modified by reference: no (returns copy).

settings

list. Must include keys for unrelated_adjustment, study_unit, report_dir, and optionally nps_blending_factor.

blend

logical(1). If TRUE, blend NPS/ABS samples. Default: TRUE.

Value

data.table. Survey data with initial_weight column added. Same schema as input seed, plus initial_weight and alpha (if blended).

Details

  • Counts complete households by block group and segment.

  • Checks for segment/block group consistency and coverage.

  • Calculates expansion weights to match reference counts.

  • Supports blending of NPS/ABS samples if requested.

  • Adjusts for additional households if unrelated householders are restructured.

  • Returns a copy; does not modify by reference.

  • Writes summary report to CSV if report_dir is set in settings.

Settings

  • unrelated_adjustment : "restructure" or other. Controls household adjustment logic.

  • study_unit : "household" or "person". Determines weighting unit.

  • report_dir : Directory for summary CSV output. Optional.

  • nps_blending_factor : Optional, overrides calculated alpha for blending.

Examples

## Not run:
# sample_plan <- ... # block group reference counts
# seed <- ... # survey data
# targets <- ... # target counts
# settings <- list(unrelated_adjustment = "restructure", study_unit = "household", report_dir = "reports/")
# result <- calc_initial_weights(sample_plan, seed, targets, settings)
## End(Not run)