PIP-Technical-Team / wbpip

Official methodological Stats of PIP
https://pip-technical-team.github.io/wbpip/
Other
3 stars 1 forks source link

add weight to quantile welfare share #243

Closed zander-prinsloo closed 7 months ago

zander-prinsloo commented 7 months ago

Hi @randrescastaneda ,

I made some adjustments to the md_quantile_welfare_share function. There were two issues

  1. While the function was accounting for weights in calculating the quantile values, when finding the sum of welfare within those quantiles, it did not use weights. Lines 265-272 now include the weights
  2. When n=NULL and the popshare argument is used, the result was a vector of length 2, rather than length 1. This is because if, for example, popshare = 0.7 then the first element in the vector gave the welfare share below 0.7 and then the second element gave the share above 0.7 (which is the functionality we want when using n). The change is to only give the first element when popshare is used.