Repository navigation
Conversation
`is_severely_disabled_for_benefits` is what policyengine-uk uses for the Child Tax Credit and Working Tax Credit severe disability elements (CTC Regs 2002 reg 8; WTC Regs 2002 reg 17). Those count the DLA care component at the highest rate, the PIP daily living component at the enhanced rate, higher-rate Attendance Allowance (WTC) and Armed Forces Independence Payment. The stored flag also counted lower-rate Attendance Allowance and FRS code 8, which covers every Armed Forces Compensation Scheme payment (including war disablement pensions and guaranteed income payments), not Armed Forces Independence Payment, which the FRS does not code. The legacy severe disability premium's wider list (any Attendance Allowance, DLA care middle rate, PIP daily living standard rate) is now read from the benefit categories in policyengine-uk rather than from this flag. A grid test pins the stored flag to the tax credit condition on the categories the same amounts map to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… model The stored flag and the benefit categories used two different floating-point comparisons, which disagreed at exactly the GBP 1/week tolerance edge (for example survey year 2022 at rate minus GBP 1.00). The flag now uses the category derivation itself, so the two agree by construction. The grid test covers survey years 2019-2026 and offsets either side of the tolerance edge, and fails on the old comparison. A differential test checks the stored flag against policyengine-uk's formula for the same categories; it skips on policyengine-uk releases that predate PolicyEngine/policyengine-uk#1946. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The differential test between the stored flag and policyengine-uk's formula no longer skips on older policyengine-uk releases: it fails until the lock includes PolicyEngine/policyengine-uk#1946, which keeps the new flag from shipping with a model that still reads it for the severe disability premium. The code comment and changelog now describe the flag as the tax credit condition and note that UC's higher disabled child addition, which is also keyed on it, differs (UC Regs reg 24(2)(b)). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Code 8's share of this PR's effect on a pre-1946 model, for d747. I ran real
So code 8 is under 0.5% of this PR's pre-1946 cost. The rest comes from its other changes: lower-rate Attendance Allowance and the category rule. Your note at the top measured on main On the policyengine-uk side, PolicyEngine/policyengine-uk#1946 (merged 2026-10-03) makes the matching formula change ( 🤖 Generated with Claude Code |
Summary
add_disability_benefit_flags_from_reported_amountsstoredis_severely_disabled_for_benefitsas:policyengine-uk uses that flag for three things:
Until PolicyEngine/policyengine-uk#1946 it also drove the legacy severe disability premium, which has a wider list. The stored flag served neither correctly:
The fix:
_reaches_weekly_ratereuses_category_from_reported_amount), so it agrees with the storedaa_category,dla_sc_categoryandpip_dl_categoryby construction. The earlier amount comparison disagreed with the categories at exactly the £1/week tolerance edge, for example in survey year 2022 at rate minus £1.00.receives_severe_disability_premium_qualifying_benefit, which reads those categories, not this flag.is_severely_disabled_for_benefitsthis definition, so the stored value and the formula agree.Law re-verified on legislation.gov.uk (current revised text) on 2026-09-30. The FRS code frame was checked against the UKDA data dictionary for study 9563 and the DWP FRS 2024-25 benefits documentation.
Tests
test_attendance_allowance_feeds_stronger_disability_flags: lower-rate AA is no longer severe; higher-rate AA is.test_armed_forces_compensation_scheme_is_not_a_severe_disability:afcs_reportedalone setsis_disabled_for_benefitsbut not the severe flag.test_severe_flag_is_the_tax_credit_condition_on_the_categories: an exhaustive grid of AA, DLA care and PIP daily living amounts for survey years 2019 to 2026.aa_category == HIGHER | dla_sc_category == HIGHER | pip_dl_category == ENHANCEDon the categories the same amounts map to.test_severe_flag_matches_the_policyengine_uk_formula: a differential test between the stored flag and policyengine-uk's formula for every category combination on the grid.PYTHONPATH).test_disability_benefits.pygives 11 passed and the intended differential failure.test_frs_only_imputation.pyandtest_legacy_benefit_proxies.pypass.Effect
Measured with real policyengine-uk
Microsimulationruns on the Enhanced FRS 2024-25, against a copy whose stored flag was recomputed from the stored categories with this definition. The script ismake_flag_dataset.py; it touches no other column. The copy was compared with the unchanged dataset.Follow-up
The FRS codes for Adult Disability Payment (117, 118) and Child Disability Payment (121, 122) are not mapped, so Scottish recipients have no disability benefit in the model: #500.
🤖 Generated with Claude Code