Skip to contents

Assigns income bins from one table to another by maximizing overlap of bin bounds. Use for harmonizing income categories between survey and reference.

Usage

find_income_overlaps(
  income.x,
  income.y,
  suffix.x = ".x",
  suffix.y = ".y",
  id.vars.x = "income",
  id.vars.y = "income",
  low.var.x = "lower",
  low.var.y = "lower",
  up.var.x = "upper",
  up.var.y = "upper"
)

Arguments

income.x

data.table. Source bins with 'lower' and 'upper' columns.

income.y

data.table. Target bins with 'lower' and 'upper' columns.

suffix.x

character(1). Suffix for source columns (default '.x').

suffix.y

character(1). Suffix for target columns (default '.y').

id.vars.x

character(1). Source bin column name (default 'income').

id.vars.y

character(1). Target bin column name (default 'income').

low.var.x

character(1). Source lower bound column (default 'lower').

low.var.y

character(1). Target lower bound column (default 'lower').

up.var.x

character(1). Source upper bound column (default 'upper').

up.var.y

character(1). Target upper bound column (default 'upper').

Value

data.table. Matched bins with overlap proportions.

Details

  • Computes overlap proportion for each bin pair.

  • Selects bin with highest overlap for each source bin.

  • Handles infinite bounds and ensures unique assignment.

  • Returns data.table with matched bins and overlap proportions.

  • Assumes input tables have lower/upper bounds and bin IDs.

Settings

None.

See also

get_income_bounds

Examples

## Not run:
find_income_overlaps(dt_x, dt_y)
#> Error: object 'dt_x' not found