Skip to main content

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 saePy

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saepy-0.2.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

saepy-0.2.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file saepy-0.2.0.tar.gz.

File metadata

  • Download URL: saepy-0.2.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for saepy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3bf20c4f8341bbbe3143b2379305c9f2ca2feeb633b2170ff30d4c2a215fe8ed
MD5 53d7d9cf6108029ca311997358e1cb1a
BLAKE2b-256 ae90d708825efd9fce50dbee0013f2d599430108b54a4f8e7b877900a1ea998c

See more details on using hashes here.

File details

Details for the file saepy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: saepy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for saepy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4c4bff9cfc5b1f07694fae4ead19098011fb60fe7ad1b27c843e43d97bcf289
MD5 3e6c7e103f9be6799b037f96ed4116d0
BLAKE2b-256 52d1e29484585d879c5c3056f89b01093439fd88e14cd295bb4e35ef55558746

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page