Skip to contents

Given a vector of weights and welfare, this functions computes the Mean Log Deviation (MLD).

Usage

pipmd_mld(
  welfare,
  weight = rep(1, length = length(welfare)),
  mean = NULL,
  format = c("dt", "list", "atomic")
)

Arguments

welfare

welfare vector

weight

population weight vector

mean

numeric: weighted welfare mean. Default is NULL.

format

character: "dt", "list", "atomic", giving the format of the output

Value

Returns a data.table and data.frame object with two variables: indicator and value. Check format argument to change the output format.

Examples

# Example 1: Basic usage with default settings
pipmd_mld(welfare = pip_md_s$welfare,
          weight = pip_md_s$weight)
#>    indicator     value
#>       <char>     <num>
#> 1:       mld 0.3016201

# Example 2: Specifying mean and returning as a list
custom_mean <- mean(pip_md_s$welfare)
pipmd_mld(welfare = pip_md_s$welfare,
          weight = pip_md_s$weight,
          mean = custom_mean,
          format = "list")
#> $mld
#> [1] 0.2606041
#> 

# Example 3: Returning MLD as an atomic value
pipmd_mld(welfare = pip_md_s$welfare,
          weight = pip_md_s$weight,
          format = "atomic")
#>       mld 
#> 0.3016201 
#> attr(,"label")
#> [1] "welfare(income of consumption)"

# Example 4: Using equal weights (weight vector is NULL)
pipmd_mld(welfare = pip_md_s$welfare,
          format = "list")
#> $mld
#> [1] 0.283235
#>