Skip to contents

Estimates an indicator declared in indicator_registry.csv by selecting the appropriate survey estimator according to the indicator contract.

Usage

enemdu_indicator_estimate(
  data,
  indicator_id,
  group_vars = NULL,
  registry = enemdu_indicator_registry(),
  value = NULL,
  ids = "upm",
  strata = "estrato",
  weight = NULL,
  survey_type = NULL,
  domain_level = NULL,
  domain_var = NULL,
  strict_domain = FALSE,
  integrate_representativity = TRUE,
  household_id = "idhogar",
  hsize = "hsize",
  scale_adjustment = c("metadata", "never", "always"),
  conf_level = 0.95,
  lonely_psu = "adjust",
  sample_n_min = 60
)

Arguments

data

A data frame.

indicator_id

Indicator identifier declared in indicator_registry.csv.

group_vars

Optional grouping variables.

registry

Indicator registry. Defaults to package registry.

value

Optional value variable override.

ids

Primary sampling unit variable. Defaults to "upm".

strata

Strata variable. Defaults to "estrato".

weight

Optional weight variable override. If NULL, uses registry value.

survey_type

Optional ENEMDU survey type. If omitted, uses the survey_type attribute when available.

domain_level

Optional domain level. If omitted and group_vars is supplied, the domain level is inferred from domain_variable_registry.csv.

domain_var

Optional domain variable. Usually omitted because group_vars is enough for inference.

strict_domain

Logical. If TRUE, errors when requested domains are outside the design scope of the selected ENEMDU survey type.

integrate_representativity

Logical. If TRUE, appends integrated representativity metadata to the estimate.

household_id

Household identifier used when household-scale adjustment is needed.

hsize

Household-size variable.

scale_adjustment

One of "metadata", "never" or "always". "metadata" applies the adjustment only when the registry requests it.

conf_level

Confidence level.

lonely_psu

Option passed to survey.lonely.psu.

sample_n_min

Preliminary minimum sample size flag.

Value

A tibble with the design-based estimate, registry metadata, and integrated representativity metadata when available.

Details

Supported estimator types in this phase are:

  • mean

  • total

  • proportion_0_1

Indicators with scale_adjustment_required = TRUE receive an internal household-scale correction for the precision decision when the adjustment is enabled. This does not change the point estimate. It adjusts the effective analytical size used for the representativity decision by summing 1 / hsize over valid repeated household-level observations.

When integrate_representativity = TRUE, the function also validates the requested domain against the representativity scope of the ENEMDU survey type and appends a final representativity_flag.