Commit 5056ce7
Anchor UC/PC/CB takeup flags to FRS-reported receipt (#359)
* Anchor UC/PC/CB takeup flags to FRS-reported receipt
FRS respondents who report positive receipt of a benefit are by
construction take-up=True. The prior code assigned `would_claim_uc`,
`would_claim_pc`, and `would_claim_child_benefit` by pure random draw
against the aggregate takeup rate, ignoring that information — which
meant a respondent reporting UC receipt could be randomly assigned
`would_claim_uc = False`, producing calibration noise.
Ports `assign_takeup_with_reported_anchors` from
`policyengine-us-data/utils/takeup.py`, pared down to the single-group
case (UK doesn't need the US's state-keyed grouping). Reporters are
forced to True; non-reporters are filled probabilistically to hit the
aggregate target rate across the full population, so the overall
takeup share still matches the target.
Applied to the three benefit-unit-level flags where FRS has a matching
reported column (`universal_credit_reported`, `pension_credit_reported`,
`child_benefit_reported`). Other takeup flags (TFC, childcare schemes,
SCP) have no FRS-reported counterpart and keep pure-random behaviour.
5 unit tests cover the new helper: pure-random fallback, reporters
always True, overall rate close to target, handling when reporters
already exceed target, and mask-length validation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Refresh uv.lock version after merge
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e132907 commit 5056ce7
4 files changed
Lines changed: 154 additions & 8 deletions
File tree
- changelog.d
- policyengine_uk_data
- datasets
- tests
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1217 | 1217 | | |
1218 | 1218 | | |
1219 | 1219 | | |
1220 | | - | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
1221 | 1235 | | |
1222 | 1236 | | |
1223 | 1237 | | |
1224 | 1238 | | |
1225 | 1239 | | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
1229 | 1246 | | |
1230 | 1247 | | |
1231 | 1248 | | |
1232 | 1249 | | |
1233 | | - | |
1234 | | - | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
1235 | 1254 | | |
1236 | | - | |
1237 | | - | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
1238 | 1259 | | |
1239 | 1260 | | |
1240 | 1261 | | |
| |||
Lines changed: 65 additions & 0 deletions
| 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 | + | |
| 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 | + | |
0 commit comments