Ir al contenido

Estimates a mean, a proportion or a total from a survey design (for example one built with fa_design()), overall or by domain, and adds the standard error, a confidence interval, the coefficient of variation and the INEI quality band (fa_quality()).

Uso

fa_estimate(
  design,
  var,
  type = c("mean", "prop", "total"),
  by = "national",
  level = 0.95,
  na.rm = TRUE,
  min_n = 30
)

Argumentos

design

A survey.design object.

var

Name of the variable to estimate. For type = "prop" it must be logical or coded 0/1.

type

"mean", "prop" (a mean of a 0/1 variable, kept between 0 and 1) or "total".

by

Domain: "national", "department", "area", "district", or the name of any column in the design. Departments and districts are read from a ubigeo column or from ccdd, ccpp and ccdi; area from an area column (1 urban, 2 rural) or ENDES hv025.

level

Confidence level.

na.rm

Drop missing values of var.

min_n

Fewest unweighted cases for a figure to be rated by its CV. Below it the quality is "referencial" whatever the CV, because a standard error from a handful of cases is itself unreliable. Set to 0 to rate by the CV alone.

Valor

A data frame with one row per domain: by, domain, name (department name when by = "department"), var, type, estimate, se, ci_low, ci_high, cv (percent), n (unweighted cases) and quality, of class fa_estimate (see estimate-methods).

Detalles

Intervals are normal (Wald) intervals; for proportions they are cut at 0 and 1. Rows without a domain (for example the ENA's agricultural firms, which carry no location) count in national figures but are left out of a breakdown, with a message. If the option survey.lonely.psu is left at its default ("fail"), strata with a single primary unit are handled with "adjust" during the call.

Ejemplos

library(survey)
data(api, package = "survey")
d <- svydesign(~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc)
d$variables$high <- d$variables$api00 > 700
fa_estimate(d, "high", type = "prop", by = "stype")
#> <faperu estimate: prop of `high` by stype, 3 rows>
#>  Area Estimate 95% CI      CV (%) n   Quality    
#>  E    36.1*    20.7 - 51.5 21.7   144 referencial
#>  H    28.6*    0.0 - 61.7  59.2   14  referencial
#>  M    24.0*    1.2 - 46.8  48.5   25  referencial
#> * CV above 15% or fewer than 30 cases: a reference only (INEI 'referencial').