Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The `spi_benefit_coherence` receipt now shows how much of the SPI copies' contributory JSA and ESA rests on pension payments, which the stage does not reduce the awards for (Vahid's review of microcosm#1426). For each award it gives the support and weighted award of the copies whose pension payments are above the award's threshold. Pension payments here are `private_pension_income`, the SPI tape's PENSION, over 52 weeks. The thresholds are £50 a week for JSA, above which JSA Regs 1996 reg 81 takes every pound off the award (policyengine-uk's `gov.dwp.JSA.contrib.pension_disregard`), and £85 a week for ESA, above which ESA Regs 2008 reg 74 takes half of every pound. The figure is the most such a reduction could take off. It is withheld where one or two source households carry it or the rest of the award. The stage's docstring now also says why the awards are not reduced, and that its weekly work tests average the tape's annual pay over 52 weeks, which understates part-year claimants.
24 changes: 24 additions & 0 deletions changelog.d/1359-lcfs-cross-fitted-gates.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
The LCFS consumption chain cross-fits its sign gates (`gate_calibration: cross_fitted` on its `fit_weighted_qrf_chain`). The in-sample gates had never seen the frame's households, and drew rare spending on them too rarely; now each sign is drawn at its donor rate on households the gates were not fitted to.

Shares of households with each spending, at prior weights. Each is a full spine built from main, then the same build with the cross-fitted gates; LCFS donors in brackets:
- solid fuels: 0.30% → 2.17% (2.47%);
- liquid fuels: 3.10% → 3.91% (4.54%);
- education: 4.29% → 6.71% (5.83%);
- tobacco: 8.17% → 11.04% (10.34%);
- gambling stakes: 14.49% → 16.76% (17.03%);
- betting and gaming, as the diary draws it before the gambling top-up: 1.95% → 2.70% (3.58%).

The near-universal divisions' zeros are now drawn at their rate too:
- food: 99.67% → 99.05% (99.15%);
- recreation: 98.91% → 97.02% (97.27%).

The twelve divisions' prior-weighted total falls 1.5%, and the six divisions held at the shared frame-to-donor ratio fall with it.

The prior-weighted full-rate VAT base, the twelve divisions times each household's full-rate share, falls 1.7%. Read it as a ratio. policyengine-uk's survey VAT consumption coverage matches receipts on the cut it is derived on, so re-deriving it on the first cut built with this change should move it by about the same ratio: to about 0.68 from the 0.69 that PolicyEngine/policyengine-uk#2634 derives on `a6299504`, a cut built without it.

The excise inputs keep their national levels, but the multiples of spending change:
- tobacco duty is about 1.8 times the tobacco spending of the households that carry it, down from 2.2;
- alcohol duty is 0.44 times alcohol spending, up from 0.40;
- the gambling top-up keeps the National Lottery and betting and gaming keys at GSGB participation in both builds. With the diary-level stakes lower, Lottery Duty goes from 0.58 to 0.63 times National Lottery stakes. The other gambling duties go from 4.9 to 5.3 times betting and gaming stakes.

Every LCFS stage-health gate passes. The gambling stake scale needs the lower floor of 0.3 (María's ruling of 2026-11-03).
10 changes: 10 additions & 0 deletions changelog.d/1359-qrf-gate-calibration.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
`RegimeGatedQRF` takes a `gate_calibration`, named by the new `GateCalibration` constants. The default, `in_sample`, is the sign gate as before, and its draws do not move. That gate is one boosted classifier, calibrated only on its own training rows. It memorises a rare class's training rows, so on every other row, every recipient included, it draws that class too rarely.

`cross_fitted` fits a gate on each of five folds of the training rows, stratified by class. One weighted calibration (Platt scaling, for two classes) is fitted on the gates' out-of-fold scores and maps each of them, and a row's probability is the mean of the mapped gates. A rare class is then drawn at its rate on rows the gates were not fitted to.

- **Where the balance holds.** The rate balance is exact on the pooled out-of-fold donor scores, not on any recipient set.
- **What moves.** The forests and the draw uniforms are unchanged. In a chain, though, a sign that changes moves later targets' amounts through their predictors.
- **Grouped folds.** `groups` (on `fit`, `start_chain` and `fit_draw_next`, and the `fit` helper) deals whole groups, such as a household's members, to the same fold. A chain locks its grouping and refuses a step that changes it.
- **Fallbacks.** A target keeps the in-sample gate when a class has fewer rows (or groups) than folds, or when a fold's training rows carry no weight for a class. The calibration falls back to the class rates when its balance cannot be met or the out-of-fold ranking is worse than none.
- **Recorded outcomes.** `FittedRegimeGatedQRF.gate_outcomes()` names what each target got, with the new `GateOutcome` constants, and the `fit.qrf@1` graph kernel takes `gate_calibration` too.
- **Checkpoints.** A chain checkpoint names the calibration only when it is cross-fitted, and the grouping only when it was given, so in-sample checkpoints are unchanged.
15 changes: 15 additions & 0 deletions changelog.d/1359-uk-cross-fitted-gates.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Every other UK imputation whose QRF draws a sign through the gate now cross-fits it too. That covers:
- the ETB services and WAS wealth chains;
- the SPI tape forest, the FRS reference forests its rank transport reads, and the FRS-only stage 2;
- the SPI housing shell's amounts, the NTS bus-use band, salary sacrifice and the Universal Credit reporter redraw;
- the LCFS prepayment-meter and zero-road-fuel redraws.

Fits on people or benefit units deal each household to one fold. Each stage's evidence names every gate's outcome under `gate_outcomes`. The ETB VAT rate is positive on every donor, so its fit has no gate and does not change.

**On held-out donors**, out of fold, the cross-fitted gate draws each fit's rarest sign within 10% of its rate on 167 of 168 gated UK fits, against 122 for the in-sample gate, and it has the lower log loss on 165.

**On a full spine from main**, at prior weights, the largest moves outside LCFS are:
- WAS student loan balances: 2.86% → 3.79% of households (donors 6.66%);
- ETB rail support: 14.15% → 15.89% (donors 16.52%).

The NTS, salary sacrifice and UC reporter draws move by under 0.1 points. The CGT incidence clones key on the SPI-drawn incomes, so the frame has 0.4% fewer households, at the same total weight. A full spine build takes about 22 minutes, against 12.
1 change: 1 addition & 0 deletions changelog.d/1359-uk-gambling-stake-scale-floor.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The gambling participation gate (`uk_stage_lcfs_consumption_gambling_participation`) lets the stake scale fall to 0.3 instead of 0.5 (María's ruling of 2026-11-03, microcosm#1359). The scale is what the stage multiplies the added regular players' drawn stakes by to bring their mean to the seen players'. With the LCFS chain's sign gates cross-fitted, the chain draws betting and gaming for more of the diary's households, at about the donors' own stake per player. So the seen players' mean falls, and with it the scale, from 0.63 to about 0.41, while the stake draws themselves do not move. Incidence and the duty bases are unchanged: every key still reaches its GSGB participation, and every base its published level. A draw that puts the added players' mean more than about 3.3 times the seen players' still fails, as one under 0.4 times does.
16 changes: 8 additions & 8 deletions docs/evidence/spec-engine/us-f0-coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -1642,13 +1642,13 @@
"compiler_ir.node_slices"
],
"expected": {
"map_sha256": "99fafd886bc7a022fcc4718169c5d9eef336d44cea849998a4584f243ac8c3cf",
"protocol_sha256": "61b4206ab27a7d9c616ba6caa6c8a3f537fc35222e9eae2ca4f665dbeef6a08d"
"map_sha256": "2ca5e0a6c53617cc6e025086e883eab8209f153547dfdb09ea220d2ff35dfe60",
"protocol_sha256": "d8217ce7f319cebdbcf8125e1313ae951fc7f03bcad7ed3550f498c4cc31e269"
},
"failures": [],
"observed": {
"map_sha256": "99fafd886bc7a022fcc4718169c5d9eef336d44cea849998a4584f243ac8c3cf",
"protocol_sha256": "61b4206ab27a7d9c616ba6caa6c8a3f537fc35222e9eae2ca4f665dbeef6a08d"
"map_sha256": "2ca5e0a6c53617cc6e025086e883eab8209f153547dfdb09ea220d2ff35dfe60",
"protocol_sha256": "d8217ce7f319cebdbcf8125e1313ae951fc7f03bcad7ed3550f498c4cc31e269"
},
"status": "covered"
},
Expand All @@ -1663,7 +1663,7 @@
"compiler_ir.seed_stream_map"
],
"expected": {
"implementation_sha256": "61b4206ab27a7d9c616ba6caa6c8a3f537fc35222e9eae2ca4f665dbeef6a08d",
"implementation_sha256": "d8217ce7f319cebdbcf8125e1313ae951fc7f03bcad7ed3550f498c4cc31e269",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand All @@ -1684,7 +1684,7 @@
},
"failures": [],
"observed": {
"implementation_sha256": "61b4206ab27a7d9c616ba6caa6c8a3f537fc35222e9eae2ca4f665dbeef6a08d",
"implementation_sha256": "d8217ce7f319cebdbcf8125e1313ae951fc7f03bcad7ed3550f498c4cc31e269",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand Down Expand Up @@ -2585,7 +2585,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "fe3901b59a02c22978cc57a296afddfca91732f952c8ebc0ed9d44f3bfe6bf16"
"spec_sha256": "a6bb8fc46541352972195992cdc1b2401637322d353992d6321f204d5c74245a"
}
},
"report_schema_version": 3,
Expand All @@ -2595,7 +2595,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "fe3901b59a02c22978cc57a296afddfca91732f952c8ebc0ed9d44f3bfe6bf16"
"spec_sha256": "a6bb8fc46541352972195992cdc1b2401637322d353992d6321f204d5c74245a"
},
"status": "pass"
}
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@
# microcosm#1259's recipient-share bound in puf_support moves both again.
# microcosm#1261 moves both again: the PUF donor carries partnership and
# S-corp line-32 shares as separate leaves.
"seed_map": '99fafd886bc7a022fcc4718169c5d9eef336d44cea849998a4584f243ac8c3cf',
"seed_protocol": '61b4206ab27a7d9c616ba6caa6c8a3f537fc35222e9eae2ca4f665dbeef6a08d',
"seed_map": '2ca5e0a6c53617cc6e025086e883eab8209f153547dfdb09ea220d2ff35dfe60',
"seed_protocol": 'd8217ce7f319cebdbcf8125e1313ae951fc7f03bcad7ed3550f498c4cc31e269',
"source_manifest": "608c3621b1e4a108e57c8f83d16a184acdb3d05e16a81b895f7f72dbf5d0685c",
"take_up": "9522ce40f7dea569312dd7a7beb474e5a5afadd2f1e10cb5876534c3ef623d35",
"tail": "071d418bb49976f4682c320d2ad07097c177de3a645d2524f235e1ff33ac83f9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3223,6 +3223,12 @@
},
"weight": {
"type": "string"
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
},
"required": [
Expand Down Expand Up @@ -3592,6 +3598,12 @@
"null"
]
}
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
},
"required": [
Expand Down Expand Up @@ -3724,6 +3736,12 @@
},
"weight_mapping": {
"type": "string"
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
},
"required": [
Expand Down Expand Up @@ -7744,6 +7762,12 @@
"salt": {
"type": "string",
"minLength": 1
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down Expand Up @@ -7787,6 +7811,12 @@
},
"seed": {
"type": "integer"
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down Expand Up @@ -8385,6 +8415,12 @@
"null"
]
}
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down Expand Up @@ -8485,6 +8521,12 @@
},
"seed": {
"type": "integer"
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down Expand Up @@ -8580,6 +8622,12 @@
},
"seed": {
"type": "integer"
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down Expand Up @@ -8685,6 +8733,12 @@
},
"seed": {
"type": "integer"
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down Expand Up @@ -8951,6 +9005,12 @@
},
"seed": {
"type": "integer"
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down Expand Up @@ -11501,6 +11561,12 @@
}
}
}
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down Expand Up @@ -13439,6 +13505,12 @@
"n_estimators": {
"type": "integer",
"minimum": 1
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down Expand Up @@ -13480,6 +13552,12 @@
"n_estimators": {
"type": "integer",
"minimum": 1
},
"gate_calibration": {
"enum": [
"in_sample",
"cross_fitted"
]
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/microcosm-build/src/microcosm/build/uk/gates.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,12 @@
"maximum_relative_deviation": 1e-09,
"maximum_stratum_shortfall": 0.01,
"amount_scale_bounds": [
0.5,
0.3,
2.5
],
"required_support_band": "30+"
},
"notes": "Stage-time fact check on the lcfs gambling_participation receipt (microcosm#1359): each key's adult participation rates (the National Lottery's products, and the betting and gaming the other gambling duties charge; past four weeks and past twelve months, by sex and age band) are recomputed from the vendored GSGB 2025 rows through the stage's own declaration, never taken from the receipt, and must equal the receipt's, and the receipt's settings (theta per key, the occasional players' stake share, the strata, the propensity classifier, the seed and the salt) must be the declared ones. Per key, each household stratum the receipt gives must sit within maximum_stratum_shortfall of its four-week target and from there of its twelve-month target, or add no household where the diary already passed a target; the national shares must reach the targets less that shortfall; no added household may lack a stake; the three classes' shares of the key's stakes must sum to one; the scale that brings the added regular players' mean stake to the seen households' must lie in amount_scale_bounds, so a broken stake draw that the anchoring would otherwise hide fails (Vahid's review, round 4; the upper bound rose from 2.0 to 2.5 on María's ruling of 2026-10-26, since full spine builds scale the National Lottery's added regular players by about 2.03); the propensity must rest on 30 or more donors; and the excise levelling must have shared the gambling bases by the topped-up keys, each key positive on its twelve-month share. The receipt withholds a stratum with a cell on one or two source households, which the gate counts rather than checks; a key withheld nationally fails. The rates are recomputed from the same vendored rows the stage read, so the check catches a step that did not apply the declared rates or settings; it cannot catch an error in the rows themselves, and the stratum targets, which need the frame's adults, are the step's own (it refuses a stratum it cannot fill). A population fact check: the synthetic smoke records it without blocking."
"notes": "Stage-time fact check on the lcfs gambling_participation receipt (microcosm#1359): each key's adult participation rates (the National Lottery's products, and the betting and gaming the other gambling duties charge; past four weeks and past twelve months, by sex and age band) are recomputed from the vendored GSGB 2025 rows through the stage's own declaration, never taken from the receipt, and must equal the receipt's, and the receipt's settings (theta per key, the occasional players' stake share, the strata, the propensity classifier, the seed and the salt) must be the declared ones. Per key, each household stratum the receipt gives must sit within maximum_stratum_shortfall of its four-week target and from there of its twelve-month target, or add no household where the diary already passed a target; the national shares must reach the targets less that shortfall; no added household may lack a stake; the three classes' shares of the key's stakes must sum to one; the scale that brings the added regular players' mean stake to the seen households' must lie in amount_scale_bounds, so a broken stake draw that the anchoring would otherwise hide fails (Vahid's review, round 4; the upper bound rose from 2.0 to 2.5 on María's ruling of 2026-10-26, since full spine builds scale the National Lottery's added regular players by about 2.03; the lower bound fell from 0.5 to 0.3 on her ruling of 2026-11-03, since the chain's cross-fitted sign gates (microcosm#1359) draw betting and gaming for more of the diary's households at about the donors' own stake per player, which takes that key's scale to about 0.41); the propensity must rest on 30 or more donors; and the excise levelling must have shared the gambling bases by the topped-up keys, each key positive on its twelve-month share. The receipt withholds a stratum with a cell on one or two source households, which the gate counts rather than checks; a key withheld nationally fails. The rates are recomputed from the same vendored rows the stage read, so the check catches a step that did not apply the declared rates or settings; it cannot catch an error in the rows themselves, and the stratum targets, which need the frame's adults, are the step's own (it refuses a stratum it cannot fill). A population fact check: the synthetic smoke records it without blocking."
},
{
"id": "uk_stage_lcfs_consumption_basis",
Expand Down
Loading
Loading