Skip to contents

Calculate poverty gap from microdata

Usage

pipmd_pov_gap(
  welfare,
  weight = rep(1, length = length(welfare)),
  povline = fmean(welfare, w = weight) * times_mean,
  times_mean = 1,
  format = c("dt", "list", "atomic")
)

Arguments

welfare

numeric: A vector of income or consumption values

weight

numeric: A vector of population weights. If NULL, a vector of 1s is used to give equal weight to each observation.

povline

numeric: Poverty line in international dollars, same units as welfare.

times_mean

numeric factor that multiplies the mean to create a relative poverty line. Default is 1

format

atomic character vector: specifies the format of output, either "dt", "list", or "atomic"

Value

A data.table and data.frame object of length equal to the povline vector with variables povline and pov_gap. See format to change the output format.

Examples

# Example 1: Basic poverty gap calculation
pipmd_pov_gap(welfare = pip_md_s$welfare,
              weight  = pip_md_s$weight,
              povline = 1.3,
              format  = "list")
#> $pl1.3
#> $pl1.3$pov_gap
#> [1] 0.0673906
#> 
#> 

# Example 2: Returning data.table format, multiple povline.
pipmd_pov_gap(welfare = pip_md_s$welfare,
              weight  = pip_md_s$weight,
              povline = c(1.3, 1.2),
              format  = "dt")
#>    povline    pov_gap
#>      <num>      <num>
#> 1:     1.3 0.06739060
#> 2:     1.2 0.05631327

# Example 3: Returning atomic format
pipmd_pov_gap(welfare = pip_md_s$welfare,
              weight  = pip_md_s$weight,
              povline = 1.3,
              format  = "atomic")
#>     pl1.3 
#> 0.0673906