create_prop: Create the inputs to evaluate the quality of proportion...

View source: R/create_external.R

create_propR Documentation

Create the inputs to evaluate the quality of proportion estimations

Description

create_prop generates a dataframe with the following elements: sum, degrees of freedom, sample size, standard error, and coefficient of variation. The function allows grouping in several domains.

Usage

create_prop(
  var,
  denominator = NULL,
  domains = NULL,
  subpop = NULL,
  design,
  ci = FALSE,
  deff = FALSE,
  ess = FALSE,
  ajuste_ene = FALSE,
  rel_error = FALSE,
  log_cv = FALSE,
  unweighted = FALSE,
  standard_eval = FALSE,
  eclac_input = FALSE,
  ci_logit = FALSE,
  scheme = c("eclac_2020", "eclac_2023")
)

Arguments

var

numeric variable within the dataframe, is the numerator of the ratio to be calculated.

denominator

numeric variable within the dataframe, is the denominator of the ratio to be calculated. If the var parameter is dummy, it can be NULL.

domains

domains to be estimated separated by the + character.

subpop

integer dummy variable to filter the dataframe.

design

complex design created by survey package.

ci

boolean indicating if the confidence intervals must be calculated.

deff

boolean design effect.

ess

boolean effective sample size.

ajuste_ene

boolean indicating if an adjustment for the sampling-frame transition period must be used.

rel_error

boolean relative error.

log_cv

boolean logarithmic coefficient of variation.

unweighted

boolean add non-weighted count if required.

standard_eval

boolean indicating if the function is wrapped inside another function, if TRUE avoid lazy eval errors.

eclac_input

boolean return eclac inputs

ci_logit

boolean indicating if interval confidence is logit, only available for proportions.

scheme

character variable indicating the evaluation protocol to use for CEPAL standard. Options are "eclac_2020" and "eclac_2023". The "eclac_2020" option does not support ratio estimation.

Value

dataframe that contains the inputs and all domains to be evaluated.

Examples

library(survey)
library(dplyr)

epf <- mutate(epf_personas, gasto_zona1 = if_else(zona == 1, gastot_hd, 0))
dc <- svydesign(ids = ~varunit, strata = ~varstrat, data = epf, weights = ~fe)
old_options <- options()
options(survey.lonely.psu = "certainty")

create_prop(var = "gasto_zona1", denominator = "gastot_hd", design = dc)

enusc <- filter(enusc, Kish == 1)

dc <- svydesign(ids = ~Conglomerado, strata = ~VarStrat, data = enusc, weights = ~Fact_Pers)
options(survey.lonely.psu = "certainty")
create_prop(var = "VP_DC", denominator = "hom_insg_taxi", design = dc)
options(old_options)

calidad documentation built on April 15, 2025, 5:08 p.m.