Calculate initial survey weights
calc_initial_weights.RdCalculates 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.
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
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.
See also
calc_uwe(), calc_alpha(), blend_initial_weights()
scripts/040_initial_expansion.R
Other weighting adjustment:
adjust_pums_to_reference(),
adjust_ref_counts_dataset(),
adjust_target_to_study_zones(),
adjust_unrelated_per_wts(),
adjust_unrelated_pums(),
blend_initial_weights(),
calc_alpha(),
calc_uwe(),
force_balance_pums_weights()
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)