Skip to contents

Adjusts reference counts so they match target data counts for each zone or PUMA. Use when reference and target data must be aligned for weighting.

Usage

adjust_reference_to_target(ref_counts, targets, settings)

Arguments

ref_counts

data.table with required columns:

  • client_zone_id <character/integer> — zone or PUMA identifier

  • ref_count_hh — household reference count

  • ref_count_per — person reference count

  • bg_geoid — block group GEOID

  • area_prop — proportion of block group area in zone Rows: one per zone. Keys: (client_zone_id). Modified by reference: no (returns copy).

targets

data.table with required columns:

  • client_zone_id <character/integer> — zone or PUMA identifier

  • p_total — target total persons

  • h_total — target total households Rows: one per zone. Keys: (client_zone_id). Modified by reference: no (returns copy).

settings

list. Must include:

  • weight_dow_groups

Value

data.table with adjusted weights. Same schema as input.

Details

  • Computes allocation factors for each zone using target and reference counts.

  • Adjusts household and person reference counts as needed.

  • Verifies adjusted totals match target counts; errors if not.

  • Handles missing or zero-population zones robustly.

  • Returns a copy; does not modify by reference.

See also

#' adjust_pums_to_reference

Examples

## Not run:
# ref_counts <- ... # sample plan ACS counts
# targets <- ... # target data
# settings <- ... # pipeline settings
# adjusted <- adjust_reference_to_target(
#   ref_counts, targets, settings
# )
## End(Not run)