Repository navigation
Conversation
The FRS build drew each benefit unit's Broad Rental Market Area from rows of lha_list_of_rents.csv.gz within region and LHA category. That file's Scottish, Welsh and Northern Ireland lists are byte-identical copies of English BRMAs' lists, each matched on the April 2019 rate, so those nations' draws ignored their rental markets (#515). Draw instead in proportion to census private-rented households by region, BRMA and the bedroom band matching each LHA category (England and Wales 2021, Scotland 2022, Northern Ireland 2021; Northern Ireland has no bedrooms question, so its weights cover every category). Move the draw to datasets/brma.py, add property tests for it, document sources and validation in storage/BRMA_DATA_SOURCES.md, and remove the list of rents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_frs's smoke test stubs Microsimulation.calculate with plain arrays, so take np.asarray rather than .values, and remove the stub of the deleted lha_list_of_rents.csv.gz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/brma_households downloads every census and BRMA geography input, checks each against a pinned sha256 (decoded-content hashes for the ONS custom-API batches), and rebuilds storage/brma_private_rented_households.csv byte for byte. Scotland's census ward table is the one manual download, with instructions in the manifest. Area overrides established from official lookups carry dated evidence and are asserted against the polygons so a boundary change fails loudly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Northern Ireland: build each BRMA's private-rented households from NISRA's postcode-district household counts and NI's private-rented share, dropping the ONS Postcode Directory Northern Ireland records, whose LPS end user licence does not clearly allow publishing derived figures. BRMA shares move by 1.5 points on average. - Move the household pick into brma.pick_household_brmas and test it. - Test that every category uses its bedroom band, with spot values; give each region's BRMAs distinct names in the property tests; make the fail-closed test remove a cell rather than skip. - Decode enum regions; assert Scotland's bedroom headers exactly. - Docs: Cardiff Bay and Balloch overrides, centroid wording, what the validation correlates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
brma-private-rented-weights
branch
from
October 2, 2026 11:56
d3b5ba0 to
ae9b9b1
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 of 27 tasks
This was referenced Oct 2, 2026
MaxGhenis
marked this pull request as ready for review
October 3, 2026 11:45
MaxGhenis
added a commit
that referenced
this pull request
Oct 6, 2026
Conflicts resolved per runbook A4 step 14, both in tests/test_legacy_benefit_proxies.py: (a) the FakeMicrosimulation double keeps #490's person_benunit_id, is_adult and is_SP_age branches and #526's [66] * len(...) state_pension_age; (b) #526's create_single_adult_frs helper drops the lha_list_of_rents.csv.gz read_csv fake, because #516 deleted that file and its fake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #515.
What changes
Each FRS benefit unit's Broad Rental Market Area (BRMA) is now drawn within its region in proportion to census private-rented households by BRMA and bedrooms, instead of the row counts of
lha_list_of_rents.csv.gz.Why. The old file's Scottish, Welsh and NI lists are byte-identical copies of English BRMAs' lists, matched on the April 2019 rate; #515 has the evidence. In the current enhanced FRS, Scotland's private renters are imputed as follows:
The new table
storage/brma_private_rented_households.csv(936 rows:region, brma, bedrooms, households). Sources, method and validation are instorage/BRMA_DATA_SOURCES.md.tools/brma_households/downloads every input, checks it against a pinned sha256 and rebuilds the CSV byte for byte. The one exception is the Scotland's Census table-builder export, which needs a browser session and has step-by-step instructions.Validation. Within each region, I compared each weight's BRMA shares with DWP's Universal Credit households assessed under LHA, averaged over April 2019 to November 2020 (UC statistics supplementary table 3.2):
Against the genuine lists, the census bedroom bands correlate with each LHA category's share as follows:
Invariants
These hold for every weights table and every set of benefit units:
ValueError; it never getsNone.BRMANamemembers and all 12 regions. Every non-NI region has bands 1, 2, 3 and 4+, and NI has onlyall. Each nation's total is within 0.1% of its published census total.Invariants 1-3 are Hypothesis property tests (200 and 100 derandomised examples), and 4-6 are example tests.
hypothesisis added to the dev extra.Differential. microcosm's
frs_brmastage reads the same table, pinned by sha256 in its generator (PolicyEngine/microcosm PR to follow). The two implementations draw differently (seeded generator here, identity-keyed uniforms there) but from the same weights.Impact
Every figure below is for 2026, from policyengine-uk runs on seeded enhanced FRS 2024-25 builds, using the published LHA rates from policyengine-uk#2022 (head aef9c2427). Running on policyengine-uk main instead gives smaller Scottish changes, because main's Scottish rates come from the copied lists. Scripts and outputs are in
impact/of the working folder.1. Expected effect of the new weights, with dataset weights held fixed. On the baseline build, BRMAs were re-drawn 10 times with the census weights and 10 times with the list-of-rents weights. The effect is the difference in means, with its standard error. "One draw, SD" is the spread between draws with the old weights.
† Suppressed, because fewer than 10 records changed in at least one draw.
Scotland's private renters move to where Scotland's private renters actually live, so they now face Lothian's and Glasgow's higher LHA rates. Averaged over draws, Scottish private renters' imputed BRMA shares now match the census: Lothian 20.6% (census 19.3%) and Greater Glasgow 15.4% (15.9%), against 12.3% and 3.1% under the old weights. England's effect is within its noise.
2. Full rebuild. I built this branch and main with the same seed; two builds of main are output-identical. The branch build is commit e0d4b24, from before the Northern Ireland rows switched to all-tenure households; NI is 2.4% of UK private renters. Under published rates, the branch moves:
3. The rebuild difference is mostly the draw, not the weights. I also rebuilt main with only the BRMA seed changed and the old weights kept. It moves:
With one clone per household, recalibration amplifies a single BRMA draw into aggregate changes of this size. A single-build comparison therefore cannot separate this PR's effect from that noise, and (1) is the estimate to use. Reducing this draw noise is a separate follow-up.
Review
An independent Opus review (round 1) requested changes, and all of them are addressed:
pick_household_brmas, with a property test.Round 2 approved after rerunning the tests and mutation checks. It also re-verified the copied-list claim from the raw file: 480 of 480 blocks match an English block from the same year. Its one remaining note, a stale NI description in
sources.yaml, is fixed. A round-3 delta review approved head 29e1bd7: the history audit, ignore protection, manifest check and tests all passed (24 passed, 1 skipped).Merge timing: per Max's ruling d833, uk-data fixes land together as one data release on his go. This PR is approved and ready, and should merge with that batch alongside PolicyEngine/microcosm#1087.
Other notes
lha_list_of_rents.csv.gzis removed; nothing else in this repo reads it.Commands run
pytest policyengine_uk_data/tests/test_brma_assignment.py test_legacy_benefit_proxies.py: 25 passed, including the built-dataset test. CI's previous run passed all 9 BRMA tests on its own built dataset.tools/brma_households/build.pyagainst a cache of the retained originals verifies all 87 inputs and rebuilds the CSV byte for byte (sha256fd40dae0…).ruff formatandruff checkon changed files: clean.🤖 Generated with Claude Code