Repository navigation
Draw LCFS spending as a budget and a donor's mix, and fix the donor's income predictors (#1717) - #1736
Conversation
… income predictors (#1717) The LCFS stage's imputed spending ran a quarter above its donor in the bottom income decile. Two causes, two fixes: - Fix A: the donor's income predictors now carry the frame's concepts. employment_income is p008p (normal gross wage, 13-week rule), not b303p (pay last time paid); self_employment_income sums p047p and p037p (main and subsidiary self-employment), not b3262p alone. - Fix B: the spending is no longer chained target by target. The new draw_budget_and_mix operation reads each household's budget (total spending over the twelve COICOP divisions) between neighbouring donors' totals in a forest neighbourhood, and takes one donor's mix, drawn from a share forest at the predictors and that budget, scaled to the budget. The general tools are forest_neighbourhoods, keyed_neighbour_donors and keyed_neighbour_quantiles in microcosm.fit.donors. A decile_fit receipt sets the frame's spending beside the donor's by income decile on every build, and the report-only gate uk_stage_lcfs_consumption_decile_fit warns when a decile 1 to 9 leaves the donor's shape by more than 10%. Lockstep surfaces: sources manifest and projection, schema branch and kind allow-list, stage hash binding and spine seed key, H2 fixture, coverage manifest, gate battery registries and digests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…icality in the national-role fixture (#1717) Scaling a donor's basket to a household's budget could take a spend target past the donor survey's range, so the support clip clipped rows and its release-blocking gate, which allows none, failed the UK smoke build. A household whose scaled basket would leave the range now keeps its budget and takes a donor drawn afresh, at a third keyed uniform, from the neighbours whose basket fits; one none of whose neighbours fits takes the budget nearest its own that its donor's basket allows. Households whose first basket fits keep it. The national-role test's bound spine report marked every spine gate release-blocking; it now records each gate's declared criticality, as the calibration seam's fixture does, since the spine scope carries the diagnostic decile gate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vahid-ahmadi
left a comment
There was a problem hiding this comment.
Reviewed at 971cb5be0. This is a clear diagnosis and a well-chosen fix. Drawing one budget and one donor mix removes the chain's compounding pull to the middle. The holdout results (bottom decile 0.97 against 1.13 for the chain, all deciles within 0.96 to 1.04) are convincing. test_donors.py and test_uk_lcfs_consumption.py pass locally (167 passed).
Fix A. The new predictors (p008p, normal gross pay on the 13-week rule; p047p + p037p, main plus subsidiary self-employment) match the frame's gross concepts, and b303p (last pay) and b3262p (the first subsidiary job only) were clearly the wrong ones. I didn't verify the codes against the LCF 2024-25 User Guide Volume F myself, so that rests on your reading.
Points
- The top decile at 1.20. You say its incomes reach beyond the donor's. Because the budget comes from a quantile of donor totals in the neighbourhood, a frame household above the donor's income range gets a budget near the richest donors', so 1.20 comes from the frame's mix, not from extrapolation. The decile-10 figure is reported, not gated, which is fine. I'd add the frame's share of households above the donor's income maximum to the
decile_fitreceipt, so the 1.20 can be read against it. - Mix repetition. About 35,000 frame households draw their mix from about 5,000 donors, so on average 7 households share each donor's shares. Budgets differ, so baskets don't repeat (0.5%). But within-decile variation in division shares is limited to the donor pool's. Your correlations at the sampling floor suggest that's fine. For any analysis that cuts spending by small groups (a region and decile cell, say), the effective number of distinct mixes per cell is the number to watch, so it might be worth putting in the receipt.
- The range step's fallback. "Fewer than three keep their donor at the nearest budget" is reassuring. One way to make sure it stays rare on future builds: a receipt count for this path, with a warning above some small share, alongside the 0.7% redraw count.
- Negative-income households. These are left for #1717, which is sensible. Until then, it would help to state in the stage notes how they draw: through the forest on a negative predictor, presumably landing with low-income donors.
Nothing blocks it from my side.
Review drafted with AI assistance and checked against the code at 971cb5be0.
…ehold mix (#1717) The decile_fit receipt now gives each decile's mean, ratio and shape twice: against the donor as surveyed, and against the donor reweighted, within each income decile, to the frame's household mix of adults (1, 2, 3+), children (0, 1, 2+), cars (0, 1, 2+) and tenure, raked in turn. Before raking, a category with fewer than three donor households joins another. A donor category the frame lacks gets no weight, and no household's weight moves more than five times either way. The receipt records whether each decile met the frame's mix. The report-only gate uk_stage_lcfs_consumption_decile_fit declares the donor it holds the frame to (shape_reference) and now reads the reweighted shape. A frame whose households spend what the donor's households like them spend sits at 1, so a difference between the two surveys' household mixes no longer sets the gate off. On the licensed stage replay, decile 1's shape is 1.05 against the reweighted donor, against 1.15 against the donor as surveyed. Against the reweighted donor, the chain's decile 1 stays at 1.21 and fix A's alone at 1.23. Re-pinned: the gate battery's policy, manifest and fingerprint digests and the spine part's two, with the data contract's test mirror. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… decile (#1717) From the review of #1736 at 971cb5b: - The draw's result now names each household's mix donor, and the households the range step redrew or moved to another budget. - A budget_and_mix receipt records the range step on every build. For each path it gives the support band and the shares, unweighted (floored to the hundredth) and at the design weights. Each is withheld where one or two source households carry it. - The decile_fit receipt gives the effective number of donors behind the frame's mixes, the inverse Simpson index at the design weights, in each decile and in each region's deciles. It is withheld under three. - The draw's docstring now says how a negative-income household draws. The forests read incomes as values, so it sorts with the donors at the bottom of every split on income. Not added: the frame's share of households above the donor's income maximum. It would turn on one LCFS household's income. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, Vahid. Since your review, the decile gate compares the frame with the donor reweighted, within each decile, to the frame's household mix of adults, children, cars and tenure (cb2f994). On the licensed replay, decile 1's shape against that reweighted donor is 1.05, so the gate passes; against the donor as surveyed it is 1.15. On your points, at 469ddf9:
|
Main had moved 177 commits on. Four files conflicted, each a pinned or generated surface that both sides had moved: - the gate battery's policy, manifest and fingerprint digests and the spine part's two, in the data contract and its test mirror, recomputed from the merged spec. The contract keeps the decile gate's entry, diagnostic, evidence and spine-scope registrations; - the release input coverage manifest, regenerated; - the H2 parity fixture, regenerated (--check byte-identical). Main's policyengine-uk 2.180.0 comes in with the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…beside the LCFS decile receipt (#1717) PolicyEngine/chronicle#450 adds ONS Family Spending, financial year ending 2025 (workbook 1, Tables 3.1E and A6). It is the official reference #1717 asked for beside the LCFS stage's frame-against-donor decile comparison. - The UK feed is re-pinned to 4e7d7746, #450's head on Chronicle main ece6bb29: 2,160,837 rows, against 15040ea5's 2,160,350. The surfaces were regenerated in docs/uk-chronicle-feed-repin.md's order. - Every 15040ea5 row is byte-identical, and the 487 new rows are #450's. - The national references and both compile-parity receipts are byte-identical. - The other surfaces change only their feed identity. The DESNZ constituency resource keeps its 2,526 values, with new keys. - The local references gain the CenTax hierarchy category that #1399 declared. - The new vendored ons_family_spending_income_decile_facts.json (133 rows) holds Table 3.1E's deciles on the updated OECD-modified scale and all households. The country package and the LCFS stage declare it. - family_spending_by_decile() reads it. For each decile, in total and by division, decile_fit sets the published weekly mean and its shape beside the frame's and the donor's own profiles. A profile is each decile's mean over its deciles 4 to 7. The reading is report-only: an unavailable table records its reason. - On the licensed stage replay: - the donor's profile sits within 0.93 to 1.10 of the published shape in every decile, with the bottom decile at 0.98; - the frame's bottom decile sits at 1.13. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PolicyEngine/chronicle#450 merged into Chronicle main as e4d46c93, onto an unmoved base, so the merge commit's tree is the pull request head's (4e7d7746). The consumer artifact's manifest records no commit, so the artifact built from that head is the merge commit's. The pin and every surface that restates the feed identity move to the merge commit, as microcosm#1421 moved from PolicyEngine/chronicle#392's head to its merge. - Every vendored resource changes only its pin stamps. - The DESNZ constituency resource keeps its 2,526 rows and values, with new keys and build date. - The local membership also moves the DESNZ cells' derived fact keys, and the local census restates the DESNZ resource's new digests. - The release input coverage manifest and the H2 fixture move only their digests. - The national and local references and both compile-parity receipts record no commit and are unchanged. - The pin tests, the runbook entry and the changelog fragment name e4d46c93. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
María's renewal of 2026-11-27 ("renew them all in the pr, use today's date"). From 27 November the engine-free suite
failed two expiry clocks: the 22 uprating holds and the ORR rail-support measure exclusion lapse on 2026-12-11, inside
UK_HOLD_EXPIRY_NOTICE_DAYS (14). Fourteen more entries lapse between 1 and 10 December. The target-fit and area-support
gates fail an expired entry, so the next local build could not certify with them.
- uk/uprating_holds.json: the 22 holds, approved 2026-11-27 and expiring 2027-01-27, the two months the holds of
2026-10-11 were signed for. Holds 9 (public transport support) and 16 (SLC student support) now say that the editions
they wait for had not reached Chronicle at the renewal.
- uk/calibration_measure_exclusions.json: orr.rail_government_support, renewed with the holds to 2027-01-27. Its
adjudication records the renewal: no build since 2026-10-24 has measured the row bound.
- uk/target_fit_reviewed_exclusions.json (5 national rows) and uk/local_target_fit_reviewed_exclusions.json (6 local
cells): the local line's gate-only sign-offs, renewed for 28 days to 2026-12-25 (draft_uk_dense_signoff.py's
FIT_WINDOW_DAYS), as the renewal of 2026-11-22 did. Each cites the current local release, dense build-2 attempt
uk-local-candidate-f100-s42-20261123T075147Z-7081d968 (full gate report sha256 fbf5a2be5138e352...), which still
breaches it. None is stale.
- uk/local_area_support_exclusions.json: the Isles of Scilly and City of London support-floor exclusions and the
census-households bound family, renewed for three months to 2027-02-27 (AREA_WINDOW_MONTHS) with their wording
unchanged. Both areas are still below the floor on that release.
- Tests: the battery clock moves to 2026-11-27, and the earliest expiry ahead is now 2026-12-14. The ORR row's and the
census-households family's date pins follow.
Next to lapse: 11 more local-line target-fit sign-offs on 2026-12-14, and 3 holds on 2026-12-15, whose clock fails the
suite from 2026-12-01.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
María's go of 2026-11-27 ("Yes, renew them") for the next entries to lapse after the renewal in 217ccdd:
- the three uprating holds of 2026-10-15 that expire on 2026-12-15, whose clock would fail the engine-free suite from
2026-12-01;
- the eleven local-line gate-only target-fit sign-offs of 2026-11-16 that expire on 2026-12-14 (six national rows and
five local cells).
- uk/uprating_holds.json: DfT BUS01a bus journeys, DESNZ sub-national consumption and DESNZ gas-connected households,
approved 2026-11-27 and expiring 2027-01-27, so all 25 renewed holds lapse together.
- uk/target_fit_reviewed_exclusions.json and uk/local_target_fit_reviewed_exclusions.json: renewed for 28 days to
2026-12-25. Each cites the current local release (uk-local-candidate-f100-s42-20261123T075147Z-7081d968, full gate
report sha256 fbf5a2be5138e352...), which still breaches it, and none is stale. Today's 22 fit renewals share one
adjudication.
- The battery clock stays on 2026-11-27, and its comment names the earliest expiry ahead, now 2026-12-20. The
changelog fragment covers all 51 entries.
Next clocks: the holds' fails the suite from 2026-12-20 (two holds expire 2027-01-03). The measure exclusions' fails
from 2026-12-25 (seven entries and the support floor expire 2027-01-08).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the e4d46c93 feed and the new CI caps (#931) Main took six pull requests since 4b78a9b: #1736 (LCFS spending drawn as a budget and a donor's mix, with a decile receipt beside ONS Family Spending, the UK feed re-pinned to Chronicle e4d46c93, and register renewals), #1779 (the CI caps from the slowest legs of 19 to 26 Nov), #1772 (a batch file's error skips the fallback), #1767 (New Zealand declares its receipt's take-up cap), #1751 (the US post-export H5 path) and #1723 (US QRF identity tests). The engine lock does not move. Eight files conflicted. - uk_runtime/lcfs_consumption.py: main's receipt imports and the clip's docstring, which now names the mix donor and keeps this branch's count of distinct source households over every clone. Main's new decile and range-step receipts count the frame's support in distinct source households (source_household_id), so on the clone-first spine a source household's clones count once. - uk_runtime/graph_kernels.py: the LCFS stage keeps this branch's full list under the derived binding rule and adds microcosm.fit.donors, which main's draw computes through. - uk_runtime/calibration_run.py: main added the LCFS decile gate to the spine gate scope, which this branch keeps in gate_scopes.py; the gate goes there. - .github/workflows/test.yml: main's caps and their basis, and this branch's note on the after-merge job's cap. - The gate contract pins, the coverage manifest and the H2 fixture are recomputed on the merged tree. The feed. Main moved the UK feed from Chronicle 15040ea5 to e4d46c93 and recorded that every 15040ea5 row is byte-identical there, the 487 new rows being ONS Family Spending. This branch's own Scottish Band D facts take the new pin stamps with their 32 rows unchanged, as main's re-pin did for its vendored resources; the local membership takes main's feed label and DESNZ keys beside this branch's two UC seat deferrals. The vendor tool's check against the e4d46c93 artifact did not run here, which lacks that artifact. Checks: with policyengine-uk hidden, as in CI's engine-free job, the tests main's six pull requests change, the LCFS, consumption, Band D, vendoring and feed tests, the UK graph's binding rules, the nesting, stage health, battery, contract, gate and coverage tests (2,245 pass; the vendoring test that rebuilds the vendored resources from a local copy of the pinned feed refuses this machine's 15040ea5 copy, as it should, and skips in CI, which has none); the US coverage report and pins (--check); CI's test plan verify; and on the engine, H2 parity, the UK graph, the consumption resources and the release input coverage (56 pass). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Closes #1717. On the certified national build, imputed spending in the bottom income decile ran a quarter above the LCFS donor. The diagnosis found two causes, and this PR fixes both. It also adds a receipt and a report-only gate that set the frame's spending beside the donor's by income decile on every build. The receipt's official reference is ONS Family Spending (PolicyEngine/chronicle#450), read from a re-pinned Chronicle feed.
Fix A: the donor's income predictors
The frame's predictors are gross pay and self-employment profit; the donor now reads the same concepts (LCF 2024-25 User Guide Volume F).
employment_income:p008p, normal gross wage or salary on the 13-week rule. It wasb303p, the pay last time paid.self_employment_income:p047pplusp037p, income from main and from subsidiary self-employment. It wasb3262p, the first subsidiary job's profit alone.Fix B: one budget and one mix per household, instead of a chain
The chain drew each spend target conditioned on the earlier random draws. That compounded the forests' pull to the middle at the bottom of the income range. The new
draw_budget_and_mixoperation works in four steps.A household with a negative income, a self-employment loss say, draws like any other: both forests read incomes as values, so it sorts with the donors at the bottom of every split on income.
The general tools are in
microcosm.fit.donors:forest_neighbourhoods,keyed_neighbour_donorsandkeyed_neighbour_quantiles.microcosm.fit's__init__.py,qrf.pyandmodel.pyare untouched, so no fit kernel pin and no US pin moves.microcosm.fit.donors, asspi_employment_shell's does.Measured on licensed data, in a local lane; aggregates only
The LCFS 2024-25 holdout. The draw is fitted on half the diaries and imputes the other half, over 12 splits, on the fix-A donor.
On the stage's own input (the certified build's spine), 0.5% of frame households share an exact basket with another. A draw that copies one donor's whole basket gives 99%. Mixes repeat, with about 35,000 frame households on about 5,000 donors; budgets do not.
Stage replay of this PR on that input. Frame spending over donor spending by income decile, after the stage's clip, rake and levelling, as the stage's
decile_fitreceipt gives it:Receipt and gate
decile_fit, in the stage's evidence.ons_family_spending_income_decile_facts.json. An unavailable table records its reason.budget_and_mix, in the stage's evidence: the range step on every build. For the households given a new donor and for those moved to another budget, it gives the support band and the shares, unweighted (floored to the hundredth) and at the design weights.uk_stage_lcfs_consumption_decile_fit: a diagnosticstage_healthgate in the transferred phase.shape_reference: reweighted_donor). A frame whose households spend what the donor's households like them spend sits at 1, so a difference between the two surveys' household mixes doesn't set it off.The Chronicle re-pin
The UK feed is re-pinned to Chronicle e4d46c93, the merge of PolicyEngine/chronicle#450. It has 2,160,837 rows, against 15040ea5's 2,160,350. The merge commit's tree is #450's head's (4e7d7746), so the artifact was built from that head and carries the merge commit's identity. Every surface was regenerated in
docs/uk-chronicle-feed-repin.md's order.Lockstep surfaces
sources.yamland itssource_stages.jsonprojection, a schema branch and the operation-kind allow-list;gates.jsonand the binding's parameter vocabulary;Tests run locally
These all pass:
test_donors.py;tools/ci_test_plan.py verifyis ok,tools/build_uk_release_input_coverage_manifest.py --checkreports current, and the H2 fixture regenerates byte-identically.This closes #1717. Two questions it raised stay open: the target level for deciles 1 to 9, and how the frame's negative-income households should draw.
🤖 Generated with Claude Code