Small Area Estimation Python package
Project description
saePy
saePy is a Python package for Small Area Estimation (SAE) implementing the EBLUP Fay-Herriot (FH), Nested Error Regression (BHF), and spatial Fay-Herriot (SFH) models. It also provides functions for estimating Mean Squared Error (MSE) and parametric bootstrap MSE for these models.
Features
- EBLUP Fay-Herriot (FH): Area-level small area estimation.
- EBLUP Nested Error Regression (BHF): Unit-level small area estimation.
- EBLUP Spatial Fay-Herriot (SFH): Area-level model with spatial correlation.
- MSE Estimation: Functions to estimate the mean squared error for FH and SFH models.
- Parametric Bootstrap MSE for BHF: Bootstrap-based MSE estimation for the BHF model.
- Example Datasets: Several example datasets are included in the
saePy/directory.
Installation
Make sure you have the following dependencies installed:
- numpy
- scipy
- pandas
- patsy
- statsmodels
Install the package using:
pip install .
or
python setup.py install
Directory Structure
saePy/
__init__.py
eblupBHF.py
eblupFH.py
eblupSFH.py
mseFH.py
mseSFH.py
pbmseBHF.py
dataset_1.csv
grapes.csv
grapesprox.csv
unit_level_1.csv
Usage
EBLUP Fay-Herriot
from saePy.eblupFH import eblupFH
import pandas as pd
data = pd.read_csv("saePy/dataset_1.csv")
result = eblupFH(
formula="y ~ x1 + x2",
vardir_col="vardir",
data=data
)
print(result)
EBLUP BHF (Unit Level)
from saePy.eblupBHF import eblupBHF
result = eblupBHF(
formula="y ~ x1 + x2",
dom="domain",
selectdom=[...], # list of domains to estimate
meanxpop=..., # population mean matrix
popnsize=..., # population size per domain
data=data
)
print(result)
MSE Estimation
from saePy.mseFH import mseFH
result = mseFH(
formula="y ~ x1 + x2",
vardir_col="vardir",
data=data
)
print(result)
Parametric Bootstrap MSE for BHF
from saePy.pbmseBHF import pbmseBHF
result = pbmseBHF(
formula="y ~ x1 + x2",
dom="domain",
selectdom=[...],
meanxpop=...,
popnsize=...,
data=data
)
print(result)
License
MIT License
Note:
- Ensure your data columns match the function arguments.
- For more details, see the documentation in each module in saePy/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file saepy-0.1.tar.gz.
File metadata
- Download URL: saepy-0.1.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f12d4abc6065ff5caab484f0f11266973743a4051d36bed8dbf4eb822ceb6de
|
|
| MD5 |
e8d598a3e39b80dd3be4c4eca43bf229
|
|
| BLAKE2b-256 |
1cd1d537fd5a432b61050c1d2ac72c7913d7ca61cfb7ee6a2784a94d77756b15
|
File details
Details for the file saepy-0.1-py3-none-any.whl.
File metadata
- Download URL: saepy-0.1-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a05b4d6d69fc6f6979432ed4b3401f7c977574fdc649cfd441f8be391ad0a59a
|
|
| MD5 |
2647e553fc13a5367580cdc69e5eeb99
|
|
| BLAKE2b-256 |
88e83eebb48619d0d91da945b48d5976950439d00b2f98c36f3af8daf5e46eae
|