Calculate person weights from household weights
calc_person_weights.RdCalculates person weights from household weights, adjusting for unrelated persons if specified. Use to generate person-level weights for weighting pipeline.
Arguments
- hh_weights
data.table with required columns:
hh_idday_groupn_complete_hh_dayshh_weightRows: one per household-day group. Keys: ( hh_id,day_group). Modified by reference: no (returns copy).
- households
data.table. Household-level variables.
- persons
data.table with required columns:
hh_idperson_idRows: one per person. Keys: ( hh_id,person_id). Modified by reference: no (returns copy).
- value_labels
data.table. Value labels for categorical variables.
- settings
list. Must include:
unrelated_adjustment— adjustment method study_unit— study unit type
Value
data.table with columns:
hh_idperson_idday_groupperson_weightRows: one per person-day group. Keys: ( hh_id,person_id,day_group).
Details
Merges household weights with persons table.
Drops nonstudy_day records if weighted record exists.
Adjusts for unrelated persons if specified in settings.
Checks consistency between household and person weights.
Returns a copy; does not modify by reference.
Settings
unrelated_adjustment (direct): Adjustment method for unrelated persons. Default from settings.
study_unit (direct): Study unit type. Default from settings.
See also
adjust_unrelated_per_wtsscripts/weighting/person_weights.R
Other weighting pipeline:
aggregate_targets(),
calc_day_weights(),
calc_linked_trip_weights(),
calc_sample_plan_counts(),
calc_tour_weights(),
calc_trip_weights(),
create_ie_adjustment_data(),
create_target_update_table(),
format_income_bins(),
get_day_groups(),
get_income_broad(),
get_income_broad_xwalk(),
prepare_zone_groups(),
update_daypat_seed(),
update_daypat_targets(),
update_income_broad_labels(),
update_rate_report(),
update_targets()
Examples
## Not run:
hh_weights <- data.table(hh_id = 1, day_group = "weekday", n_complete_hh_days = 5, hh_weight = 1.2)
households <- data.table()
persons <- data.table(hh_id = 1, person_id = 1)
value_labels <- data.table()
settings <- list(unrelated_adjustment = "person", study_unit = "household")
calc_person_weights(hh_weights, households, persons, value_labels, settings)
#> Error in colnamesInt(i, unname(on), check_dups = FALSE): argument specifying columns received non-existing column(s): cols[1]='hh_id'
## End(Not run)