Skip to contents

Derives comp1 through comp5 from raw ENEMDU questionnaire variables for a supported profile. The output is designed to be passed to enemdu_build_nbi_flags().

Usage

enemdu_build_nbi_components(
  data,
  profile = "enemdu_2025_anual",
  household_id = "id_hogar",
  person_id = "p01",
  hsize_var = "hsize",
  area_var = "area",
  overwrite = FALSE,
  strict = TRUE,
  registry = enemdu_nbi_derivation_registry()
)

Arguments

data

A data frame.

profile

NBI derivation profile.

household_id

Household identifier variable.

person_id

Person identifier variable.

hsize_var

Household-size variable. If absent, it is built from household_id.

area_var

Optional area/domain variable used by the input preflight.

overwrite

Logical. If TRUE, overwrite existing comp1-comp5.

strict

Logical. If TRUE, abort when required inputs are missing.

registry

NBI derivation registry.

Value

A data frame with comp1 through comp5.

Details

This function does not compute knbi, nbi, or xnbi, and it does not implement TPM, TPEM, intensity, or IPM.

Examples

data <- tibble::tibble(
  id_hogar = c("h1", "h1", "h2", "h2"),
  p01 = c(1, 2, 1, 2),
  p03 = c(40, 8, 45, 10),
  p04 = c(1, 3, 1, 3),
  p07 = c(2, 2, 2, 1),
  p10a = c(1, 3, 4, 3),
  p10b = c(0, 2, 5, 3),
  empleo = c(0, 0, 1, 0),
  vi04a = c(7, 7, 1, 1),
  vi05a = c(1, 1, 1, 1),
  vi07 = c(0, 0, 1, 1),
  vi09 = c(5, 5, 1, 1),
  vi10 = c(1, 1, 1, 1),
  vi10a = c(1, 1, 1, 1),
  area = c(1, 1, 2, 2)
)

out <- enemdu_build_nbi_components(data)
enemdu_build_nbi_flags(out)
#> # A tibble: 4 × 24
#>   id_hogar   p01   p03   p04   p07  p10a  p10b empleo vi04a vi05a  vi07  vi09
#>   <chr>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 h1           1    40     1     2     1     0      0     7     1     0     5
#> 2 h1           2     8     3     2     3     2      0     7     1     0     5
#> 3 h2           1    45     1     2     4     5      1     1     1     1     1
#> 4 h2           2    10     3     1     3     3      0     1     1     1     1
#> # ℹ 12 more variables: vi10 <dbl>, vi10a <dbl>, area <dbl>, hsize <int>,
#> #   comp1 <int>, comp2 <int>, comp3 <int>, comp4 <dbl>, comp5 <int>,
#> #   knbi <int>, nbi <int>, xnbi <int>