Skip to main content

svy-sae

Small area estimation at census scale, in Python.

PyPI 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_sae costs 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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for svy-sae 0.4.1
File
svy_sae-0.4.1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
svy_sae-0.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
svy_sae-0.4.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ ARM64, Linux glibc 2.17+ ARM64 Details
svy_sae-0.4.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
svy_sae-0.4.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
svy_sae-0.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
svy_sae-0.4.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
svy_sae-0.4.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
svy_sae-0.4.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
svy_sae-0.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
svy_sae-0.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
svy_sae-0.4.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details

Total release size: 15.5 MB

Release files / svy_sae-0.4.1-cp314-cp314-win_amd64.whl

Download URL svy_sae-0.4.1-cp314-cp314-win_amd64.whl
Size 1.5 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
7b3f03e515463114149ce7769af4c22c8ebec556a1afc394e6ec7c633301348a
BLAKE2b-256 checksum
How to use checksums
a60b679c09ca1c2ea2232f7286af19458fa6ef888b65ee1803102fc77f752a46
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL svy_sae-0.4.1-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
cc7cb6c192fabb484ebcc68b2d2025450026e585fa434eeefc9a23e7653b1486
BLAKE2b-256 checksum
How to use checksums
f8bc9288821bd4c23e4ae263f6ed9dac0966f41f73b0acddbf472677a8c8a1ba
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL svy_sae-0.4.1-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
f7c2c284b20e331b8f13153ed505f4c52a61bdf1e82398a7afe6b49ababdbf15
BLAKE2b-256 checksum
How to use checksums
7fba30f23edfa5859d2981beb0854d748609b6d7dd0de20072b0b293b8af4d2a
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp314-cp314-macosx_11_0_arm64.whl

Download URL svy_sae-0.4.1-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
4d41e1e74bd0b0e395a35090cf6c2f0a0348730202ada88c0d540cb1c0dbc1de
BLAKE2b-256 checksum
How to use checksums
63aa1b2dad03554ee99ba03fc9187dc0feb58664f56e8503e249c95e280a9e74
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp313-cp313-win_amd64.whl

Download URL svy_sae-0.4.1-cp313-cp313-win_amd64.whl
Size 960.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
c26ef075a134c189535306b69e594b442e4bf704fa88f7e44dbd81f30aa65569
BLAKE2b-256 checksum
How to use checksums
1f7de7f838de364c3d7493484141b218d760425182e6924a274946ecf15373fc
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL svy_sae-0.4.1-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
9138c55171ced3b7dff27dcb0138c36377bfdc9c4ee8bdb85f70d1303ab67896
BLAKE2b-256 checksum
How to use checksums
5cd91eaf789f307a78905eeec49d303c4ef0c059ccb7f75ed3da4cfc0b882bd0
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL svy_sae-0.4.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 1.5 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
b23e8a53eabd1e7e579d9e62a292bdd12840c148d02d3f0ed72c3b7922bee63c
BLAKE2b-256 checksum
How to use checksums
0c88b6542b5391c771d3f05e77d76b171c43fe3a55881fe22feb79b29cef9e60
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL svy_sae-0.4.1-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
90a27669c4eefd66394318b535ff220d153ae4ebf719586a384a0be7e1bff9f6
BLAKE2b-256 checksum
How to use checksums
57b258445eb489258eb72cf0e15fc89a8ca5a22dfd034d7bfaf29ad5f52399c8
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp312-cp312-win_amd64.whl

Download URL svy_sae-0.4.1-cp312-cp312-win_amd64.whl
Size 491.4 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
bc00015e402e5ee69cffad7f1273771a0f870f25d748f640a3f8dde80317d619
BLAKE2b-256 checksum
How to use checksums
f5227693ac366dc9900d120a6c1e170335fb2bb5dd1a73066882468caccd33a7
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL svy_sae-0.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 815.7 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
95c0555cc03278f623278d7ae5fa4fa7faf6e9e78bc6499b971521f4af9145f5
BLAKE2b-256 checksum
How to use checksums
26709c0527aa6473c274f620a0183aa5de0d4652babcc4fd2dbfa6b6f02820ef
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL svy_sae-0.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 734.9 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
e4aca53bb16b755a0eb35e8a64bf8d66086eb73eddb310043509445c83c0b25d
BLAKE2b-256 checksum
How to use checksums
dfcf49aa1353922f6f5174fafdbd31fdf5147e386eca3da4ea02925bab9e1a4f
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 Oct 9, 2026.

Transparency log

Release files / svy_sae-0.4.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL svy_sae-0.4.1-cp312-cp312-macosx_11_0_arm64.whl
Size 547.4 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a83ca9fb99ea2373a83230f64928a4934423d2c0d7e8afc6bd4d673578cbb370
BLAKE2b-256 checksum
How to use checksums
538a267ecab2eba5966a3d1486d60360adfacd887b0fd117540ef228dd9e2dca
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 Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

12 release files

0.4.0

12 release files

0.3.0

12 release files

0.2.0

12 release files

0.1.0

5 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page