Skip to content

Add WPP-2024 reference series (median + 95% PI) to population_by_age_and_sex, population_by_broad_age_group, annual_growth_rate #2

Description

@cimentadaj

Background

run_forecast() already returns WPP-2024 reference columns (un_*_median / un_*_95low / un_*_95high) for the time-series outputs:

  • population_by_time
  • tfr_by_time
  • e0_by_time
  • mig_by_time

This lets the demographydash app overlay the UN reference on those charts. The remaining by-age outputs do not carry UN reference columns:

  • population_by_age_and_sex — has only year, age, popM, popF
  • population_by_broad_age_group — has only year, age, pop, pop_percent
  • annual_growth_rate — has only year, age, growth_rate

So the demographydash Compare-Simulations views for population pyramid, population by broad age groups, and growth rate by age cannot draw the UN reference. This was raised by Mengjia Liang / Patrick Gerland in the April 8 OPPP review (item 5 of their feedback list) and is the only deferred item from that round.

Desired changes (mirroring the existing un_* naming in population_by_time)

  1. population_by_age_and_sex — add un_popM_median, un_popF_median (and ideally un_popM_95low / un_popM_95high / un_popF_95low / un_popF_95high).
  2. population_by_broad_age_group — add un_pop_median (and un_pop_95low / un_pop_95high).
  3. annual_growth_rate — add un_growth_rate_median (and un_growth_rate_95low / un_growth_rate_95high).

The canonical pattern to copy is get_pop_by_time() in R/forecast.R, which already merges WPP via get_wpp_pop_by_age_multiple_years() for the median and get_wpp_indicator_multiple_years("popprojAgeGrp1dt", package = "wpp2024extra") for the prediction intervals.

Draft PR (median-only)

I'm opening a draft PR (#) that wires up the median columns for all three outputs by reusing the existing helpers get_wpp_pop_by_age_multiple_years(), get_pop_by_broad_age(), and get_annual_growth_rate(). The 95% PI columns are marked TODO(hana) — they depend on bayesPop's quantiles{M,F}age object (already touched in extract_pop_by_age_sex), and figuring out the right quantile keys / open-age handling is your call. Happy to extend the PR once you point me at the right shape.

cc @hanase

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions