Transformed Fay–Herriot Models in Python with svy-sae
Log, arcsine, and logit transformations with back-transformed estimates
Tutorials
Area-level
Transformations
Python
Fit Fay-Herriot small area models on a transformed scale in Python with svy-sae: log for skewed outcomes, arcsine and logit for proportions, back-transformations, and Slud-Maiti or bootstrap MSE on the original scale.
Author
Mamadou S. Diallo, Ph.D.
Modified
November 5, 2026
Keywords
transformed Fay-Herriot model, log transformation small area estimation, arcsine transformation proportions, Slud-Maiti MSE, back-transformation bias correction
WarningAbout these examples
This tutorial illustrates the svy-sae API; it is not a rigorous small area analysis. The models are kept simple so each step stays readable, and in many places, from the choice of covariates to the variance model, better choices could be made to improve them.
The Fay–Herriot model assumes normal area effects and sampling errors on the scale of the direct estimates. Skewed outcomes such as expenditure or income break that assumption, and so can proportions, which are bounded by 0 and 1. Fitting the model on a transformed scale, where the assumptions hold better, and transforming the estimates back is the usual remedy.
fh() does both steps: it moves the direct estimates and their sampling variances to the model scale, fits there, and returns estimates and MSEs on the original scale.
This tutorial demonstrates the log transformation on district mean expenditure, the choice of back-transformation and MSE, and the arcsine and logit transformations for proportions, applied to the district poverty rates.
NoteNot a search for the best model
This tutorial does not try to find the best model for these data. It shows the options svy-sae offers to evaluate a model and the ways to improve it; the choices made below are examples, not recommendations.
Setting up the inputs
We use the same survey, districts, and census as the previous tutorials:
The normality findings are gone. The model is fitted to the log of the direct estimates, with sampling variances \(D_i / \hat\theta_i^2\) by the delta method, and the estimates and MSEs come back in currency units:
The per-district diagnostics keep both scales: the direct estimate and variance on the original scale, and on the model scale with a _t suffix.
Mobile phone ownership was chosen on the log scale: stepwise() takes the same transformation= argument as fh() and compares the candidates on that scale.
Back-transformation
Transforming the model-scale estimate back with \(\exp\) gives the median, not the mean, of the district’s expenditure given the data. The backtransform option of LogTransform sets how to return to the original scale:
Table 1: Back-transformations for LogTransform
backtransform
Estimate
MSE
"bc"(default)
\(\exp(\tilde\theta_i + s^2_i / 2)\), the mean given the data
The correction is small here because the log-scale variances are small.
Analytical MSE
The Slud–Maiti MSE of the bias-corrected estimate needs ML estimation, and covers sampled areas only. Fit the sampled districts by ML without pop_data, so the covariate must be in the frame of direct estimates:
Here the two disagree, and the bootstrap is the closer to the actual squared error. The Slud–Maiti MSE is a second-order approximation, and its term for the uncertainty of \(\hat\sigma^2_u\) is large when \(\hat\sigma^2_u\) is poorly determined, as here:
Both models cut the error of the direct estimates by about three quarters. On the original scale, the error is slightly lower, but the model’s assumptions fail and its MSE is three times the actual squared error. On the log scale, the assumptions hold and the MSE is close to the actual error: the uncertainty the model reports can be trusted.
Proportions
Poverty rates are bounded by 0 and 1, and their sampling variance depends on the rate itself. Two transformations address that: the arcsine of the square root, which stabilizes the variance, and the logit, which maps \((0, 1)\) to the whole line.
Two districts have a direct poverty rate of 0, which the logit cannot take:
❌ Direct estimates outside the transformation's domain [MODEL_ERROR]
The logit needs direct estimates strictly between 0 and 1; areas ['geo_09_01', 'geo_10_01'] are not.
Hint: ArcsinTransform(eff_size=...) takes estimates of 0 and 1.
Docs: https://svylab.com/docs/svy/reference/codes.html#model-error
The arcsine takes 0 and 1, but its delta-method variance is undefined there. ArcsinTransform(eff_size=...) replaces it with \(1/(4\tilde n)\), from a column of effective sample sizes \(\tilde n = n / \text{deff}\). A district with no poor household has no design effect of its own, so use the national one:
For these rates the arcsine does not help. The area variance stays at the boundary, as in The Fay–Herriot model, and only the bootstrap MSE exists for the arcsine, which understates the MSE at the boundary: its intervals miss the truth far more often. The untransformed model, with its analytical MSE, remains the better choice for the poverty rates.
TipWhen to transform
Transform when the checks of the untransformed model fail in a way the transformation addresses, such as skewed residuals, and check that they pass afterwards. A transformation is a change of model, not a refinement that is always worth making.
Summary
This tutorial fitted the Fay–Herriot model on transformed scales:
Log for a skewed outcome: transformation="log" fixes the normality findings, and its MSE matches the actual error
Back-transformations: "bc" for the mean given the data, "naive" for the median, "crude" with the analytical MSE
MSE: Slud–Maiti for the log with ML on sampled areas, which overstates when \(\hat\sigma^2_u\) is poorly determined; otherwise the bootstrap
Proportions: the logit needs rates strictly between 0 and 1; the arcsine takes 0 and 1 with eff_size=
When not to: for the poverty rates, the untransformed model is better
Next steps
The district estimates are final. Regional figures already published from the survey may need to agree with them.
Slud, Eric V., and Tapabrata Maiti. 2006. “Mean-Squared Error Estimation in Transformed Fay-Herriot Models.”Journal of the Royal Statistical Society: Series B 68 (2): 239–57.