Builds the IPM component columns that are auditable in the current package
contract and marks the remaining registered components as pending. The
current operational rules cover all 12 registered components for the
enemdu_2025_anual profile when the required source variables are present.
Usage
enemdu_build_ipm_components(
data,
profile = "enemdu_2025_anual",
household_data = NULL,
household_id = "id_hogar",
person_id = "p01",
hsize_var = "hsize",
overwrite = FALSE,
strict = TRUE,
extreme_poverty_var = "epobre",
extreme_poverty_income_var = NULL,
extreme_poverty_line = NULL,
build_from_precomputed = TRUE,
water_public_network_codes = 1,
extreme_poverty_alias_vars = c("epobreza", "expobre"),
area_var = "area",
age_var = "p03",
attendance_var = "p07",
attendance_yes_codes = 1,
attendance_no_codes = 2,
school_age_min = 5,
school_age_max = 17,
education_level_var = "p10a",
education_grade_var = "p10b",
incomplete_education_age_min = 18,
incomplete_education_age_max = 64,
incomplete_schooling_years = 10,
condact_var = "condact",
labor_inadequate_flags = c("labor_desempleo", "labor_subempleo",
"labor_otro_empleo_no_pleno", "labor_empleo_no_remunerado",
"labor_empleo_no_clasificado"),
higher_education_reason_var = "p09",
higher_education_economic_reason_codes = 3,
bachillerato_completed_levels = NULL,
bachillerato_completed_min_grade = NULL,
child_work_var = "empleo",
child_hours_var = "p24",
child_income_var = "ingrl",
p20_var = "p20",
p21_var = "p21",
p22_var = "p22",
p24_var = "p24",
pea_var = "pea",
condactn_var = c("condactn", "condact"),
p51_prefix = "p51",
child_sbu = 470,
employment_na_as_not_employed = TRUE,
hours_sentinel_codes = 999,
income_negative_sentinel_codes = -1,
income_missing_sentinel_codes = 999999,
social_security_var = "p61b1",
social_security_a_var = "p05a",
social_security_b_var = "p05b",
pension_income_var = "p72a",
human_development_bonus_var = "p75",
disability_bonus_var = "p77",
social_security_contribution_codes = c(1, 2, 3, 4),
social_security_no_contribution_codes = 5,
social_security_unknown_codes = 6,
unemployment_var = "desempleo",
unemployed_var = "desem",
inactive_var = "pei",
working_age_var = "pet",
roof_material_var = "vi03a",
roof_state_var = "vi03b",
floor_material_var = "vi04a",
floor_state_var = "vi04b",
wall_material_var = "vi05a",
wall_state_var = "vi05b",
housing_material_valid_codes = NULL,
housing_state_valid_codes = 1:3,
bedrooms_zero_policy = c("official_recode_to_one", "deprived"),
deficit_roof_material_codes = NULL,
deficit_floor_material_codes = NULL,
deficit_wall_material_codes = NULL,
deficit_state_codes = 3,
sanitation_var = "vi09",
sanitation_urban_area_codes = 1,
sanitation_rural_area_codes = 2,
sanitation_sewer_codes = 1,
sanitation_septic_codes = 2,
sanitation_valid_codes = 1:5,
garbage_var = "vi13",
garbage_collection_codes = 2,
garbage_valid_codes = 1:5
)Arguments
- data
Person-level ENEMDU data.
- profile
IPM derivation profile. Defaults to
"enemdu_2025_anual".- household_data
Optional household- or housing-level ENEMDU data. When supplied, it is joined with
enemdu_join_ipm_sources().- household_id
Household identifier.
- person_id
Person identifier.
- hsize_var
Household-size variable. If absent, household size is derived by counting persons within
household_idfor implemented household components.- overwrite
Logical. If
TRUE, replace components that can be built from implemented rules.- strict
Logical. If
TRUE, abort when any registered component remains pending or when implemented source values are invalid or missing.- extreme_poverty_var
Precomputed binary extreme-income-poverty flag. Defaults to
"epobre"for the official-syntax profile.- extreme_poverty_income_var
Optional per-capita income variable used only to fill missing values in the selected
extreme_poverty_varor alias whenextreme_poverty_lineis also supplied. This local reproducibility fallback does not constitute official validation by itself.- extreme_poverty_line
Optional extreme-poverty line used with
extreme_poverty_income_varto fill missing selected binary-flag cases viaincome < line. The line is never hard-coded by this builder.- build_from_precomputed
Logical. If
TRUE, existing registered component columns are accepted as precomputed inputs after binary validation.- water_public_network_codes
Codes that identify public-network water in the source water variable. The default
1is profile-specific and still requires real-data reproducibility validation.- extreme_poverty_alias_vars
Alias variables checked when
extreme_poverty_varis absent. Defaults to"epobreza"and"expobre"for the 2025 annual ENEMDU profile.- area_var
Urban/rural area variable used by sanitation rules.
- age_var
Age variable.
- attendance_var
School-attendance variable.
- attendance_yes_codes
Codes that mean attending formal education.
- attendance_no_codes
Codes that mean not attending formal education.
- school_age_min
Minimum age for basic and bachillerato attendance.
- school_age_max
Maximum age for basic and bachillerato attendance.
- education_level_var
Educational level variable.
- education_grade_var
Completed grade/year variable within educational level.
- incomplete_education_age_min
Minimum age for incomplete educational attainment.
- incomplete_education_age_max
Maximum age for incomplete educational attainment.
- incomplete_schooling_years
Schooling-year cutoff for incomplete educational attainment.
- condact_var
Consolidated ENEMDU condition-of-activity variable used through
enemdu_build_labor_flags().- labor_inadequate_flags
Existing or derived labor flags treated as unemployment or inadequate employment.
- higher_education_reason_var
Reason for not attending higher education.
- higher_education_economic_reason_codes
Codes treated as economic reasons for not accessing higher education. The default
3follows the official-syntax profile. IfNULL, the builder attempts to infer the code from value labels containing economic-resource wording.- bachillerato_completed_levels
Optional education-level codes that identify completed bachillerato when paired with
bachillerato_completed_min_grade. IfNULL, the profile-specific schooling-years helper is used.- bachillerato_completed_min_grade
Optional minimum grade/year for the levels in
bachillerato_completed_levels.- child_work_var
Binary employment/work variable for children and adolescents.
- child_hours_var
Weekly-hours variable for working adolescents.
- child_income_var
Labor-income variable for working adolescents.
- p20_var, p21_var, p22_var, p24_var, pea_var
Official child/adolescent employment source variables used when available.
- condactn_var
Candidate official condition-of-activity variables. Defaults to checking
"condactn"and"condact".- p51_prefix
Prefix for p51 hour variables used in official child/adolescent employment hours.
- child_sbu
Profile-specific basic salary cutoff used for adolescents. The default
470is for the 2025 annual profile.- employment_na_as_not_employed
Logical. If
TRUE, missing values in the operational employment flag are treated as not employed for IPM components that useemployment_var. This matches the ENEMDU 2025 annual profile whereempleois coded as1/NA.- hours_sentinel_codes
Hour codes treated as non-evaluable sentinels.
- income_negative_sentinel_codes
Income codes treated as negative-income sentinels.
- income_missing_sentinel_codes
Income codes treated as missing-income sentinels.
Social-security contribution variable.
Official social-security affiliation/contribution variables used when available.
- pension_income_var
Retirement or pension receipt variable.
- human_development_bonus_var
Human-development bonus receipt variable.
- disability_bonus_var
Disability-bonus proxy variable.
Contribution codes.
No-contribution codes.
Unknown contribution codes.
- unemployment_var
Binary unemployment variable used for diagnostics in the pension component.
- unemployed_var, inactive_var, working_age_var
Official pension component source variables used when available.
- roof_material_var
Roof-material variable.
- roof_state_var
Roof-state variable.
- floor_material_var
Floor-material variable.
- floor_state_var
Floor-state variable.
- wall_material_var
Wall-material variable.
- wall_state_var
Wall-state variable.
- housing_material_valid_codes
Confirmed valid material codes. If
NULL, labels are used when available.- housing_state_valid_codes
Confirmed valid state codes.
- bedrooms_zero_policy
Policy for
vi07 == 0in overcrowding. The default"official_recode_to_one"follows the official syntax.- deficit_roof_material_codes
Roof-material codes treated as deficit.
- deficit_floor_material_codes
Floor-material codes treated as deficit.
- deficit_wall_material_codes
Wall-material codes treated as deficit.
- deficit_state_codes
State codes treated as deficit.
- sanitation_var
Excreta-sanitation source variable.
- sanitation_urban_area_codes
Area codes treated as urban.
- sanitation_rural_area_codes
Area codes treated as rural.
- sanitation_sewer_codes
Sanitation codes treated as sewerage.
- sanitation_septic_codes
Sanitation codes treated as septic tank.
- sanitation_valid_codes
Confirmed valid codes for the sanitation source variable.
- garbage_var
Garbage-disposal source variable.
- garbage_collection_codes
Garbage-disposal codes treated as collection service. The default
2follows the official-syntax profile where onlyvi13 == 2is non-deprived.- garbage_valid_codes
Confirmed valid codes for the garbage-disposal source variable.
Value
A data frame with the 12 registered IPM component columns when
strict = FALSE or when all components are available, plus an
ipm_component_diagnostics attribute.
Details
This function does not invent unsupported rules. Rule details that depend on
questionnaire codes are explicit arguments. When strict = TRUE, the
function aborts if the full set of 12 registered IPM components cannot be
completed from implemented rules or accepted precomputed component columns.
When strict = FALSE, pending or non-evaluable components are returned as
NA_integer_ and documented in the diagnostics attribute.
This function does not compute ipm_score, tpm, tpem, A, or aggregate
ipm, and it does not claim official validation.