expected_CV: expected_CV

expected_CVR Documentation

expected_CV

Description

Function to report the expected coefficients of variation for target variables Ys in a 'strata' dataset given an allocation 'alloc' and the current set of precision constraints

Usage

expected_CV(strata, errors, alloc)

Arguments

strata

name of the dataframe containing information in the sampling strata.

errors

name of the dataframe

alloc

vector containing the allocation of sampling units.

Value

a dataframe containing the maximum expected coefficients of variation in each domain level for each target variable

Examples

load("./data/sample.RData")
target_vars <- c("active","inactive","unemployed","income_hh")
strata <- R2BEAT:::prepareInputToAllocation_beat.1st(samp_frame = samp,
                                                     ID = "id_hh",
                                                     stratum = "stratum_label",
                                                     dom = "region",
                                                     target = target_vars)
strata$CENS <- as.numeric(strata$CENS)
strata$COST <- as.numeric(strata$COST)
strata$CENS <- 0
cv <- as.data.frame(list(DOM = c("DOM1","DOM2"),
                         CV1 = c(0.05,0.10),
                         CV2 = c(0.05,0.10),
                         CV3 = c(0.05,0.10),
                         CV4 = c(0.05,0.10)))
allocation <- beat.1st(strata,cv)

alloc <- allocation$alloc$ALLOC[-nrow(allocation$alloc)]
exp_cv <- expected_CV(strata,cv,alloc)
exp_cv


barcaroli/R2BEAT documentation built on Jan. 9, 2025, 8:09 a.m.