📘 MPIToolbox User Guide
Attribution
This work builds upon code originally developed by Nicolai Suppa (2022), licensed under the MIT License.
This guide introduces the MPIToolbox Python class, designed to estimate, compare, and summarize multidimensional poverty indices (MPI) using flexible specifications.
📚 Additional Resources
👉 See the MPI Results Utilities Guide
🔧 Initialization
from mpitb.core import MPIToolbox
mpi = MPIToolbox()
🗂️ 1. Define Specifications
mpi.set(
name="trial01",
description="Preferred trial specification",
dimensions=[
(["d_cm", "d_nutr"], "hl"),
(["d_satt", "d_educ"], "ed"),
(["d_elct", "d_wtr", "d_sani", "d_hsg", "d_ckfl", "d_asst"], "ls")
],
replace=True
)
name: Unique name for the specificationdimensions: A list of (indicators, dimension name)replace=True: Overwrite existing spec
⚖️ 2. Set Weights
mpi.setwgts("trial01", "health50", dimw=[0.5, 0.25, 0.25])
mpi.setwgts("trial01", "ind_equal", indw=[0.1]*10)
You can define:
- Dimension-level weights (
dimw) - Indicator-level weights (
indw)
📏 3. Estimate MPI
mpi.est(
df=df,
name="trial01",
klist=[33],
weights="equal",
svy=True,
lframe="myresults",
over=["region", "area"]
)
Output:
- Estimation records are stored in
mpi.results["myresults"] - Use
replace=Trueto overwrite an existing frame
📊 4. Change-over-Time Estimation
mpi.est_cot(
df=df,
name="trial01",
yearvar="t",
klist=[33],
cotmeasures=["M0", "H", "A", "hd", "hdk"],
wgts="equal",
cotframe="mycot",
replace=True,
raw=True,
ann=True,
total=True,
insequence=False,
svy=True
)
cotmeasures: includeM0,H,A, and optionalhd,hdkrawandann: toggle raw/annual changetotalorinsequence: whether to compute period vs. year-to-year changes
📁 5. Extract and Summarize Results
Use functions from mpi_results_utils.py (see companion guide):
from mpi_results_utils import extract_core_measures, extract_cot_summary, pivot_cot_summary
summary = extract_core_measures(df_myresults)
cot_table = extract_cot_summary(mpi.results, "mycot", measure="H", k=[33])
pivot = pivot_cot_summary(mpi.results, "mycot", measure=["H", "M0"], k=[33, 50])
📌 6. Store Custom Results
mpi.stores(
frame="myresults",
loa="nat",
measure="M0",
spec="trial01",
k=33,
estimate=0.115,
ts=True
)
You can manually add structured metadata to mpi.results["myresults"].
🛠️ Other Tools
mpi.svyset(...): Define survey weight/PSU/stratum variables.mpi.get_equal_weights(name): View equal weighting structure.mpi.show(name): Print full spec summary.mpi.rframe(...): Register a new result frame structure.
🧪 Example Quick Start
mpi = MPIToolbox()
mpi.svyset(psu="psu", weight="weight", strata="stratum")
mpi.set(name="trial01", description="baseline", dimensions=[
(["d_cm", "d_nutr"], "hl"),
(["d_satt", "d_educ"], "ed"),
(["d_elct", "d_wtr", "d_sani", "d_hsg", "d_ckfl", "d_asst"], "ls")
])
mpi.setwgts("trial01", "equal", dimw=[1/3, 1/3, 1/3])
mpi.est(df=df, name="trial01", klist=[33], weights="equal", svy=True, lframe="results")
Metadata
Release files for mpitb 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mpitb-0.2.tar.gz | 12.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mpitb-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.0 kB
Release files / mpitb-0.2.tar.gz
| Download URL | mpitb-0.2.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11ac446871eeefd4212baf906462cfbdceb4f58d39a88aabee070d595398f69c
|
|
BLAKE2b-256 checksum How to use checksums |
3629f0de4ded0989661574aa1fcac013eb8895ce934be72fb480826bfda6194e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Release files / mpitb-0.2-py3-none-any.whl
| Download URL | mpitb-0.2-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14b0aca557764fb907fb42ea2e86c1df076f5d0a9b01c942709544c9cb93a29a
|
|
BLAKE2b-256 checksum How to use checksums |
d3987dff718118189cbd9d7644e8315796d06d962c534cf5bcbc03fcc735ea30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|