Skip to content

Commit 10d1e9f

Browse files
vahid-ahmadiclaude
andcommitted
Add calibration target for babies under 1 in Scotland
Add scotland_babies_under_1 calibration target (~46k) based on NRS Vital Events data. This addresses overestimation of babies in Scotland (99k vs 46k actual births per year). Source: NRS Vital Events Reference Tables 2024 https://www.nrscotland.gov.uk/publications/vital-events-reference-tables-2024/ Changes: - demographics.csv: Add scotland_babies_under_1 entry (46k for all years) - loss.py: Add matrix column for Scotland babies under 1 - test_scotland_babies.py: Add test to validate calibration accuracy (15% tolerance) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0315be3 commit 10d1e9f

4 files changed

Lines changed: 46 additions & 0 deletions

File tree

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: minor
2+
changes:
3+
added:
4+
- Add calibration target for babies under 1 in Scotland (~46k from NRS Vital Events)

policyengine_uk_data/storage/demographics.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ scotland_age_60_69,person-k,ons_age_sex_region,,,,,691,702,714,727,741,755,767,,
7575
scotland_age_70_79,person-k,ons_age_sex_region,,,,,506,520,534,546,557,565,575,,,
7676
scotland_age_80_89,person-k,ons_age_sex_region,,,,,274,282,290,297,302,307,312,,,
7777
scotland_children_under_16,person-k,nrs_mid_year_population_estimates,,,,,904,900,896,892,888,884,880,,,
78+
scotland_babies_under_1,person-k,nrs_vital_events,,,,,46,46,46,46,46,46,46,,,
7879
scotland_households_3plus_children,household-k,scotland_census_2022,,,,,82,82,82,82,82,82,82,,,
7980
south_east_age_0_9,person-k,ons_age_sex_region,,,,,1047,1044,1042,1039,1034,1028,1024,,,
8081
south_east_age_10_19,person-k,ons_age_sex_region,,,,,1122,1119,1117,1114,1108,1102,1097,,,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Test Scotland babies under 1 calibration target.
2+
3+
Source: NRS Vital Events Reference Tables 2024
4+
https://www.nrscotland.gov.uk/publications/vital-events-reference-tables-2024/
5+
Scotland had 45,763 live births in 2024.
6+
"""
7+
8+
import pytest
9+
10+
11+
def test_scotland_babies_under_1(baseline):
12+
"""Test that babies under 1 in Scotland matches NRS birth statistics.
13+
14+
Target: ~46,000 babies under 1 (based on ~46k annual births)
15+
Source: NRS Vital Events 2024 reports 45,763 births
16+
"""
17+
region = baseline.calculate("region", map_to="person", period=2025)
18+
age = baseline.calculate("age", map_to="person", period=2025).values
19+
person_weight = baseline.calculate(
20+
"person_weight", map_to="person", period=2025
21+
).values
22+
23+
scotland_babies = (region.values == "SCOTLAND") & (age < 1)
24+
total_babies = (person_weight * scotland_babies).sum()
25+
26+
TARGET = 46_000 # NRS Vital Events 2024: 45,763 births
27+
TOLERANCE = 0.15 # 15% tolerance
28+
29+
assert abs(total_babies / TARGET - 1) < TOLERANCE, (
30+
f"Expected ~{TARGET/1000:.0f}k babies under 1 in Scotland, "
31+
f"got {total_babies/1000:.0f}k ({total_babies/TARGET*100:.0f}% of target)"
32+
)

policyengine_uk_data/utils/loss.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ def pe_count(*variables):
272272
scotland_children_under_16
273273
)
274274

275+
# Babies under 1 in Scotland
276+
# Source: NRS Vital Events - births registered in Scotland
277+
# https://www.nrscotland.gov.uk/publications/vital-events-reference-tables-2024/
278+
# ~46,000 births per year (45,763 in 2024)
279+
scotland_babies_under_1 = (region == "SCOTLAND") & (age < 1)
280+
df["ons/scotland_babies_under_1"] = household_from_person(
281+
scotland_babies_under_1
282+
)
283+
275284
# Households with 3+ children in Scotland
276285
# Source: Scotland Census 2022 - Household composition
277286
# https://www.scotlandscensus.gov.uk/census-results/at-a-glance/household-composition/

0 commit comments

Comments
 (0)