This function executes a sequence of statistical estimations on Survey objects, applying functions from the R survey package with appropriate metadata. Automatically handles different survey types and periodicities.
Arguments
- svy
A list of Survey objects, or a PoolSurvey. Even for a single survey, wrap it in
list():workflow(svy = list(my_survey), ...). Must contain properly configured sample design.- ...
Calls to survey package functions (such as
svymean,svytotal,svyratio, etc.) that will be executed sequentially- estimation_type
Type of estimation (default
"monthly") that determines which weight to use. Options:"monthly","quarterly","annual", or vector with multiple types
Value
data.table with results from all
estimations, including columns:
stat: Name of estimated statisticvalue: Estimation valuese: Standard errorcv: Coefficient of variationestimation_type: Type of estimation usedsurvey_edition: Survey editionOther columns depending on estimation type
Details
The function automatically selects the appropriate sample design according
to the specified estimation_type. For each Survey in the input list,
it executes all functions specified in ... and combines the results.
Supported estimation types:
"monthly": Monthly estimations
"quarterly": Quarterly estimations
"annual": Annual estimations
For PoolSurvey objects, it uses a specialized methodology that handles pooling of multiple surveys.
See also
svymean for population means
svytotal for population totals
svyratio for ratios
svyby for domain estimations
PoolSurvey for survey pooling
Other workflows:
RecipeWorkflow-class,
evaluate_cv(),
print.RecipeWorkflow(),
publish_workflow(),
read_workflow(),
reproduce_workflow(),
save_workflow(),
workflow_from_list(),
workflow_table()
Examples
# Simple estimation with a test survey
dt <- data.table::data.table(
x = rnorm(100), g = sample(c("a", "b"), 100, TRUE),
w = rep(1, 100)
)
svy <- Survey$new(
data = dt, edition = "2023", type = "test",
psu = NULL, engine = "data.table",
weight = add_weight(annual = "w")
)
result <- workflow(
svy = list(svy),
survey::svymean(~x, na.rm = TRUE),
estimation_type = "annual"
)
# \donttest{
# ECH example with domain estimations
# result <- workflow(
# survey = list(ech_2023),
# svyby(~unemployed, ~region, svymean, na.rm = TRUE),
# estimation_type = "annual")
# }