Repository navigation
Fix outside-London bus concessionary yield - #2641
juaristi22 wants to merge 2 commits into
Conversation
Aggregate impact on certified data: passBase Checks: 0 broken by this change, 1 failing on both sides, 0 fixed. Moves flagged for review: 0 (thresholds in Notes
Moves flagged for reviewNone. Spending by benefit and service
Caseloads
Standard reform costings (change in gov_balance)
Standard reforms: change in each reform's target
Household net income by decileNo household's net income changes in any year. No change in any year: receipts by tax head; government balance, each component counted once; model totals; household income totals; population; poverty rates; people in poverty; inequality; mean household net income in each side's own deciles. Checks failing on both base and head (1)
Counted-once checkEach of 87 components was raised by £1 per unit in 2026-27, and every head of its totals was read household by household: its own head must rise by exactly £1, no other tax head may move, no other benefit may rise, and the model's own total must move by what its heads moved. A head that breaks a rule is measured again twice: with every other head held at its baseline value, and with every other head held at its value after the first £1 while the component rises again. It fails where either still shows the response. 0 failed; 0 were skipped.
Provenance
Dataset: Receipts by tax head: head levels
Spending by benefit and service: head levels
Caseloads: head levels
Government balance, each component counted once: head levels
Model totals: head levels
Household income totals: head levels
Population: head levels
Poverty rates: head levels
People in poverty: head levels
Inequality: head levels
Mean household net income in each side's own deciles: head levels
Standard reform costings (change in gov_balance): head levels
Standard reforms: change in each reform's target: head levels
|
vahid-ahmadi
left a comment
There was a problem hiding this comment.
@juaristi22 thanks, this is a clean fix. I checked it against the official DfT tables at head 6ea70a3. I have nothing blocking and four small nits.
What I checked
-
Source figures. I downloaded
bus01.ods(media69c11f97cfa346b9d4704a50, the file the tests cite) andbus05i.odsfrom the bus statistics page and parsed them. England outside London, millions:Year ending March BUS01a journeys BUS01c Elderly/Disabled BUS01c total BUS05ai passenger fare receipts 2024 (2023-24) 1,780.91290001636 391.01714937439 499.73008211509 £1,936.89 2025 (2024-25) 1,850.50988726131 402.84635014539 519.10760859444 £2,069.953713 Every constant in
yield_per_boarding.yaml, the tests, the script and the docs matches these to the last digit. £2,069.953713m / (1,850.510m − 402.846m) = £1.4298582925868, which equals the new parameter. The old £1.554716967657 is the same sum with the BUS01c total. -
Numerator and denominator agree. BUS05ai keeps Passenger fare receipts (note 3: fares the operators keep) apart from Concessionary Travel (£630.6m in 2024-25, councils' reimbursement) and Fare cap support (£515.7m). So the numerator is what passengers pay, with no reimbursement in it. BUS01c note 4 says the table covers older/disabled and youth schemes that councils reimburse. Taking off only the Elderly/Disabled row leaves the youth journeys in the denominator at the reduced fares their holders paid. The result is the average fare a passenger pays per boarding by anyone the free-pass flag leaves out, which is what
person_bus_fare_spending.py:117-118charges. The two leftover gaps are written up in the docs (disabled pass holders are charged, under-5s ride free). -
References. The YAML reference title now names the right sheets: BUS01a, BUS01c and BUS05ai.
-
Refit.
scripts/fit_bus_cap_savings.pyin a fresh environment gives 0.56/0.31/0.13 and £1.70/£2.21/£3.96 (loss 0.172). Every figure in the docs' fit table matches what the script prints: £282.8m, 9.8%, £144.2m, £420.2m, £2.15, 0.44, £2.73, £272.7m, and £252.5m (37% below £400m). The derived numbers I checked by hand also hold: 116.3m, 1,390m and 1,448m, 77.5%, 2.6%, £0.36 and £0.14 per single, £0.37bn and £0.14bn. -
Tests. At head:
test_bus_fare_parameters.py,test_bus_fare_reforms.py,test_road_fuel_volume_uprating.pyandtest_parameter_descriptions.pygave 55 passed.test_disable_simulated_benefits_winter_heating.py, which also touches bus fares, gave 16 passed.policyengine-core test .../gov/dftgave 43 passed. With the new tests on the merge base8e0049b,test_outside_london_yield_uses_older_disabled_concessionsfails, and Cases 9, 10, 14, 15 and 16 fail, as the PR body says. -
Effect on cap reforms, from the updated expectations. In Case 15, a £2 cap in 2025-26 saves the Case 10 passenger £17.19, down from £18.54 (−7.3%). In Case 14, removing the £3 cap costs them £11.20 more, down from £11.83 (−5.3%). For the same priced boardings in the data, the saving per single ticket at FY2025-26 prices falls from £0.2355 to £0.2184 for £2 against £3. At 2027 prices it falls 6.1%, from £0.2653 to £0.2492. The baseline outside-London other-local-bus yield falls 8.0%.
-
PR body. The
Reproducer:line andaxiom: n/awith a reason are both present.changelog.d/2640.fixed.mdis there. CI is green at this head. No other open PR changes these bus files apart from #2077 and #2131. Those two are far behind main, and their diffs only show the uncapped table as added.
Findings
- nit,
policyengine_uk/tests/test_bus_fare_parameters.py:118-162: the table-fit tests cannot tell the refitted table from the old one. With the new yield and boardings, the old 0.55/0.30/0.15 and £1.65/£2.21/£3.87 table still passes all fourtest_table_matches_*tests. They check that the table lies inside the bands, not that it is the best fit: for example the 2023-24 grant comes out at £304.7m, +9.2% against ±15%. The old table is caught today only because three tests intest_bus_fare_reforms.pyand Cases 14 and 15 hardcode the new values. The next benchmark change would again rely on someone refitting by hand.fit()takes about 4 seconds, so one test that callsscripts/fit_bus_cap_savings.fit()and compares its result withshare.yamlandfare.yamlwould make the refit check itself.fit()reads the OBR CPI, so the test would need refitting after each OBR update. The suite already hardcodes 1.034 elsewhere, so this adds no new kind of upkeep. Fine as a follow-up. - nit,
policyengine_uk/parameters/gov/dft/bus/yield_per_boarding.yaml:1,docs/engineering/bus-fares.md:50,:229and:236, andscripts/fit_bus_cap_savings.py:59: these lines still say "fare-paying boardings". For England outside London, that count now includes youth and other concessionary journeys. London, Scotland and Northern Ireland still subtract every concessionary journey, so "fare-paying" is still right for them. The test comment attest_bus_fare_parameters.py:146already says "priced boardings". That word covers all four areas, so it would suit the general formula at:50and the outside-London lines. - nit,
docs/engineering/bus-fares.md:72-78: the docs name the two mismatches betweenCand the flag, but not which way they net out. Disabled pass holders sit insideCand are still charged, which pushes modelled spending up. Under-5s ride free in the model but are not inC, which pulls it down. The issue measured the net on the certified build: from +6.8% to about −1.8% against BUS05ai. One sentence with that figure would tell users which way the model leans. Related: Microcosm's bus-pass basis text (packages/microcosm-build/src/microcosm/build/uk/spec/sources.yaml:3225on main) still says "disabled passes and child half-fares are absorbed by the yield", which stops being true with this PR. Worth adding to microcosm#1385. - nit,
policyengine_uk/parameters/gov/dft/bus/yield_per_boarding.yaml:11-12: the reference links only to the bus statistics landing page, whose tables DfT replaces with each release. The values come from the March 2026 revised release, and its fixed file addresses are already cited in the test and the script:bus01.ods(media69c11f97cfa346b9d4704a50) andbus05i.ods(media69c11f97b920af63be1c7631). Adding them here would pin the vintage. The docs could also call the 116.3m other concessions youth-scheme journeys, since BUS01c note 4 says that is what they are.
Merge order. This needs a Microcosm follow-up (PolicyEngine/microcosm#1385), because bus_engine_parity checks this yield at 0.1%. has_bus_journeys (utils/bus_fares.py:8) falls back to reported spending when no trips are supplied. The CI aggregate-impact run on Enhanced FRS supplies none, so it does not test this change. The effect shows only on data that supplies journeys, such as Microcosm.
Approve.
🤖 Generated with Claude Code
6ea70a3 to
f9fa839
Compare
|
@vahid-ahmadi addressed all four suggestions:
After rebasing onto current Please review the final head when the new CI run is green. |
Fixes #2640
England outside London's bus yield excluded every concessionary journey even though the supplied free-travel flag covers a narrower group. Use BUS01c's older-and-disabled count, leaving youth-scheme journeys and their discounts in the priced denominator. The FY2024–25 benchmark falls from £1.554716967657 to £1.429858292587 per boarding.
Refit the uncapped-fare table using the same concession definition for 2023–24 and 2024–25. The fit reads the model's benchmark yield and fares index directly. An executable regression now reruns the fit and compares every band share and fare with the parameters. The parameter references pin the March 2026 revised BUS01 and BUS05i files. London, Scotland and Northern Ireland keep their existing yields.
This implements proposal A. The person-level concessionary share in proposal D remains later work. Charging disabled pass holders raises modelled spending; making under-5s free lowers it. Microcosm #1385 reports that the denominator change moves outside-London fares from 6.8% above BUS05ai to about 1.8% below it on its named certified build, with its weights fixed and model year 2024. Those are the issue's historical measurements; this review round did not rerun the population calculation.
After the model release, Microcosm #1385 must align the companion selectors, bus-pass basis text and model lock. Its parity check requires that follow-up before a new certified build.
Reproducer:
policyengine_uk/tests/test_bus_fare_parameters.py::test_outside_london_yield_uses_older_disabled_concessions;policyengine_uk/tests/policy/baseline/gov/dft/bus_journeys.yaml::Case 16, paying youth journeys remain priced and free-pass journeys cost nothing.The yield regression and Case 16 failed against the old parameter before the fix: a paying passenger's 100 trips cost £174.85 rather than £160.81. The new fit-parity test separately rejects the previous shares and previous fares under an in-memory mutation check; no tracked parameter file was changed for that check.
axiom: n/a: statistical fare benchmark and calibration correction; no statutory eligibility or policy rules change.
Validation after rebasing onto main:
uv run --frozen --no-sync pytest policyengine_uk/tests/test_bus_fare_parameters.py policyengine_uk/tests/test_bus_fare_reforms.py policyengine_uk/tests/test_parameter_descriptions.py policyengine_uk/tests/test_disable_simulated_benefits_winter_heating.py -q: 70 passed.uv run --frozen --no-sync policyengine-core test policyengine_uk/tests/policy/baseline/gov/dft -c policyengine_uk: 43 passed.uv run make format: repository-wide format and lint passed; affected fit tests passed afterward. Rebased touched Python files pass the format check.git diff --checkpass.The full certified-data suite was not run locally; CI runs the repository suite. The aggregate-impact dataset supplies no bus journeys, so its zero impact does not validate journey pricing. Local tests use fixture-scale journeys and reforms. No local documentation build was repeated for the methodology-only Markdown changes; book configuration is unchanged.