Commit dfe5e6c
Calibrate combined self-employed NICs and skip inert Class 3 target (#379)
* Calibrate combined self-employed NICs target and skip inert Class 3
Two NI calibration gaps surfaced during issue audit (#88) and bug
report #378:
1. Recent OBR EFOs (e.g. March 2026) publish a single combined
"Class 4 and Class 2 Self employed NICs" line instead of two
separate rows. The parser's Class 2 / Class 4 candidate labels
no longer matched, so neither target was registered and
self-employed NICs were silently uncalibrated against OBR.
2. ni_class_3 is an input variable in PolicyEngine UK with no
formula and no dataset path that populates it. The matrix
column is therefore a flat zero, calibration cannot move it,
and the diagnostic that "the target is included" is misleading.
This commit:
- Adds an obr/ni_self_employed target whose values come from the
combined EFO line and whose matrix column is computed via a new
custom_compute that sums ni_class_2 + ni_class_4 at the household
level. Smoke-build on enhanced_frs_2023_24.h5 with year=2025:
6,848 non-zero households, target £2.90bn.
- Keeps the legacy Class 2 / Class 4 candidate labels around so
older or future EFOs that revert to separate rows still produce
individual targets.
- Removes the ni_class_3 entry from _parse_nics with a comment
pointing at #378 and the conditions for restoring it (a Class 3
imputation that addresses #88 in full).
Tests cover both layers:
- test_obr_nics.py: parser handles the combined EFO layout, the
legacy separate layout, and intentionally drops Class 3 in either
format.
- test_obr_nic_signal.py: the registered targets are present in
the registry, the combined target carries a custom_compute
callable, ni_class_3 is absent, and (gated on enhanced_frs) each
underlying PE-UK NI variable produces non-zero variation while
ni_class_3 returns a uniform zero — the very property that makes
it inert as a calibration target.
Closes #378. Partial close of #88 — Class 3 imputation remains a
separate follow-up.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Use direct self-employed NICs target variable
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Max Ghenis <mghenis@gmail.com>1 parent 0fe94f8 commit dfe5e6c
4 files changed
Lines changed: 281 additions & 91 deletions
File tree
- changelog.d
- policyengine_uk_data
- targets/sources
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
252 | 267 | | |
253 | 268 | | |
254 | 269 | | |
| |||
257 | 272 | | |
258 | 273 | | |
259 | 274 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
268 | 283 | | |
269 | 284 | | |
270 | 285 | | |
| |||
296 | 311 | | |
297 | 312 | | |
298 | 313 | | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
311 | 327 | | |
312 | 328 | | |
313 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
0 commit comments