Skip to contents

Loads and processes ACS household income data, aligning block group income distributions to survey bins for use in imputation models. Use to generate block group-level income fractions for model fitting and prediction.

Usage

prepare_acs_income(hhs, survey_upper, settings)

Arguments

hhs

data.table. Household records with block group GEOID. Required columns:

  • bg_geoid — block group GEOID Rows: one per household. Keys: (bg_geoid). Modified by reference: no (returns copy).

survey_upper

numeric vector. Upper bounds for survey income bins (must match ACS labels).

settings

list. Settings object with ACS configs. Required keys:

  • acs_tables[['hh_income']] — ACS table name

  • acs_year — ACS year

Value

data.table. Block group-level ACS income fractions. Columns:

  • bg_geoid — block group GEOID

  • f_* — fraction of households in each income bin (e.g., f_0_24999) Rows: one per block group. Keys: (bg_geoid).

Details

  • Fetches ACS household income data using settings (table and year).

  • Relabels ACS income bins to match survey upper bounds using regex and value_labels.

  • Tabulates block group counts and converts to fractions for each income bin.

  • Fills zero fractions to avoid rank deficiency in modeling.

  • Returns a data.table with block group GEOID and income fraction columns (e.g., f_0_24999).

  • Assumes ACS data is available and settings are correct; errors if required columns are missing.

Settings

  • acs_tables[['hh_income']] (direct): ACS table for household income. Default from settings.

  • acs_year (direct): ACS year. Default from settings.

Examples

## Not run:
prepare_acs_income(hhs, survey_upper, settings)
#> Error in prepare_acs_income(hhs, survey_upper, settings): could not find function "prepare_acs_income"
## End(Not run)