View source: R/md_compute_poverty_stats.R
md_compute_fgt | R Documentation |
Compute FGT poverty family measures and Watts index for Microdata
md_compute_fgt(
fgt_data = NULL,
welfare = NULL,
weight = rep(1, length(welfare)),
povline = fmedian(welfare, w = weight)/2,
alpha = 0,
return_data = FALSE,
include_povline = FALSE
)
md_compute_headcount(
welfare,
weight = rep(1, length(welfare)),
povline = fmedian(welfare, w = weight)/2,
return_data = FALSE,
include_povline = FALSE
)
md_compute_pov_gap(
welfare,
weight = rep(1, length(welfare)),
povline = fmedian(welfare, w = weight)/2,
return_data = FALSE,
include_povline = FALSE
)
md_compute_pov_severity(
welfare,
weight = rep(1, length(welfare)),
povline = fmedian(welfare, w = weight)/2,
return_data = FALSE,
include_povline = FALSE
)
md_compute_watts(welfare, weight = rep(1, length(welfare)), povline)
fgt_data |
list of previously computed fgt calculations |
welfare |
numeric vector with either income or consumption |
weight |
numeric vector with sample weights. Default is 1. |
povline |
poverty line. Default is the half the weighted median of
|
alpha |
numeric. Alpha parameter of FGT measures. if |
return_data |
logical: whether to return a list to be used in subsequent
calls of md_compute_fgt in the parameter |
include_povline |
logical: Whether to include the poverty line as
threshold for poverty measure. The default is |
md_compute_fgt works in two ways. It could either receive a list
of previously computed calculations in argument fgt_data
or receive the
standard poverty calculation inputs such as welfare
, weights
and
povline
. The first modality ensures efficiency in computations as the
poverty status of each observation and their relative distance to the
poverty line is calculated only once.
either a vector with the fgt measure selected in argument alpha
or
a list of fgt estimations if return_data
is TRUE
There are a few functions that are basically wrappers of md_compute_fgt. They do not serve any purpose beyond ease to the user to identify the right measure.
md_compute_headcount Computes poverty headcount, which is equivalent to
md_compute_fgt(alpha = 0)
md_compute_pov_gap Computes poverty gap, which is equivalent to
md_compute_fgt(alpha = 1)
md_compute_pov_severity Computes poverty severity, which is equivalent to
md_compute_fgt(alpha = 2)
md_compute_watts is not a wrapper of md_compute_fgt but it is part of the poverty measures, so it is included in this documentation. Notice that the arguments are the same as of the functions above.
when include_povline
is TRUE
, the
value of the povline
is artificially modify to povline + e
where e
is
a very small number (1e-10
), ensure the inclusion of the line.
welfare <- md_ABC_2010_income$welfare/1e6
weight <- md_ABC_2010_income$weight
wna <- !is.na(welfare)
welfare <- welfare[wna]
weight <- weight[wna]
md_compute_fgt(welfare = welfare,
weight = weight,
povline = 5)
# Multiple values of alpha using the return_data argument
fgt <- md_compute_fgt(welfare = welfare,
weight = weight,
povline = 5,
return_data = TRUE) |>
md_compute_fgt(alpha = 1,
return_data = TRUE) |>
md_compute_fgt(alpha = 2,
return_data = TRUE)
c(fgt$FGT0, fgt$FGT1, fgt$FGT2)
# multiple poverty lines
dtgft <- md_compute_fgt(welfare = welfare,
weight = weight,
povline = seq(from = 1, to = 10, by = .1))
attributes(dtgft)
fgt <- md_compute_fgt(welfare = welfare,
weight = weight,
povline = seq(from = 1, to = 10, by = .1),
return_data = TRUE) |>
md_compute_fgt(alpha = 1,
return_data = TRUE) |>
md_compute_fgt(alpha = 2,
return_data = TRUE)
dt_fgt <- data.frame(povline = fgt$povline,
FGT0 = fgt$FGT0,
FGT1 = fgt$FGT1,
FGT2 = fgt$FGT2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.