svy
v0.30.0Design-based survey analysis: estimation, weighting, replicate weights, and modelling.
Open source · free forever
The open-source engine under svyLab: estimation with correct variances, weighting and calibration, replicate weights, small-area estimation, and readers and writers for SPSS, Stata and SAS files, validated against R's survey package. Read the code, run it in a notebook, cite it.
1 For the estimators benchmarked (means, totals, ratios, proportions, domain means and batched multi-variable calls), measured on an Apple M1 Max with 10 cores and 34 GB RAM. Other estimators were not timed, and the ratios shrink on machines with fewer cores.
import svy df = svy.read_parquet("wave1.parquet") design = svy.Design( stratum="region", psu="cluster", wgt="final_wgt" ) sample = svy.Sample(data=df, design=design) est = sample.estimation.mean( ["income", "food_share"], by="urban_rural" ) print(est) # est · se · lci · uci · cv · deff · df
pip install svy
Documentation
All on PyPI · github.com/samplics-org
Design-based survey analysis: estimation, weighting, replicate weights, and modelling.
Small-area estimation: Fay–Herriot, unit-level (Battese–Harter–Fuller), Molina–Rao — on JAX.
Fast readers and writers for SPSS, Stata, and SAS survey files — labels and missing codes included.
If you read four things
The standing validation study — every estimate and standard error agrees to at least six decimals.
Two NCHS data briefs reproduced at published precision, Korn–Graubard intervals included.
12–24× faster than R's survey on the estimators benchmarked, at one million rows on a stratified two-stage design.
The weighting tutorial — the page most people arrive on from search.
Variance estimation with replicate weights, end to end.
Learn
Validation studies, benchmarks, comparisons with R and Stata — the methods content.
svy on national surveys — NHANES, Canada's LFS, Mexico's ENIGH, Brazil's TIC Domicílios.
Hands-on sessions on public-use files, such as the 2025 MEPS-HC workshop.
Everything, including the RSS feeds: svylab.com/learn →
svy is the evolution of samplics, published in the Journal of Open Source Software. If it contributes to published work, please cite:
Diallo, M. S. (2021). samplics: a Python package for selecting, weighting and analyzing data from complex sampling designs. Journal of Open Source Software. doi:10.21105/joss.03376
Issues, feature requests, and pull requests are welcome on GitHub. The comparison with R doubles as the validation suite, so a reproducible example against R's survey is the most useful bug report there is.
Open an issue →Releases, tutorials, and svyLab updates — a few emails a year.
Using svy in your organization?
Questionnaire and analysis plan in — weights, estimates, and a branded report out, every wave, with the method behind every number visible to a reviewer. Same engine; one governed place.