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".
Argumentos
- data
A data frame, usually from
fa_read().- survey
Short name, for example
"enaho". Seefa_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 aubigeocolumn orccdd,ccppandccdi.
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 byESTRATOas strata. Rows without weight (people under 14) are dropped with a message.ENAPRES:
FACTOR,CONGLOMERADO, department by area. ItsESTRATOcolumn 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 2022ESTRATOis empty for producers (or absent), andDOMINIOis used, with a warning of classfaperu_warning_ena_strata. Agricultural firms (CODIGO2) are a separate frame and keep their own strata; from 2024 they are surveyed in full and add no variance. The cluster isCONGLOMERADOup to 2022 andNSEGMfrom 2023. ReadESTRATO,DOMINIOandCODIGOwith 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.
