create_prop {calidad}R 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
)

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 it is required

standard_eval

boolean Indicating if the function is wrapped inside a function, if TRUE avoid lazy eval errors

eclac_input

boolean return eclac inputs

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)

[Package calidad version 0.5.0 Index]