Skip to contents

Creates a standardized employment target variable for person-level weighting and expansion, using either PUMS or survey input. Use when preparing employment targets for synthetic population or survey analysis.

Usage

prep_target_employment(
  h_data,
  p_data,
  target_name = "p_employment",
  codebook,
  settings
)

Arguments

h_data

data.table. Household-level input (not used, included for interface consistency).

p_data

data.table. Person-level input. Required columns:

  • For PUMS: must include SERIALNO, ESR, WKHP.

  • For survey: must include employment column as specified in settings. Rows: one per person. Modified by reference: no (returns copy).

target_name

character(1). Name of the target variable to create (default: "p_employment").

codebook

data.table. Codebook for variable mapping; must include employment value and label columns.

settings

list. Project settings; must include targets[[target_name]] with levels.

Value

data.table. Copy of person-level input with new target variable column (target_name).

  • Columns: all original plus target_name (factor)

  • Values: standardized employment levels ("full_time", "part_time", "nonworker")

  • Row order preserved

Details

  • Detects input type (PUMS vs. survey) by presence of SERIALNO column.

  • For PUMS:

    • Uses codebook to map ESR codes to employment status labels.

    • Uses regex civilian employed|armed forces to identify workers in val_label (case-insensitive).

    • Assigns target levels:

      • is_worker & WKHP >= 35 → "full_time"

      • is_worker & WKHP < 35 → "part_time"

      • else → "nonworker"

  • For survey:

    • Uses codebook to map employment values to labels.

    • Uses regex patterns:

      • label %like% "Employed full" → "full_time"

      • label %like% "Employed part" → "part_time"

      • label %like% "Self-employed" → "full_time"

      • else → "nonworker"

  • Includes self-employed in full-time worker category.

  • Checks that observed levels match expected target levels from settings.

  • Renames output column to target_name (default: p_employment).

  • Returns a copy of the input data.table with the new target variable.

  • Error handling: stops if levels do not match expected values.

Settings

  • targets[["p_employment"]] (direct): must include levels.

Examples

## Not run:
prep_target_employment(h_data, p_data, target_name = "p_employment", codebook, settings)
#> Error: object 'p_data' not found
## End(Not run)