Skip to contents

Adjusts household weights (WGTP) in PUMS data so that each household's WGTP matches the mean person weight (PWGTP) for that household. Use to ensure household and person weights are consistent for expansion and reporting.

Usage

force_balance_pums_weights(pums)

Arguments

pums

data.table. PUMS data with required columns:

  • SERIALNO <character/integer> — household ID

  • SPORDER — person order in household

  • NP — household size

  • WGTP — household weight

  • PWGTP — person weight Rows: one per person. Keys: (SERIALNO, SPORDER). Modified by reference: no (returns copy).

Value

data.table. PUMS data with WGTP pegged to mean PWGTP for each household. Same schema as input.

Details

  • Calculates mean person weight (PWGTP) for each household (SERIALNO).

  • Sets household weight (WGTP) to this mean for all records in the household.

  • Checks for weight skew after adjustment using check_weight_skew().

  • Returns a copy; does not modify by reference.

Settings

None.

Examples

## Not run:
pums <- data.table(SERIALNO = 1, SPORDER = 1, NP = 2, WGTP = 100, PWGTP = 50)
force_balance_pums_weights(pums)
#> Recalculating WGTP
#> Skew between HH/PER weights after pegging HH weights to person weights: -100% -- sum(NP*WGTP): 100, sum(PWGTP): 50
#> Index: <SPORDER>
#>    SERIALNO SPORDER    NP  WGTP PWGTP
#>       <num>   <num> <num> <num> <num>
#> 1:        1       1     2    50    50
## End(Not run)