Skip to content

Open source · free forever

Open-source for survey design and analysis in Python.

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.

pip install svy GitHub Getting started →
37
estimators validated against R, to at least six decimals
12–24×
faster than R on a million-row two-stage design1
2020
first released, as samplics

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.

analysis.py
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
Runs on your machine. pip install svy

Documentation

The libraries

All on PyPI · github.com/samplics-org

Cite it

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

Contribute

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 →

Follow along

Releases, tutorials, and svyLab updates — a few emails a year.

Using svy in your organization?

svyLab runs your survey program on it.

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.