svy-sae
Small area estimation at census scale, in Python.
svy-sae produces estimates for domains too small for direct survey estimation — districts, municipalities, enumeration areas — by borrowing strength from a model linking a survey to auxiliary population data. It implements the standard area-level and unit-level estimators, validated against R's sae package, on compiled JAX kernels that scale to a multi-million-household census.
🌐 svylab.com · 📦 PyPI · 🧭 Built on svy
Why svy-sae?
- The three estimators practitioners actually use. Fay–Herriot for area-level data, the Battese–Harter–Fuller nested-error model for unit-level, and Molina–Rao Empirical Best Prediction for non-linear indicators like poverty rates and Gini.
- Uncertainty you can report. Analytical MSE (Prasad–Rao for Fay–Herriot) where a closed form exists, and a parametric bootstrap where it does not — because a small area estimate without a defensible MSE is not usable for policy.
- Non-linear indicators, not just means. Poverty headcount, poverty gap, poverty severity, Gini and the quintile share ratio, computed per simulated population rather than back-transformed from a mean, plus any custom indicator you pass as a callable.
- Census scale. Memory is bounded independently of the Monte Carlo count, so a 2.5M-household census at 200 draws runs in about 16 seconds within roughly 2.5 GB.
- Cheap to import.
import svy_saecosts about 5 ms; JAX and the model machinery load on first use, so CLI tools, test collection, and doc builds do not pay for a fit they never run.
Installation
pip install svy-sae # or: uv add svy-sae
Requires Python 3.12–3.14. Wheels are published for macOS (Apple silicon), Linux (x86_64 and aarch64), and Windows.
Area level: Fay–Herriot
When you have direct estimates per area and their sampling variances:
import polars as pl
import svy
from svy_sae.models import AreaLevel
milk = svy.datasets.load("milk").with_columns(variance=pl.col("SD") ** 2)
result = AreaLevel(milk).fh(
y="yi",
x=svy.Cat("MajorArea", ref=1),
variance="variance",
area="SmallArea",
method="reml",
)
print(result.stats.sigma_u**2) # 0.018550 (R sae::eblupFH: 0.0186)
for pred in result.prediction[:3]:
print(pred.area, round(pred.pred, 4), round(pred.cv, 4))
Unit level: nested-error EBLUP
When you have unit records in the survey and area-level means from the census:
import svy
from svy_sae.models import UnitLevel
sample = svy.datasets.load("cornsoybean")
census = svy.datasets.load("cornsoybeanmeans")
result = UnitLevel(sample).eblup(
y="CornHec",
x=["CornPix", "SoyBeansPix"],
area="County",
pop_data=census,
pop_size="PopnSegments",
mse="analytical", # or "bootstrap" for a parametric bootstrap MSE
)
print(result.stats.sigma_u**2) # 63.3145 (R: 63.3149)
print(result.stats.sigma_e**2) # 297.7133 (R: 297.7128)
Non-linear indicators: Molina–Rao EBP
Poverty and inequality measures are not linear in the outcome, so they cannot be obtained by back-transforming a predicted mean. EBP simulates populations from the fitted model and computes the indicator on each:
from svy_sae.core.enumerations import Indicator
result = UnitLevel(sample).ebp(
y="CornHec",
x=["CornPix", "SoyBeansPix"],
area="County",
pop_data=census,
transformation="log", # "boxcox" (default), "log", or "none"
indicators=[Indicator.MEAN, Indicator.POVERTY_HEADCOUNT],
threshold=100.0, # absolute; pass a callable for e.g. 0.6 x median
n_mc=200,
rstate=42,
)
for pred in result.prediction[:4]:
print(pred.area, pred.indicator, round(pred.pred, 4))
Pass n_reps to add a parametric bootstrap MSE for each indicator.
Capabilities
| Area level | Fay–Herriot (REML, ML), Prasad–Rao and parametric bootstrap MSE |
| Unit level | Battese–Harter–Fuller EBLUP (REML, ML), analytical and bootstrap MSE |
| Non-linear | Molina–Rao EBP with Box–Cox, log, or no transformation |
| Indicators | Mean, poverty headcount, poverty gap, poverty severity, Gini, quintile share ratio, plus custom callables |
| Inputs | Polars frames or a svy.Sample, with the survey design carried through |
| Reproducibility | Explicit rstate seeds; typed, serializable result objects |
First-run performance
Model kernels compile on first use and are cached to disk (~/.cache/svy_sae),
so only the first fit of a given data shape on a machine pays compilation — a
few extra seconds. To pay that cost deliberately instead of during real work
(a class demo, a production window), warm the cache first:
import svy_sae
svy_sae.warmup() # every estimator path, tiny synthetic data
# Or warm the exact shapes you will fit — e.g. once before a workshop:
svy_sae.warmup(course_sample, y="pc_exp", x=["hhsize", "rooms"],
area="geo2", pop_data=course_census)
The cache is keyed by input shapes: warming with your own data covers your later fits of that data exactly; the no-argument form initialises JAX and covers only the built-in example shapes.
Validation
Estimates are checked against R's sae package on its own benchmark datasets, which ship with svy and make the comparisons above reproducible:
| svy-sae | R sae |
|
|---|---|---|
cornsoybean σ²_e |
297.7133 | 297.7128 |
cornsoybean σ²_u |
63.3145 | 63.3149 |
milk σ²_u |
0.018550 | 0.018600 |
Bootstrap MSE is compared against sae::pbmseBHF, where mean agreement across the twelve counties is within 0.4% at 4,000 replicates — the residual being Monte Carlo error rather than bias.
Ecosystem
svy-sae builds on svy, which handles the survey side: design metadata, weighting, direct estimation, and the datasets used above. Pass a svy.Sample and its design travels with your data into the model.
Status
svy-sae is in alpha and pre-1.0. The API may change between minor versions; each release documents what moved in CHANGELOG.md, including any change that alters reported numbers.
Feedback
Issues and discussions: github.com/samplics-org/svy-sae
Small area estimates carry policy weight. svy-sae aims to make the uncertainty around them as defensible as the estimates themselves.
Metadata
Release files for svy-sae 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 15.3 MB
Release files / svy_sae-0.4.0-cp314-cp314-win_amd64.whl
| Download URL | svy_sae-0.4.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f483cc98c5fc19bde1b9224002ea2c327c6b83c147ede51527e2243ad16c7da8
|
|
BLAKE2b-256 checksum How to use checksums |
5821ee51340a61c0d4cf66fc9709b1f6c87b4f8f376850b7c792a4e09924e21b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | svy_sae-0.4.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
27b2d08c31e0504bd7ee448a90a77c05d0032834f949cbce5d3677f6eaaa783e
|
|
BLAKE2b-256 checksum How to use checksums |
ee54168a8ba1bef008ea331874135a3ce66e4522b1374d30a72193979beb0d42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | svy_sae-0.4.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
57d8075df9c7808a2840cd2ce7d8d624f803f3839fb22b3c4b689b3022922d14
|
|
BLAKE2b-256 checksum How to use checksums |
03160ba311756601a4c60d0a63380bc15a7d4593c6c43eae5a76817064395203
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | svy_sae-0.4.0-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0450535daaf7ebb4defbbcee1689917f9c43aa00ecd2fe93e807d5f04bd7c2c0
|
|
BLAKE2b-256 checksum How to use checksums |
9bf0c8bdd28ed611a4ea228ad7b73ed979515edd913d2a8fadb68480c0d1a49e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp313-cp313-win_amd64.whl
| Download URL | svy_sae-0.4.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 950.9 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
083617ca12325977329974e1d373de9f59f02378d72b9a3be6083dbd8878e4a4
|
|
BLAKE2b-256 checksum How to use checksums |
7d78f002b42ebbc0b4f8743ccc10c9b8f56bd4bba889403ada193f58c466209c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | svy_sae-0.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
4966a5651937d6b32d0189100ee08f4532cc1216b88ff927efcf7297352b3d44
|
|
BLAKE2b-256 checksum How to use checksums |
498f5aa630507b766db8e7c9de50971323c0325fc98f200f50632ef1f678f71d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | svy_sae-0.4.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
f0575386beecbddeeb308b47c3e8545cea6fdb63368d47343aa2020a948365ab
|
|
BLAKE2b-256 checksum How to use checksums |
beb3523feced373515187468d282ca0050ea3f1587dfe916dde73c729538968a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | svy_sae-0.4.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5f450d90c613853d0e12b31cad45b8d24daa8d037733566161482adfae5eb747
|
|
BLAKE2b-256 checksum How to use checksums |
af111046f07ac28f777d1b3c01a2aa723a0533a52ff341da27780a67002e4106
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp312-cp312-win_amd64.whl
| Download URL | svy_sae-0.4.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 485.7 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a570f2806962c79644acfdbcaee8a0fbb72ab4f1389c7459038424032627df48
|
|
BLAKE2b-256 checksum How to use checksums |
18e23755ead15f455c05b3d1f087a2efb717d3a37fdad493f9588f76cbab83de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | svy_sae-0.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 807.5 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
29b050a5f46b65f2122952355dcc4988839a96ed8a2367d057720ef0c2952f37
|
|
BLAKE2b-256 checksum How to use checksums |
924fc2d5025d29c6878e927c2ad3b91a624202e7b3a12faf5918edba181f07b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | svy_sae-0.4.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 728.3 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
ff89254dbad4e719b055504ab2b1e0ea5056b142a501db4dd73cf0790d81de4a
|
|
BLAKE2b-256 checksum How to use checksums |
0bdd5fa7a42d924197b45cec9d258607362d9d3fe7fee9db6de30a1f2517c05c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency logRelease files / svy_sae-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | svy_sae-0.4.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 541.5 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8be4aa8fa70007fc987678641317c523dcd42980fee25b202b834a330c737abf
|
|
BLAKE2b-256 checksum How to use checksums |
1759b38d89d9d2f70c1ae905f495ee9390e24235c0a23bd2fcd6a5b557912185
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.
Transparency log