Calculate day weights for each person-day
calc_day_weights.RdCalculates day weights for each person in each household, adjusting for unrelated persons and incomplete days. Use to generate day-level weights for downstream weighting steps.
Arguments
- person_weights
data.table with required columns:
hh_idperson_idday_groupperson_weightRows: one per person-day group. Keys: ( hh_id,person_id,day_group). Modified by reference: no (returns copy).
- households
data.table. Household-level variables.
- persons
data.table. Person-level variables.
- days
data.table with required columns:
hh_idperson_idday_idday_grouptravel_downum_tripsis_completehh_day_completeRows: one per person-day. Keys: ( hh_id,person_id,day_id). Modified by reference: no (returns copy).
- trips
data.table. Trip-level variables.
- value_labels
data.table. Value labels for categorical variables.
- settings
list. Must include:
unrelated_adjustment— adjustment method weight_dow_groups— valid day-of-week groups
Value
data.table with columns:
hh_idperson_idday_idday_groupnum_tripsday_weightRows: one per person-day. Keys: ( hh_id,person_id,day_id).
Details
Adjusts person weights for unrelated persons if specified in settings.
Merges day, person, and household data to assign weights.
Sets weights to zero for non-study or incomplete days.
Checks consistency between person and day weights.
Returns a copy; does not modify by reference.
Settings
unrelated_adjustment (direct): Adjustment method for unrelated persons. Default from settings.
weight_dow_groups (direct): Valid day-of-week groups. Default from settings.
See also
adjust_unrelated_per_wtsscripts/weighting/day_weights.R
Other weighting pipeline:
aggregate_targets(),
calc_linked_trip_weights(),
calc_person_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:
person_weights <- data.table(
hh_id = 1,
person_id = 1,
day_group = "weekday",
person_weight = 1.2
)
households <- data.table()
persons <- data.table()
days <- data.table(
hh_id = 1,
person_id = 1,
day_id = 1,
day_group = "weekday",
travel_dow = "Mon",
num_trips = 2,
is_complete = 1,
hh_day_complete = 1
)
trips <- data.table()
value_labels <- data.table()
settings <- list(
unrelated_adjustment = "day",
weight_dow_groups = c("Mon", "Tue")
)
calc_day_weights(
person_weights,
households,
persons,
days,
trips,
value_labels,
settings
)
#> Setting non-surveyed person-day weights to 0 and adjusting up remaining person-day weights.
#> Error in .checkTypos(e, names_x): Object 'variable' not found amongst []
## End(Not run)