Skip to contents

Overview

weightflow weightflow-package
weightflow: declarative survey weighting
weightflow-concepts
Conventions shared by every weightflow step
weightflow-alerts
Quality alerts raised while preparing a recipe

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
weighting_alerts() has_alerts()
Quality alerts recorded while preparing a recipe
collect_weights()
Extract the data with the computed weights
y_model()
Specify a working model for a study variable y
reference_sample()
Use a weighted survey as the calibration reference instead of a frame
write_recipe()
Write a weighting recipe to a YAML file
read_recipe()
Read a weighting recipe from a YAML file

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-cluster selection adjustment
step_subsample()
Second-phase subsampling (two-phase sampling)
step_nonresponse()
Nonresponse adjustment
step_pseudoweight()
Pseudo-weights for a non-probability sample against a reference
step_calibrate()
Calibration to population totals
step_model_calibration()
Model calibration (Wu and Sitter 2001)
step_trim()
Trim extreme weights against a ratio
step_trim_weights()
Automatic weight trimming to an absolute band
step_trim_calibrated()
Trimmed calibration (range-restricted, totals-preserving)
step_round()
Round the final weights
step_rescale()
Rescale the weights to a fixed sum
step_assert()
Assert quality conditions on the weights
step_nr_sensitivity()
Sensitivity of a mean to nonignorable nonresponse or selection
step_cross_sectional() step_longitudinal()
Declare the recipe's scope: cross-sectional or longitudinal weights
step_panel_overlap()
Adjust base weights by the panel-selection probability (CEPAL ch. XVI)
step_attrition()
Attrition adjustment for panel waves
step_cre()
Composite regression estimator (CRE / regression composite estimation)

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
collect_propensities()
Recover the fitted response propensities of a nonresponse step
collect_step_detail()
Per-unit detail of one step of the cascade
domain_summary()
Per-domain weight summary at every stage of the cascade
design_effect()
Kish design effect from unequal weighting
data_defect()
Data-defect diagnostics for a non-probability sample
disclosure_risk()
Flag re-identification risk from outlier weights within a publication cell
nr_sensitivity()
Read the nonresponse-sensitivity analysis from a prepped recipe
report_weighting()
Self-contained HTML quality report for a weighting recipe

Variance estimation

Bootstrap and jackknife that re-apply the recipe, plus survey/srvyr bridges.

bootstrap_weights()
Recipe-aware bootstrap replicate weights
two_phase_variance()
Decompose a two-phase variance into V = V1 + V2
bootstrap_estimate() boot_total() boot_mean()
Bootstrap estimate, standard error and confidence interval
jackknife_weights()
Recipe-aware delete-a-PSU jackknife replicate weights
jackknife_estimate() jack_total() jack_mean()
Jackknife 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
as_sae_input()
Direct estimates and design SEs per domain, ready for small-area estimation
print(<weightflow_boot>)
Print a bootstrap replicate-weight object
print(<weightflow_jack>)
Print a jackknife replicate-weight object

Panels

Rotating and pure panels – structure, net change, chaining and gross flows.

panel_design()
Describe the rotating-panel structure of a survey
panel_merge()
Build the wide longitudinal file from per-wave surveys
panel_pr()
Panel-selection probability for a set of combined waves
wave_bootstrap()
Coordinated bootstrap across panel waves
wave_jackknife()
Coordinated delete-one jackknife across panel waves
change_estimate() change_mean() change_total()
Net change between two panel waves, with honest variance
level_estimate() level_mean() level_total()
Level estimate for a single panel wave, with its replicate variance
panel_estimate() panel_mean() panel_total()
Linear combination of panel waves, with honest between-wave variance
wave_step()
One period of a coordinated panel bootstrap, chained from the previous ones
wave_carry()
Extract the carry artifact of a period
wave_contrast()
Linear combination of an estimand across a chain of periods
transition_matrix()
Gross-flow transition matrix between two panel waves
boot_transition()
Transition matrix with per-cell bootstrap standard errors
boot_flows()
Gross-flow TOTALS with standard errors, plus net flows and margins
report_panel()
Panel / longitudinal HTML report

Estimation grammar

Declare domains and estimands once, read them off a saved replicate object.

step_domain() step_filter() step_estimate() step_transition()
Declarative estimation over a coordinated panel object
collect_estimates()
Evaluate an estimation pipeline

Example data

population
Synthetic target population (sampling frame)
sample_survey
Synthetic person sample with a take-all household roster
sample_one
Synthetic address sample with one selected person per household
panel_puro panel_cl panel_ine panel_us
Synthetic rotating- and pure-panel datasets