Skip to content

Conversation

@MaxGhenis
Copy link
Collaborator

Summary

  • Move stochastic variable generation from country package to data package
  • Variables now read pre-computed values from datasets for deterministic, reproducible calculations
  • is_higher_earner uses age as deterministic tie-breaker instead of random noise

Changes

Variable Change
would_claim_pc Remove formula, use default_value = True
would_claim_uc Remove formula, use default_value = True
would_claim_child_benefit Remove formula, use default_value = True
child_benefit_opts_out Remove formula, use default_value = False
would_evade_tv_licence_fee Remove formula, use default_value = False
household_owns_tv Remove formula, use default_value = True
main_residential_property_purchased_is_first_home Remove formula, use default_value = False
is_disabled_for_benefits Remove formula, use default_value = False
would_claim_marriage_allowance New variable for take-up decision
marriage_allowance Use would_claim_marriage_allowance instead of random()
attends_private_school Use pre-generated random draw from dataset
is_higher_earner Use age as deterministic tie-breaker

Related PRs

  • policyengine-uk-data#246: Adds stochastic variable generation to data package

Test plan

  • CI passes
  • Manual testing with dataset confirms deterministic results

🤖 Generated with Claude Code

MaxGhenis and others added 4 commits January 16, 2026 21:12
Move stochastic variable generation to data package. Variables now read
pre-computed values from datasets for deterministic, reproducible
calculations.

Changes:
- would_claim_pc, would_claim_uc, would_claim_child_benefit,
  child_benefit_opts_out, would_evade_tv_licence_fee, household_owns_tv,
  main_residential_property_purchased_is_first_home,
  is_disabled_for_benefits: Remove formulas, use default_value
- would_claim_marriage_allowance: New variable for take-up decision
- marriage_allowance: Use would_claim_marriage_allowance instead of random()
- attends_private_school: Use pre-generated random draw from dataset
- is_higher_earner: Use age as deterministic tie-breaker instead of random()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Tests verify:
- Default values work correctly in policy calculator mode
- Variables can be explicitly overridden in situations
- is_higher_earner uses deterministic tie-breaking (older wins)
- Calculations are deterministic across multiple runs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add SCP variable and parameters with would_claim_scp for deterministic
take-up (matching the pattern for other benefits in this PR).

Changes:
- Add would_claim_scp variable (default True, generated in dataset)
- Add scottish_child_payment variable with defined_for="would_claim_scp"
- Add is_scp_eligible_child helper variable
- Add SCP parameters with legislation references:
  - amount.yaml (Regulation 20)
  - max_age.yaml (Regulation 18)
  - premium_under_one_amount.yaml (Scottish Budget 2026-27)
  - qualifying_benefits/ (Regulation 14)
  - takeup_rate/ (for dataset generation)
- Add tests for SCP baby bonus

Source: The Scottish Child Payment Regulations 2020
https://www.legislation.gov.uk/ssi/2020/351/contents

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MaxGhenis MaxGhenis force-pushed the migrate-random-fresh branch from 9f18b84 to c84ae00 Compare January 17, 2026 02:13
MaxGhenis and others added 3 commits January 16, 2026 21:21
- Create scottish_child_payment_person at Person level with defined_for
- Keep scottish_child_payment at BenUnit level using adds to aggregate
- Maintains backward compatibility with existing tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MaxGhenis
Copy link
Collaborator Author

Microsimulation Validation

The new dataset (policyengine-uk-data 1.34.0) with would_claim_scp has been validated.

Takeup Rates

Age Group Actual Target
Under 6 97.7% 97%
Ages 6-15 82.7% 85%

SCP Amounts (2025)

  • Mean SCP per eligible child: £1,308
  • Max SCP per child: £1,412 (= £27.15/week × 52)

Full Validation Notebook

📓 View executed notebook

MaxGhenis and others added 5 commits January 16, 2026 23:11
- Add 2026-04-01: £28.20 rate (inflation increase per Scottish Budget)
- Change baby boost start from 2026-04-06 to 2027-04-06 (payments start 2027-28)

Source: Scottish Budget 2026-27 confirms "will be paid in 2027-28"
https://www.gov.scot/publications/scottish-budget-2026-2027/pages/6/

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove unconfirmed 2026 rate (£28.20) - belongs in PR #1475
- Update baby bonus tests to use £27.15 standard rate
- Baby boost starts 2027-04-06 per Scottish Budget announcement

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Baby bonus (SCP Premium for under-ones) belongs in draft PR #1475
(Scottish Budget 2026-27), not this deterministic takeup PR.

This PR is only about migrating from random() to would_claim_scp.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove BenUnit wrapper - scottish_child_payment is now Person-level
with defined_for="is_scp_eligible".

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tests now specify per-person expected values since scottish_child_payment
is a Person-level variable.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MaxGhenis MaxGhenis merged commit 695d9b2 into main Jan 17, 2026
1 of 2 checks passed
@MaxGhenis MaxGhenis deleted the migrate-random-fresh branch January 17, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants