| compute_mpi | R Documentation |
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.
compute_mpi(
.data,
mpi_specs,
deprivations,
...,
by = NULL,
include_deprivation_matrix = 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 |
... |
(Optional) Extra columns to carry through into the
deprivation matrix (tidyselect). These columns are included in the matrix
after |
by |
(Optional) Columns to group summary outputs by (tidyselect),
e.g. |
include_deprivation_matrix |
Whether to include deprivation matrices.
Default |
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, deprived, 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.