weightflow: Declarative Recipes for Staged Survey Weighting with Recipe-Aware Replicate Variances

Builds survey analysis weights by declaring the whole weighting process as an ordered recipe of explicit adjustments and estimating it in a single call. Steps include within-cluster selection, second-phase subsampling for two-phase sampling, nonresponse adjustment by weighting classes or response-propensity models (including machine-learning learners with optional cross-fitting), calibration to known totals following Deville and Sarndal (1992) <doi:10.2307/2290268> with optional model-assisted calibration following Wu and Sitter (2001) <doi:10.1198/016214501750333054>, adjustment of non-probability samples by pseudo-weighting, mass imputation and doubly robust estimators, and range-restricted trimming. Variances come from a recipe-aware bootstrap and jackknife that resample or delete primary sampling units and re-apply the entire cascade on each replicate, following Rao and Wu (1988) <doi:10.1080/01621459.1988.10478591>, and are separated into first- and second-phase components (V = V1 + V2) for two-phase designs. A self-contained HTML report documents each step, and the weights bridge to the 'survey' and 'srvyr' packages.

Version: 1.2.0
Depends: R (≥ 4.1.0)
Imports: stats, utils, graphics, parallel
Suggests: MASS, rpart, ranger, testthat (≥ 3.0.0), survey, srvyr, dplyr, tidyr, ggplot2, haven, archive, knitr, rmarkdown, spelling, xgboost, yaml
Published: 2026-08-30
DOI: 10.32614/CRAN.package.weightflow
Author: Juan Pablo Ferreira ORCID iD [aut, cre, cph], Andrés Gutiérrez ORCID iD [aut]
Maintainer: Juan Pablo Ferreira <juanpablo.ferreira at fcea.edu.uy>
BugReports: https://github.com/jpferreira33/weightflow/issues
License: MIT + file LICENSE
URL: https://github.com/jpferreira33/weightflow, https://jpferreira33.github.io/weightflow/
NeedsCompilation: no
Language: en-US
Citation: weightflow citation info
Materials: README, NEWS
In views: OfficialStatistics
CRAN checks: weightflow results

Documentation:

Reference manual: weightflow.html , weightflow.pdf
Vignettes: Machine learning, cross-fitting and robust calibration (source, R code)
Ways to specify calibration totals (source, R code)
Calibration: raking, post-stratification and GREG (source, R code)
Inspecting and auditing the cascade (source, R code)
Model calibration (model-assisted weighting) (source, R code)
Non-probability samples (source, R code)
Nonresponse: weighting classes, propensities and calibration (source, R code)
Preparing the sample: eligibility and response before weighting (source, R code)
Documenting and auditing the weights: the quality report (source, R code)
From raw sample to final weights (source, R code)
Calibrating to a reference survey (source, R code)
Trimming survey weights (source, R code)
Two-phase (double) sampling (source, R code)
Validation against the survey package (source, R code)
Variance estimation (source, R code)
weightflow in production (GSBPM 5.6) (source, R code)
Staged survey weighting: the adjustment logic (source, R code)

Downloads:

Package source: weightflow_1.2.0.tar.gz
Windows binaries: r-devel: weightflow_1.1.0.zip, r-release: weightflow_1.2.0.zip, r-oldrel: weightflow_1.2.0.zip
macOS binaries: r-release (arm64): weightflow_1.2.0.tgz, r-oldrel (arm64): weightflow_1.2.0.tgz, r-release (x86_64): weightflow_1.2.0.tgz, r-oldrel (x86_64): weightflow_1.2.0.tgz
Old sources: weightflow archive

Linking:

Please use the canonical form https://CRAN.R-project.org/package=weightflow to link to this page.