Create the inputs to evaluate the quality of proportion estimations
create_prop.Rd
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 thevar
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, ifTRUE
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.
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)
#> stat se df n cv
#> 1 0.6138541 0.02485186 248 48308 0.04048496
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)
#> stat se df n cv
#> 1 0.8937474 0.04366055 486 24465 0.04885111
options(old_options)