Skip to contents

Builds the phase-3 core derived variables for ENEMDU analytical workflows:

Usage

enemdu_build_variables(
  data,
  household_id = "idhogar",
  normalize_missing = TRUE,
  missing_applies_to = "income_derivation",
  keep_raw_missing = TRUE,
  create_missing_flags = TRUE,
  missing_vars_absent = c("warn_as_na", "error"),
  existing = c("backup", "overwrite", "error"),
  backup_suffix = "_source"
)

Arguments

data

A data frame.

household_id

Household identifier. Defaults to "idhogar" and falls back to "id_hogar" when needed.

normalize_missing

Logical. If TRUE, applies enemdu_normalize_missing_values() to registered income components before deriving income variables.

missing_applies_to

Missing-code registry scope. Defaults to "income_derivation".

keep_raw_missing

Logical passed to enemdu_normalize_missing_values().

create_missing_flags

Logical passed to enemdu_normalize_missing_values().

missing_vars_absent

One of "warn_as_na" or "error". If "warn_as_na", absent optional income variables are treated as all-missing during income construction.

existing

One of "backup", "overwrite" or "error" for existing output variables.

backup_suffix

Suffix used when existing = "backup".

Value

A data frame with derived variables added and derivation metadata in attributes.

Details

  • household size (hsize),

  • main labor income (ingr),

  • secondary labor income (ingrls),

  • total labor income (ingrl),

  • individual total income before household aggregation (ingrltot),

  • household total income (ingtot),

  • household per-capita income (ingtot_pc).

The function deliberately does not derive poverty or extreme poverty flags. Poverty classification is handled by enemdu_build_poverty_flags() because it requires explicit and auditable poverty-line parameters.