Ir al contenido

Builds a survey::svydesign() object with the weight, strata and cluster variables that the catalog declares for that source. The first declared name found in the data is used, so the same call works for ENDES women (V005) and households (HV005). Any of them can be overridden, and a stratum can be the crossing of two columns, written "CCDD*AREA".

Uso

fa_design(
  data,
  survey,
  weight = NULL,
  strata = NULL,
  cluster = NULL,
  territory = NULL
)

Argumentos

data

A data frame, usually from fa_read().

survey

Short name, for example "enaho". See fa_surveys().

weight, strata, cluster

Variable names to use instead of the catalog defaults.

territory

Optional. Departments, provinces or districts to keep: INEI codes of 2, 4 or 6 digits ("21", "2101", "210101") or department names ("Puno", "Lima"), several at once if needed. The data need a ubigeo column or ccdd, ccpp and ccdi.

Valor

A survey.design2 object.

Detalles

The names were checked in INEI's technical sheets (fichas tecnicas) and in the headers of 2024 and 2025 files; the diseno entry of each YAML in inst/catalog/ lists them with a note and the document behind them.

  • EPEN: FAC300_ANUAL (or the quarterly and Lima weights), CONGLOMERADO, and department by ESTRATO as strata. Rows without weight (people under 14) are dropped with a message.

  • ENAPRES: FACTOR, CONGLOMERADO, department by area. Its ESTRATO column is socioeconomic, not a design stratum.

  • ENUT and ENARES: INEI publishes no strata, so there are none and a warning says so. ENARES weights depend on the questionnaire, and in the school questionnaires the cluster is the school.

  • Annual Economic Survey: FACTOR_EXP, one stage. Firms included with certainty (FACTOR_EXP == 1) form their own stratum with no variance. The real strata are not published, so standard errors are approximate.

Where a stratum has a single cluster, as in ENDES, survey stops unless you set options(survey.lonely.psu = "adjust"); faperu warns but does not change the option for you.

  • ENA: the stratum depends on the round. From 2023 it is ESTRATO; from 2014 to 2022 ESTRATO is empty for producers (or absent), and DOMINIO is used, with a warning of class faperu_warning_ena_strata. Agricultural firms (CODIGO 2) are a separate frame and keep their own strata; from 2024 they are surveyed in full and add no variance. The cluster is CONGLOMERADO up to 2022 and NSEGM from 2023. Read ESTRATO, DOMINIO and CODIGO with the other columns.

The ENA has thousands of fine strata, most with one cluster. Collapsing them is not official, but if you need it: ena$estrato_c <- paste0(ena$CCDD, substr(ena$ESTRATO, 7, 9)) and fa_design(ena, "ena", strata = "estrato_c").

Territory first, the right way. To study one department, province or district, pass it as territory instead of filtering the rows yourself. Filtering the data before the design drops the strata and clusters of the rest of the country and gives wrong standard errors. With territory, faperu builds the design on the whole sample and then keeps only that territory with survey::subset(), so the estimates are those of the territory and their precision is correct.

Ejemplos

if (FALSE) { # \dontrun{
s <- fa_read("enaho", 2024, "34", file = "Sumaria-2024\\.")
d <- fa_design(s, "enaho")
survey::svymean(~I(pobreza < 3), d)

# Only Puno, with correct standard errors
puno <- fa_design(s, "enaho", territory = "Puno")
survey::svymean(~I(pobreza < 3), puno)
} # }