Skip to contents

Overview

weightflow weightflow-package
weightflow: declarative survey weighting

Build and run a recipe

Define the recipe, estimate it, and pull the weights out.

weighting_spec()
Start a weighting specification
prep()
Estimate the weighting cascade
collect_weights()
Extract the data with the computed weights
y_model()
Specify a working model for a study variable y

Adjustment steps

The staged adjustments, applied in the order you pipe them.

step_unknown_eligibility()
Unknown-eligibility adjustment
step_drop_ineligible()
Drop ineligible (out-of-scope) units
step_select_within()
Within-household selection adjustment
step_nonresponse()
Nonresponse adjustment
step_calibrate()
Calibration to population totals
step_model_calibration()
Model calibration (model-assisted, Wu & Sitter 2001)
step_trim()
Trim extreme weights
step_trim_weights()
Automatic weight trimming (survey-style)
step_round()
Round the final weights
step_rescale()
Rescale (normalize) the weights
step_assert()
Assert conditions on the weights at this point of the cascade

Diagnostics and reporting

Inspect, summarise and report the cascade.

summary(<prepped_weighting_spec>)
Detailed per-step diagnostics
plot(<prepped_weighting_spec>)
Diagnostic plots for the weights
weight_factors()
Per-unit adjustment factors table
design_effect()
Kish design effect from unequal weighting
report_weighting()
Build a nice HTML report of the weighting recipe

Variance estimation

Bootstrap that re-applies the recipe, plus survey/srvyr bridges.

bootstrap_weights()
Bootstrap replicate weights that re-apply the recipe
bootstrap_estimate() boot_total() boot_mean()
Bootstrap estimate, standard error and confidence interval
as_svydesign() as_svrepdesign()
Export weightflow weights to a survey design
collect_replicate_weights()
Collect replicate weights into a data frame ready for srvyr

Example data

population
Example target population for weightflow
sample_survey
Example survey sample (take-all roster)
sample_one
Example survey sample (select-one-person, multistage)