| Title: | Multidimensional Poverty Index (MPI) via the Alkire-Foster Method |
|---|---|
| Description: | Estimate Multidimensional Poverty Index (MPI) measures from household survey microdata using the Alkire-Foster dual-cutoff counting method (Alkire and Foster, 2011, <doi:10.1016/j.jpubeco.2010.11.006>). Load indicator specifications from CSV, Excel, JSON, or plain-text files; compute the headcount ratio (H), intensity (A), and MPI = H x A across any subgroup; and export results to formatted Excel reports. Supports complex survey designs — stratification, clustering, and probability weights — and optionally appends design-based standard errors and confidence intervals. |
| Authors: | Bhas Abdulsamad [aut, cre, cph]
|
| Maintainer: | Bhas Abdulsamad <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0 |
| Built: | 2026-06-08 05:45:45 UTC |
| Source: | https://github.com/yng-me/mpindex |
The primary single-call API for computing the MPI using the
Alkire-Foster (AF) counting method. Deprivation cutoffs are specified inline
using the deprived helper, making the workflow
self-contained and readable.
For a step-by-step workflow using a pre-assembled deprivation profile, see
compute_mpi_from_profile.
compute_mpi( .data, mpi_specs, deprivations, ..., by = NULL, include_deprivation_matrix = TRUE, generate_output = FALSE, mpi_output_filename = NULL, include_specs = FALSE, weight = NULL, strata = NULL, cluster = NULL, fpc = NULL, survey_design = NULL, inference = FALSE, ci_level = 0.95 )compute_mpi( .data, mpi_specs, deprivations, ..., by = NULL, include_deprivation_matrix = TRUE, generate_output = FALSE, mpi_output_filename = NULL, include_specs = FALSE, weight = NULL, strata = NULL, cluster = NULL, fpc = NULL, survey_design = NULL, inference = FALSE, ci_level = 0.95 )
.data |
A data frame where each row is the unit of analysis. |
mpi_specs |
MPI specifications from |
deprivations |
A named list of |
... |
Grouping columns (tidyselect) or reserved for old-name detection. |
by |
(Optional) Columns to group results by, passed as a
tidyselect expression, e.g. |
include_deprivation_matrix |
Whether to include deprivation matrices.
Default |
generate_output |
Whether to write an Excel file as a side effect.
Default |
mpi_output_filename |
Output filename when |
include_specs |
Whether to include MPI specification sheet in Excel output. |
weight |
Name of the sampling-weight column in |
strata |
Name of the stratum column in |
cluster |
Name of the cluster / PSU column in |
fpc |
Name of the finite-population correction column in |
survey_design |
A pre-built |
inference |
Logical. When |
ci_level |
Confidence level for intervals. Default |
A named list of class mpi_output with components:
$indexNamed list keyed by k_*: MPI, H, A, n.
$contributionNamed list keyed by k_*: contribution by indicator/dimension.
$headcount_ratioNamed list with uncensored and per-k_* censored ratios.
$deprivation_matrixNamed list with uncensored and per-k_* matrices.
Alkire-Foster Method
How to Apply the Alkire-Foster Method
define_mpi_specs, deprived, compute_mpi_from_profile, save_mpi
specs <- define_mpi_specs( system.file("extdata", "global-mpi-specs.csv", package = "mpindex"), uid = "uuid" ) ## Not run: mpi_result <- compute_mpi( df_household, mpi_specs = specs, deprivations = list( nutrition = deprived( undernourished == 1 & age < 70, .data = df_household_roster, collapse_fn = max ), child_mortality = deprived(with_child_died == 1), year_schooling = deprived( completed_6yrs_schooling == 2, .data = df_household_roster, collapse_fn = max ), school_attendance = deprived( attending_school == 2 & age %in% c(5:24), .data = df_household_roster, collapse_fn = max ), cooking_fuel = deprived(cooking_fuel %in% c(4:6, 9)), sanitation = deprived(toilet > 1), drinking_water = deprived(drinking_water == 2), electricity = deprived(electricity == 2), housing = deprived( roof %in% c(5, 7, 9) | walls %in% c(5, 8, 9, 99) == 2 | floor %in% c(5, 6, 9) ), assets = deprived(!( (asset_tv + asset_telephone + asset_mobile_phone + asset_computer + asset_animal_cart + asset_bicycle + asset_motorcycle + asset_refrigerator) > 1 & (asset_car + asset_truck) > 0 )) ) ) ## End(Not run)specs <- define_mpi_specs( system.file("extdata", "global-mpi-specs.csv", package = "mpindex"), uid = "uuid" ) ## Not run: mpi_result <- compute_mpi( df_household, mpi_specs = specs, deprivations = list( nutrition = deprived( undernourished == 1 & age < 70, .data = df_household_roster, collapse_fn = max ), child_mortality = deprived(with_child_died == 1), year_schooling = deprived( completed_6yrs_schooling == 2, .data = df_household_roster, collapse_fn = max ), school_attendance = deprived( attending_school == 2 & age %in% c(5:24), .data = df_household_roster, collapse_fn = max ), cooking_fuel = deprived(cooking_fuel %in% c(4:6, 9)), sanitation = deprived(toilet > 1), drinking_water = deprived(drinking_water == 2), electricity = deprived(electricity == 2), housing = deprived( roof %in% c(5, 7, 9) | walls %in% c(5, 8, 9, 99) == 2 | floor %in% c(5, 6, 9) ), assets = deprived(!( (asset_tv + asset_telephone + asset_mobile_phone + asset_computer + asset_animal_cart + asset_bicycle + asset_motorcycle + asset_refrigerator) > 1 & (asset_car + asset_truck) > 0 )) ) ) ## End(Not run)
Computes the Multidimensional Poverty Index using a
pre-assembled deprivation profile — a named list produced by calling
define_deprivation once per indicator.
This is the lower-level entry point. For a single-call workflow with inline
cutoff expressions, use compute_mpi with
deprived.
compute_mpi_from_profile( .data, deprivation_profile, ..., mpi_specs = NULL, include_deprivation_matrix = TRUE, generate_output = FALSE, mpi_output_filename = NULL, include_specs = FALSE, weight = NULL, strata = NULL, cluster = NULL, fpc = NULL, survey_design = NULL, inference = FALSE, ci_level = 0.95 )compute_mpi_from_profile( .data, deprivation_profile, ..., mpi_specs = NULL, include_deprivation_matrix = TRUE, generate_output = FALSE, mpi_output_filename = NULL, include_specs = FALSE, weight = NULL, strata = NULL, cluster = NULL, fpc = NULL, survey_design = NULL, inference = FALSE, ci_level = 0.95 )
.data |
A tidy data frame where each row is the unit of analysis. |
deprivation_profile |
A named list of data frames produced by
|
... |
Grouping columns (tidyselect), e.g. |
mpi_specs |
MPI specifications from |
include_deprivation_matrix |
Whether to include deprivation matrices
in the output. Default |
generate_output |
Whether to write an Excel file as a side effect.
Default |
mpi_output_filename |
Output filename when |
include_specs |
Whether to include MPI specification sheet in Excel output. |
weight |
Name of the sampling-weight column in |
strata |
Name of the stratum column in |
cluster |
Name of the cluster / PSU column in |
fpc |
Name of the finite-population correction column in |
survey_design |
A pre-built |
inference |
Logical. When |
ci_level |
Confidence level for intervals. Default |
A named list of class mpi_output with components:
$indexNamed list keyed by k_*: MPI, H, A, n.
$contributionNamed list keyed by k_*: contribution by indicator/dimension.
$headcount_ratioNamed list with uncensored and per-k_* censored ratios.
$deprivation_matrixNamed list with uncensored and per-k_* matrices.
define_mpi_specs, define_deprivation, compute_mpi, save_mpi
specs <- define_mpi_specs( system.file("extdata", "global-mpi-specs.csv", package = "mpindex"), uid = "uuid" ) deprivation_profile <- list() deprivation_profile$drinking_water <- df_household |> define_deprivation( indicator = drinking_water, cutoff = drinking_water == 2, mpi_specs = specs ) # ... (define remaining indicators) ... ## Not run: mpi_result <- compute_mpi_from_profile( df_household, deprivation_profile, mpi_specs = specs ) ## End(Not run)specs <- define_mpi_specs( system.file("extdata", "global-mpi-specs.csv", package = "mpindex"), uid = "uuid" ) deprivation_profile <- list() deprivation_profile$drinking_water <- df_household |> define_deprivation( indicator = drinking_water, cutoff = drinking_water == 2, mpi_specs = specs ) # ... (define remaining indicators) ... ## Not run: mpi_result <- compute_mpi_from_profile( df_household, deprivation_profile, mpi_specs = specs ) ## End(Not run)
Sets a deprivation cutoff for a single indicator. For each
unit of analysis, the result is 0 (not deprived), 1
(deprived), or NA (missing). An additional weighted column
(indicator value × weight) is also computed.
define_deprivation( .data, indicator, cutoff, mpi_specs = NULL, collapse_fn = NULL, set_na_equal_to = 0, ... )define_deprivation( .data, indicator, cutoff, mpi_specs = NULL, collapse_fn = NULL, set_na_equal_to = 0, ... )
.data |
A data frame or tibble. |
indicator |
Name of the indicator as defined in the MPI Specs (must
exactly match the |
cutoff |
A logical expression that evaluates to |
mpi_specs |
MPI specifications from |
collapse_fn |
An optional function to collapse roster-level data to
the unit-of-analysis level (e.g. |
set_na_equal_to |
Coerce |
... |
Reserved; passing old dotted names triggers a helpful error. |
A data frame with columns *_unweighted and *_weighted.
How to Apply the Alkire-Foster Method
specs_file <- system.file( "extdata", "global-mpi-specs.csv", package = "mpindex" ) specs <- define_mpi_specs(specs_file, uid = "uuid") df_household |> define_deprivation( indicator = drinking_water, cutoff = drinking_water == 2, mpi_specs = specs ) df_household_roster |> define_deprivation( indicator = school_attendance, cutoff = attending_school == 2, mpi_specs = specs, collapse_fn = max )specs_file <- system.file( "extdata", "global-mpi-specs.csv", package = "mpindex" ) specs <- define_mpi_specs(specs_file, uid = "uuid") df_household |> define_deprivation( indicator = drinking_water, cutoff = drinking_water == 2, mpi_specs = specs ) df_household_roster |> define_deprivation( indicator = school_attendance, cutoff = attending_school == 2, mpi_specs = specs, collapse_fn = max )
Use to define MPI dimensions, indicators and its corresponding
weights using any of the supported file types: .xlsx (Excel),
.json, .csv, or .txt (TSV). You can also set the
poverty cutoff or list of poverty cutoffs.
define_mpi_specs( mpi_specs_file = NULL, indicators = NULL, poverty_cutoffs = NULL, unit_of_analysis = NULL, aggregation = NULL, uid = NULL, source_of_data = NULL, names_separator = "__", save_as_global_options = FALSE, ... )define_mpi_specs( mpi_specs_file = NULL, indicators = NULL, poverty_cutoffs = NULL, unit_of_analysis = NULL, aggregation = NULL, uid = NULL, source_of_data = NULL, names_separator = "__", save_as_global_options = FALSE, ... )
mpi_specs_file |
Path to a |
indicators |
A data frame of MPI indicators. Alternative to
|
poverty_cutoffs |
Single value or vector of poverty cutoffs (k).
All values must be in (0, 1]. Default is |
unit_of_analysis |
e.g. |
aggregation |
Column name that defines an aggregation level. |
uid |
Column name containing the unique ID (unit of analysis). |
source_of_data |
Source of data; used in output footnotes. |
names_separator |
|
save_as_global_options |
|
... |
Reserved for forward-compatibility; passing old dotted argument
names (e.g. |
An mpi_specs_df object. Pass this directly as the
mpi_specs argument in compute_mpi,
define_deprivation, and save_mpi.
specs_file <- system.file( "extdata", "global-mpi-specs.csv", package = "mpindex" ) system.file("extdata", package = "mpindex") |> list.files()specs_file <- system.file( "extdata", "global-mpi-specs.csv", package = "mpindex" ) system.file("extdata", package = "mpindex") |> list.files()
compute_mpi
A helper that captures a bare deprivation cutoff expression and
optional per-indicator settings for use inside the deprivations
argument of compute_mpi.
deprived(.cutoff, .data = NULL, collapse_fn = NULL, set_na_equal_to = 0, ...)deprived(.cutoff, .data = NULL, collapse_fn = NULL, set_na_equal_to = 0, ...)
.cutoff |
A bare logical expression evaluated against the indicator's
data frame. Rows where this evaluates to |
.data |
An optional data frame to use for this indicator instead of the
primary |
collapse_fn |
An optional function applied to collapse roster-level
data to the unit-of-analysis level (e.g. |
set_na_equal_to |
Coerce |
... |
Reserved; passing old dotted names (e.g. |
An object of class mpi_deprivation_spec.
deprived(drinking_water == 2) deprived(undernourished == 1 & age < 70, .data = df_household_roster, collapse_fn = max)deprived(drinking_water == 2) deprived(undernourished == 1 & age < 70, .data = df_household_roster, collapse_fn = max)
This is a synthetic dataset containing household information primarily used for demonstration purposes on how to use the mpindex package.
df_householddf_household
A tibble with 198 rows and 21 variables:
Unique ID
Urbanity: Rural or Urban
Acess to drinking water: 1 - improved; 2 - unimproved
Service level of toilet or sanitation facility: 1 - basic; 2 - limited; 3 - unimproved; 4 - open defecation
With at least one (1) child died in the last five (5) years: 1 - with child died; 2 - without child died
Main construction material of the roof: 1 - galvanized iron/aluminum; 2 - concrete/clay tile; 3 - half galvanized iron and half concrete; 4 - wood/bamboo; 5 - cogon/nipa/anahaw; 6 - asbestos; 7 - makeshift/salvaged/improvised materials; 9 - other construction material
Main construction material of the outer walls: 1 - concrete/brick/stone; 2 - wood; 3 - half concrete/brick/stone and half wood; 4 - Galvanized iron/aluminum; 5 - bamboo/sawali/cogon/nipa; 6 - asbestos; 7 - glass; 8 - makeshift/salvaged/improvised materials; 9 - none; 10 - concrete hollow blocks; 11 - concrete hollow blocks/wood; 12 - shear walls; 99 - other construction material
Main construction material of the floor: 1 - concrete; 2 - wood; 3 - coconut lumber; 4 - bamboo; 5 - earth/sand/mud; 6 - makeshift/salvaged/improvised materials; 9 - other construction material
Access to electricity: 1 - with access to electricity; 2 - without access to electricity
Fuel use for cooking: 1 - electricity; 2 - kerosene (gaas); 3 - liquified petroleum gas (LPG); 4 - charcoal; 5 - wood; 6 - none; 9 - other cooking fuel such as dung, agricultural crop, or shrubs
Number of working radio owned by the household
Number of working television owned by the household
Number of working telephone owned by the household
Number of working mobile phone owned by the household
Number of working computer owned by the household
Number of animal carts owned by the household
Number of bicycle owned by the household
Number of motorcylce owned by the household
Number of working refrigerator owned by the household
Number of car owned by the household
Number of trucks owned by the household
df_householddf_household
This dataset contains a many-to-one relationship with the df_household dataset. Hence, you can apply joins using the uuid.
df_household_rosterdf_household_roster
A tibble with 905 rows and 8 variables:
Unique ID
Number identifier for each member within the household
Urbanity: Rural or Urban
Sex of the household member
Age of the household member
Whether the household member (aged 5-24 years old) is currently attending school: 1 - currently attending; 2 - currently not attending
Whether completed at least six (6) years of schooling: 1 - completed; 2 -not completed
Whether the household member (aged below 70 years old) is undernourished: 1 - undernourished; 2 - not undernourished
df_household_rosterdf_household_roster
Returns the mpi_specs_df object for the standard
Global MPI (10 indicators across Health, Education, and Living Standards).
Assign the result and pass it explicitly as mpi_specs.
global_mpi_specs(..., poverty_cutoffs = 1/3)global_mpi_specs(..., poverty_cutoffs = 1/3)
... |
Additional arguments passed to |
poverty_cutoffs |
Single value or vector of poverty cutoffs (k).
All values must be in (0, 1]. Default is |
An mpi_specs_df object.
mpi_specs <- global_mpi_specs(uid = "uuid")mpi_specs <- global_mpi_specs(uid = "uuid")
Save the MPI output to an Excel file using the tsg package for publication-ready table formatting.
save_mpi( mpi_output, mpi_specs = NULL, filename = NULL, include_deprivation_matrix = TRUE, include_specs = FALSE, ... )save_mpi( mpi_output, mpi_specs = NULL, filename = NULL, include_deprivation_matrix = TRUE, include_specs = FALSE, ... )
mpi_output |
An object derived from compute_mpi. |
mpi_specs |
MPI specifications defined in
|
filename |
Output filename. The |
include_deprivation_matrix |
Whether to include deprivation matrices
as separate sheets. Defaults to |
include_specs |
Whether to include MPI specification as a separate
sheet. Defaults to |
... |
Reserved; passing old dotted names triggers a helpful error. |
Returns the normalised file path of the generated Excel file.
## Not run: mpi_result <- compute_mpi(df_household, mpi_specs = specs, deprivations = deps) save_mpi(mpi_result, mpi_specs = specs, filename = "MPI Sample Output") ## End(Not run)## Not run: mpi_result <- compute_mpi(df_household, mpi_specs = specs, deprivations = deps) save_mpi(mpi_result, mpi_specs = specs, filename = "MPI Sample Output") ## End(Not run)
Please use
global_mpi_specs instead.
use_global_mpi_specs(...)use_global_mpi_specs(...)
... |
Passed to |
An mpi_specs_df object.
## Not run: # Deprecated — use global_mpi_specs() instead mpi_specs <- use_global_mpi_specs(uid = "uuid") ## End(Not run)## Not run: # Deprecated — use global_mpi_specs() instead mpi_specs <- use_global_mpi_specs(uid = "uuid") ## End(Not run)