Skip to contents

Updates household income by adding imputed nonrelative income, recalculating bounds, and re-binning into income categories using crosswalks and overlap logic. Use to produce final household income labels for analysis and reporting.

Usage

update_hh_income_imputed(hh_income_pnta, persons_nr, value_labels)

Arguments

hh_income_pnta

data.table. Household income table. Required columns:

  • hh_id — household identifier

  • income_imputed_pnta — imputed income from pnta

  • income_imputed_pnta_label — income label Rows: one per household. Keys: (hh_id). Modified by reference: no (returns copy).

persons_nr

data.table. Person-level data with imputed nonrelative income. Required columns:

  • hh_id — household identifier

  • nonrelative_income — imputed nonrelative income

value_labels

data.table. Value labels for variables. Required columns:

  • variable — variable name

  • label — value label

  • value <integer/character> — coded value

Value

data.table. Updated household income. Columns:

  • hh_id — household identifier

  • income_imputed <integer/numeric> — final imputed income bin

  • income_imputed_label — final income label Rows: one per household. Keys: (hh_id).

Details

  • Copies input household income table to avoid reference modification.

  • Uses get_income_bounds to compute lower and upper bounds for each income label.

  • Adds imputed nonrelative income to household bounds.

  • Uses get_income_broad_xwalk and find_income_overlaps to re-bin revised income ranges into broad income categories:

    • Crosswalks income bins using value_labels and settings.

    • Finds overlapping bins and assigns followup labels based on maximum overlap.

  • Joins bin labels back to household income and drops intermediate columns.

  • Returns a data.table with hh_id, final imputed income, and label.

  • Assumes value_labels and crosswalks are current; errors if binning fails or overlaps are ambiguous.

Dependencies

  • get_income_bounds: computes lower/upper bounds for income labels

  • get_income_broad_xwalk: crosswalks income bins to broad categories

  • find_income_overlaps: assigns bin labels based on overlap

Examples

## Not run:
update_hh_income_imputed(hh_income_pnta, persons_nr, value_labels)
#> Error in update_hh_income_imputed(hh_income_pnta, persons_nr, value_labels): could not find function "update_hh_income_imputed"
## End(Not run)