PIP-Technical-Team / wbpip

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

fix value of poverty line with when Beta and quadratic are not normal #217

Closed randrescastaneda closed 1 year ago

randrescastaneda commented 1 year ago

Hi @tonyfujs ,

the PIP API is returning two values for alternative aggregate data (e.g., AFW) when one of the underlying group data tables does not mean normality in the poverty lines provided by the user. You can run the following and see that instead of one the API returns two.

lkups <- create_versioned_lkups(Sys.getenv("PIPAPI_DATA_ROOT_FOLDER_LOCAL"), 
                                vintage_pattern = "20220909")
lkup <- lkups$versions_paths[[lkups$latest_release]]

dt <- pip_grp_logic(
  country  = "AFW",
  year     = 1983,
  group_by = "wb",
  povline  = 6.85,
  lkup     = lkup, 
  censor = TRUE
)
dt[]

image

Or, using pipr: image

The problem is that in wbpip when neither the lorenz nor the quadratic meet normality, the value of the poverty line is set to NA in this line. Do you know is there is reason for that? I can understand the rationale behind making the estimates equal to NA, but I don't understand why the value of the poverty line should be set to NA as well. Since the poverty line is used as a "byable" variable in pipapi, I think the problem should be fixed directly in wbpip. This PR fixes the problem, making sure the value of the poverty line in lorenz and quadratic is the same (which should be by construction).

Thanks.

randrescastaneda commented 1 year ago

Task linked: CU-38a4vea Fix Issue in AFW output with high poverty lines