Demographics view: population by age vs Census#17
Draft
PavelMakarchuk wants to merge 1 commit into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new Demographics view (
/populace/demographics) readingdemographics.jsonlive 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.jsonper 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/populace/demographics[?release=](200 +available:falseuntil the artifact exists) and/demographics/history./populace/demographicspage — 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).tscclean. Verified live: endpoint returnsavailable:falsefor the current release (no artifact yet), page renders 200.🤖 Generated with Claude Code