Prepare household-level data for income imputation
prep_hhs_for_income_imputation.RdCleans and formats household data for income imputation, ensuring income bins are properly labeled and missing responses are handled. Use to generate model-ready household data for imputation and reporting.
Arguments
- households
data.table. Household records to impute. Required columns:
hh_id— household identifier income_broad<integer/character> — income binincome_broad_label— income bin label residence_rent_own<integer/character> — rent/own coderesidence_type<integer/character> — residence type codenum_people— household size Rows: one per household. Keys: ( hh_id). Modified by reference: no (returns copy).
- value_labels
data.table. Value labels for variables. Required columns:
variable— variable name label— value label value<integer/character> — coded value
Value
data.table. Household-level data for imputation. Columns:
hh_id— household identifier income_imputed_pnta<integer/numeric> — imputed income binincome_imputed_pnta_label— imputed income label Additional columns for home ownership and residence type flags. Rows: one per household. Keys: (
hh_id).
Details
Assumes
income_broadis a factor with labels for income levels, combiningincome_detailedandincome_followup.If missing, creates
income_broad_factorfromincome_broad_label.Updates income bin labels using value_labels if not already a factor.
Handles missing or "Prefer Not to Answer" values by returning imputed columns or prepping for imputation.
Adds home ownership and single-family home flags using value_labels and regex matching.
Returns a data.table with household ID, imputed income, and label columns.
Assumes value_labels are current and complete; errors if factor levels or labels are missing.
See also
impute_income_pnta, prepare_acs_income
Other imputation utilities:
calculate_acs_proportions(),
get_acs_ethnicity(),
get_acs_race(),
get_hh_person_sums(),
impute_ethnicity(),
impute_gender(),
impute_income_nonrelatives(),
impute_income_pnta(),
impute_race(),
make_binary(),
prepare_acs_income(),
prepare_ethnicity_labels(),
prepare_ethnicity_survey_data(),
prepare_impute_targets(),
prepare_income_fit_dt(),
prepare_persons_dt(),
update_hh_income_imputed()