Install svy-sae and learn how its core objects fit together
Getting Started
Installation
Python
Install svy-sae for small area estimation in Python and learn its object model: a model class over a data frame, a fit method per estimator, and a results object with tables, diagnostics, and plots.
Author
Mamadou S. Diallo, Ph.D.
Modified
November 8, 2026
Keywords
install svy-sae, small area estimation Python setup, svy-sae getting started, Fay-Herriot EBLUP EBP Python
This page gets svy-sae installed and gives you a mental model of the library: two model classes, a fit method per estimator, and one results object for all of them. Once the model clicks, the tutorials are deeper dives into each piece.
svy-sae installs svy with it. Optional extras add features:
Table 1: Optional extras
Install
Adds
"svy-sae[spatial]"
Neighbours from polygons for spatial models (ContiguityProx), through polars-st
"svy[remote]"
The online dataset catalog that the tutorials load their data from
The examples in these docs load their data with svy.datasets, so install both:
pip install svy-sae "svy[remote]"
System requirements:
Python 3.12, 3.13, or 3.14
Linux, macOS (Apple silicon), and Windows
For virtual environments and uv projects, see the full Installation guide.
The svy-sae Object Model
Every workflow follows the same three moves:
Wrap the data in a model class: AreaLevel for one row per area, UnitLevel for one row per sampled unit.
Fit an estimator with a method of the class, naming the columns it uses.
Read the results from the SAEResults it returns.
import svyimport svy_sae as saemilk = svy.datasets.load("milk").data# 1. Wrap the data: one row per areamodel = sae.AreaLevel(milk)# 2. Fit an estimatorfit = model.fh( y="yi", x=svy.Cat("MajorArea", ref=1), variance="variance", area="SmallArea",)# 3. Read the resultsprint(fit.stats)
The data stay as they are: each fit names its outcome, covariates, and area column, so one model object serves several fits. Covariates are column names, or svy.Cat(...) for a categorical one.
The estimators
Table 2: Model classes and their estimators
Class
Method
Fits
Learn more
AreaLevel
fh()
Fay–Herriot, with transformations and benchmarking; spatial or temporal effects through random=
sae.smooth_variance() prepares the sampling variances for fh(): see Smoothing variances. Options that take more than a value are small objects passed to the fit: sae.Benchmark(...), sae.LogTransform() and the other transformations, sae.SAR(...) and sae.AR1() for the area effects, and sae.Indicator for the EBP indicators.
Everything hangs off the results
fh(), eblup(), and ebp() all return an SAEResults:
Table 3: Accessing an SAEResults
Access
What it gives
Learn more
print(fit)
Summary: fit statistics, coefficients, variance components, findings
fit.to_polars(...)
Each part as a polars DataFrame: "predictions", "fixed", "components", "diagnostics", "tests", "findings", …
sae.compare(fit_a, fit_b, ...) puts fits side by side, one row each, and AreaLevel.influence() refits a Fay–Herriot model without each influential area: see Checking the model.
svy-sae fits models; svy handles the survey. Area-level models take direct estimates and their design-based variances, which svy computes from the survey and its design: see Preparing inputs. The example datasets come from svy.datasets.
The first fit on a machine
The model kernels compile on their first use and are cached to disk, so the first fit of a given data shape on a machine takes a few extra seconds, and later fits skip it. svy_sae.warmup() pays that cost ahead of time: see Installation.
Ready to Explore?
Take the five-minute quick tour, then the step-by-step tutorials.