fastsae provides a high-performance, unified framework for Small
Area Estimation (SAE) in R. It combines ultra-fast compiled C++
(RcppArmadillo + OpenMP) for frequentist EBLUP models with INLA
(Integrated Nested Laplace Approximations) for fast Bayesian
hierarchical models—achieving 50× to 6,400× speedups over classical
packages (sae, emdi) and >230× speedups over MCMC (tipsae),
with near-zero memory footprint and exact numerical equivalence.
- ⚡ Blazing Fast: Optimized C++ Fisher-scoring and deterministic INLA Laplace approximations turn minutes of runtime into milliseconds.
- 🎯 Exact Concordance: Frequentist estimates match
saeto machine tolerance; Bayesian posteriors match Stan HMC ($r = 0.989$ ). - 🔀 Unified Interface: Common S3 workflow (
summary,coef,fitted,residuals,autoplot,compare_sae) for both paradigms. - 🧵 Multi-Threaded Bootstrap: OpenMP-accelerated parametric and non-parametric bootstrap MSE.
- 🗺️ Comprehensive Spatial & Temporal: SAR, Besag ICAR, BYM2, Spatial Lag, AR(1), and RW(1/2).
- 💾 Ultra-Low Memory: Avoids large dense matrix allocations,
scaling effortlessly to
$n > 10,000$ domains.
| Function | Model Level | Structure | MSE Estimation |
|---|---|---|---|
eblup_fh() |
Area-level | Standard Fay-Herriot with IID domain effects | Analytical (Prasad-Rao) |
eblup_sfh() |
Area-level | Spatial SAR(1) autoregressive effects | Analytical, Bootstrap |
eblup_stfh() |
Area-level | Spatio-temporal SAR(1) + AR(1) dynamics | Bootstrap |
eblup_bhf() |
Unit-level | Battese-Harter-Fuller nested error regression | Analytical, Bootstrap |
| Function | Model Level | Distributions | Random Effects |
|---|---|---|---|
hb_area() |
Area-level | Gaussian, Beta, Binomial, Poisson, NegBin, Gamma | IID, BYM2, Besag ICAR, RW(1/2), AR(1) |
hb_unit() |
Unit-level | Gaussian | Unit-level nested error |
| Task | fastsae |
sae (Molina & Marhuenda) |
emdi |
|---|---|---|---|
| Standard Fay-Herriot | 0.291 s (~190x slower) | 9.64 s (~6,400x slower) | |
| Spatial Fay-Herriot | 12.60 s (~76x slower) | 8.69 s (~53x slower) | |
| Peak RAM Usage | ~400 MB | ~800 MB |
| Model Specification |
fastsae::hb_area (INLA) |
tipsae::fit_sae (Stan HMC) |
Speedup & Efficiency |
|---|---|---|---|
| Standard Beta | 187.16 s (18.3 GB) | ||
| Spatial Beta (Besag ICAR) | 412.39 s (22.9 GB) | ||
| Concordance vs MCMC | Baseline |
Install from CRAN:
install.packages("fastsae")Or install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("ridsonap/fastsae")To enable Bayesian models, install INLA:
install.packages(
"INLA",
repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"),
dep = TRUE
)library(fastsae)
# 1. Frequentist Fay-Herriot (C++)
fit_fh <- eblup_fh(y ~ x1 + x2 + x3, vardir = ~vardir, data = na.omit(mys))
summary(fit_fh)
# 2. Diagnostic & Visualization
autoplot(fit_fh, type = "estimates")Explore comprehensive guides, mathematical formulations, and worked examples:
👉 https://ridsonap.github.io/fastsae/
- Getting Started with fastsae
- Spatial & Spatio-Temporal Models
- Bayesian Area-Level Models via INLA
- Model Diagnostics & Calibration
- Interactive Benchmarks
citation("fastsae")Bug reports and feature requests are welcome on the issue tracker.
