Skip to content

Demographics view: population by age vs Census#17

Draft
PavelMakarchuk wants to merge 1 commit into
mainfrom
demographics
Draft

Demographics view: population by age vs Census#17
PavelMakarchuk wants to merge 1 commit into
mainfrom
demographics

Conversation

@PavelMakarchuk

Copy link
Copy Markdown
Contributor

What

A new Demographics view (/populace/demographics) reading demographics.json live from HF: the populace dataset's weighted population by age band against the US Census age structure, with run-over-run tracking.

This answers "can I look at population by age from the dashboard" — and adds a fit-vs-Census angle, since the current fiscal release doesn't calibrate age (so e.g. the 5–17 band runs ~+61% over Census; a real, visible signal).

How it fits the pure-HF architecture

Same producer→consumer pattern as reform validation: the populace build publishes demographics.json per release (producer PR PolicyEngine/populace#); this is the consumer.

  • lib/populace/demographics.ts — pure-HF loader; buildDemographics (per-band error, benchmark stats), buildDemographicsHistory (run-over-run).
  • API: /api/populace/demographics[?release=] (200 + available:false until the artifact exists) and /demographics/history.
  • /populace/demographics page — KPIs (total vs Census, mean/largest band error), an age table with share-vs-Census bars, run-over-run table; nav entry; hooks + types.

Tests

bun test — 4 new (per-band error, signed total-vs-benchmark, unbenchmarked bands excluded, chronological history). tsc clean. Verified live: endpoint returns available:false for the current release (no artifact yet), page renders 200.

🤖 Generated with Claude Code

Reads demographics.json (published per release by the populace build) live from
HF: the dataset's weighted population by age band, its share, the Census
benchmark, and the fit error. The fiscal release doesn't calibrate age, so this
surfaces the dataset's emergent age structure — and how it tracks Census
release over release.

- lib/populace/demographics.ts: pure-HF loader + buildDemographics (per-band
  error, benchmark stats) + buildDemographicsHistory for run-over-run.
- API: /api/populace/demographics[?release=] (200 + available:false until
  published) and /demographics/history.
- /populace/demographics page: KPIs (total vs Census, mean/largest band error),
  an age table with share-vs-Census bars, and a run-over-run table.
- Nav entry; hooks + types; 4 bun tests.

Pairs with the producer PR PolicyEngine/populace#<demographics>.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant