Skip to main content

Python implementation of FAO's Food Insecurity Experience Scale (FIES) — weighted Rasch model, equating to the global standard, and prevalence estimation for SDG indicator 2.1.2.

Project description

pyFIES

Python implementation of FAO's Food Insecurity Experience Scale (FIES) — the methodology behind UN SDG indicator 2.1.2 (prevalence of moderate-or-severe and severe food insecurity in the population).

pyfies is a from-scratch port of the R package RM.weights (Cafiero, Viviani, Nord), implementing the weighted Conditional Maximum Likelihood (CML) Rasch estimator, equating to FAO's 2014–2016 global standard, and probabilistic prevalence assignment along the latent food-insecurity trait.

Status: alpha. v0.1 covers the dichotomous Rasch model, equating, and prevalence estimation. The polytomous (partial credit) extension and full diagnostics suite are planned for v0.2.

Installation

pip install pyfies          # from PyPI (once published)
pip install -e ".[dev]"     # editable install with dev tooling

Requires Python 3.11+.

Quickstart

import pandas as pd
from pyfies import RaschModel, FAO_2014_2016, DEFAULT_FIES_ITEMS

# df has 8 columns named WORRIED, HEALTHY, FEWFOOD, SKIPPED,
# ATELESS, RUNOUT, HUNGRY, WHLDAY (1=affirmative, 0=negative, NA=missing)
X = df[DEFAULT_FIES_ITEMS].to_numpy()
w = df["sampling_weight"].to_numpy()

model = RaschModel().fit(X, sample_weight=w)
model.equate(reference=FAO_2014_2016)
result = model.prevalence()

print(f"Moderate or severe food insecurity: {result.moderate_or_severe:.1%}")
print(f"Severe food insecurity:             {result.severe:.1%}")

What it computes

  1. Item severity parameters for each FIES question via weighted CML.
  2. Person parameters per raw score (post-hoc MLE conditional on item parameters).
  3. Equating to the FAO 2014–2016 global metric so prevalence rates are comparable across countries and survey rounds.
  4. Prevalence rates at any latent-trait threshold via Gaussian-mixture probabilistic assignment.

Methodology references

Numerical parity with RM.weights

pyFIES is validated against the reference R package on the data.FAO_country1..4 sample datasets shipped with RM.weights. To regenerate parity fixtures (R required, one-time):

Rscript scripts/generate_r_fixtures.R

Default tolerance: atol=1e-6 on item severities and prevalence rates.

Citing

If you use pyFIES in published research, please cite both this package and the underlying FAO methodology (Cafiero et al., 2018). A CITATION.cff file will be added at first stable release.

License

Apache 2.0.

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

pyfies-0.1.0.tar.gz (60.1 kB view details)

Uploaded Source

Built Distribution

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

pyfies-0.1.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file pyfies-0.1.0.tar.gz.

File metadata

  • Download URL: pyfies-0.1.0.tar.gz
  • Upload date:
  • Size: 60.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyfies-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3bee941d345d6229da0bcad38398faaa47e1e37d5c9ce13fd978288290a13df5
MD5 fb1813ea3afc3a15b67d355c626a515d
BLAKE2b-256 3dd3e11e0206b71332d6dc19f0f7454d9b3c0a49d530f664c4c34c1cedbe1540

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfies-0.1.0.tar.gz:

Publisher: release.yml on nejohnson2/pyFIES

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfies-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyfies-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyfies-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a1d5f04bdcd9a37c182321f43c5989deb6af5706019ea9304c62ea144728430
MD5 54ce347f6ff5d429e6cf17428bad8fc5
BLAKE2b-256 5284f34ca6fd5fe8a00554c65626c50e5daf96542e9bd668af2b30388d746347

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfies-0.1.0-py3-none-any.whl:

Publisher: release.yml on nejohnson2/pyFIES

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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