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.1.tar.gz (60.2 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.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyfies-0.1.1.tar.gz
  • Upload date:
  • Size: 60.2 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.1.tar.gz
Algorithm Hash digest
SHA256 b69b7fcdb4e8dde2c8f650ba006b761050b8767bccdcf6da998ffaa4b1921710
MD5 ab2d1c8850aec545c42d21d1ebb8743b
BLAKE2b-256 b4c89f7abe60bb227a8153c7db67868ba0a73616a9f2eabbd165c974b0924191

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfies-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pyfies-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8bcda80adfd5cb619afc09a494005dc265769339388b50b6dd30fd9d38f3d115
MD5 fe3e7b34400610cf5b6900f856b29917
BLAKE2b-256 12289ba36cb261845c0ca2e97a274a25138bc80d001157063b34eca245f79d7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfies-0.1.1-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