expected_CV.Rd
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
expected_CV(strata, errors, alloc)
a dataframe containing the maximum expected coefficients of variation in each domain level for each target variable
load("./data/sample.RData")
#> Warning: cannot open compressed file './data/sample.RData', probable reason 'No such file or directory'
#> Error in readChar(con, 5L, useBytes = TRUE): cannot open the connection
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)
#>
#> Calculating strata...
#> Error: object 'samp' not found
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)
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Error in chromy(0, 999, 0, c(rep(1/nvar, nvar)), c(rep(0, nvar)), array(0.1, dim = c(nstrat, 1))): dims [product 16] do not match the length of object [32]
alloc <- allocation$alloc$ALLOC[-nrow(allocation$alloc)]
#> Error in -nrow(allocation$alloc): invalid argument to unary operator
exp_cv <- expected_CV(strata,cv,alloc)
#> Error in checkData(strata = stratif, errors = errors): In strata dataframe the number of means and std deviations differs from the number of coefficient of
#> variations in errors dataframe
exp_cv
#> Error: object 'exp_cv' not found