Skip to content

feat: add calibration/reweighting system#24

Merged
nikhilwoodruff merged 7 commits intomainfrom
feat/calibration
Apr 8, 2026
Merged

feat: add calibration/reweighting system#24
nikhilwoodruff merged 7 commits intomainfrom
feat/calibration

Conversation

@nikhilwoodruff
Copy link
Copy Markdown
Contributor

@nikhilwoodruff nikhilwoodruff commented Apr 8, 2026

Adds a calibration/reweighting system that adjusts EFRS household survey weights to match administrative totals from four sources.

The system works in two layers: Python scripts parse official statistics into a standardised JSON target format, then a Rust Adam optimiser adjusts log-space weights to minimise mean squared relative error against those targets.

Target sources (1,406 targets total):

  • HMRC SPI (1,092): income-by-band distributions for employment, self-employment, pensions, property, dividends, savings — scaled from the 2022-23 snapshot to all years using OBR growth rates
  • OBR EFO (177): aggregate tax receipts (IT, NI, VAT, fuel duty, CGT, SDLT, council tax), benefit spending, and labour market aggregates (employment count, wages & salaries, self-employment income)
  • DWP (102): benefit caseloads (UC with subgroup breakdowns, PIP, pension credit, carer's allowance, AA, state pension, ESA, DLA) — scaled across years using DWP's own Spring Statement 2025 caseload forecasts
  • ONS (35): population by age group, total households

Targets are consistent across calibration years (2024-2029 each have ~201 targets), ensuring trends are accurate. Training RMSRE is 15-20% across all years. Calibrated EFRS for 2024-2029 uploaded to gs://policyengine-uk-microdata/efrs/.

nikhilwoodruff and others added 7 commits April 8, 2026 13:24
Python scripts pull calibration targets from OBR EFO (tax/benefit aggregates),
HMRC SPI (income distributions by band), DWP stat-xplore (benefit caseloads),
and ONS (demographics). Rust module reweights household data using Adam
optimiser in log-space to minimise mean squared relative error, with holdout
validation for HMRC count targets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
UC_Monthly measure is V_F_UC_CASELOAD_FULL (people), not V_F_UC_HOUSEHOLD.
PIP uses PIP_Monthly_new database (post-2019). Simplified queries to use
no dimensions — stat-xplore auto-selects the latest month.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds pension credit, carer's allowance, attendance allowance, state pension,
ESA, and DLA caseloads from stat-xplore, plus UC household breakdowns by
family type, child/carer/LCWRA/housing entitlement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Run a baseline simulation before calibrating so targets can reference
simulated variables (income_tax, national_insurance, vat, etc.) rather
than raw input proxies. Income tax RMSRE drops from 79% to 1%.

Also adds benunit entity support to the calibration matrix builder, and
updates OBR targets to use simulated tax/benefit variables (income_tax,
national_insurance, vat, fuel_duty, capital_gains_tax, stamp_duty) and
benunit-level benefit variables (universal_credit, housing_benefit, etc.).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add BenunitFilter struct for UC subgroup targets (is_couple,
  has_children, has_carer, has_lcwra, has_lcw, has_housing)
- Add total_ni variable (employee + employer NI) for OBR NI receipts
- ONS targets now emitted for years 2024-2030 so they bind regardless
  of calibration year (fixes weight sum blowup from 34m to ~29m)
- DWP UC subgroup targets now carry benunit_filter conditions
- Add historical FRS years 1994-2021 to rebuild_all manifest

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Parse sheet 1.6 for employment count, wages & salaries, self-employment
income, and self-employed count. Brings total target count to 385 (283
training, 102 holdout).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
HMRC SPI 2022-23 income bands are now scaled to 2024-2030 using OBR
growth rates (sheet 3.5 for self-employment/dividends/property/savings,
sheet 1.6 for wages & salaries, sheet 1.7 CPI for pensions).

DWP stat-xplore caseloads are scaled to 2024-2029 using DWP's own
caseload forecasts from the Spring Statement 2025 benefit expenditure
and caseload tables.

All targets now participate in training (holdout flag only affects
reporting, not gradient). This ensures consistent ~15-20% RMSRE across
all calibration years, so trends are accurate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nikhilwoodruff nikhilwoodruff merged commit 19fa204 into main Apr 8, 2026
1 check passed
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