View source: R/weighted_poverty.R
run_weighted_poverty_shortfall | R Documentation |
Calculates the average shortfall (gap) between individual/household income and the relative poverty line, weighted by the population weights and restricted to those below the poverty line.
run_weighted_poverty_shortfall(
data_list,
var_name,
wgt_name = NULL,
times_median = 0.5,
type = c("type_4", "type_2"),
percent = FALSE,
na.rm = TRUE
)
data_list |
A named list of data frames. |
var_name |
A string specifying the variable name (e.g., |
wgt_name |
A string (optional). The name of the weight variable. If |
times_median |
A numeric scalar. The multiple of the median used to define the poverty threshold (default is |
type |
A character vector indicating the percentile estimation type (passed to |
percent |
Logical. If |
na.rm |
Logical. Should missing values be removed before computation? Default is |
A named list. Each list element is named by country and contains a named numeric vector, where the names are years and the values represent:
The average daily shortfall in monetary units (if percent = FALSE
), or
The average relative shortfall in percentage terms (if percent = TRUE
), among individuals or households below the poverty threshold.
## Not run:
library(lissyrtools)
library(purrr)
datasets <- lissyrtools::lissyuse(data = c("de", "es", "uk"), vars = c("dhi"), from = 2016)
datasets <- datasets %>%
map(~ .x %>% filter(!is.na(dhi))) %>%
map(~ .x %>% mutate(new_wgt = hwgt * nhhmem)) %>%
apply_iqr_top_bottom_coding("dhi", "hwgt", type = "type_2") %>%
apply_sqrt_equivalisation("dhi")
# Compute average poverty shortfall in absolute (daily monetary) terms
abs_gap <- run_weighted_poverty_shortfall(
data_list = datasets,
var_name = "dhi",
wgt_name = "new_wgt"
)
# Compute average poverty shortfall in percentage of the poverty line
rel_gap <- run_weighted_poverty_shortfall(
data_list = datasets,
var_name = "dhi",
wgt_name = "new_wgt",
percent = TRUE
)
# Compute average poverty shortfall in absolute (daily monetary) terms, converted to international dollars at 2017 prices.
abs_gap_dollars <- datasets %>%
apply_ppp_adjustment("dhi", "lis", "lisppp") %>%
run_weighted_poverty_shortfall(
var_name = "dhi",
wgt_name = "new_wgt"
)
print(abs_gap)
print(rel_gap)
print(abs_gap_dollars)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.