From 40e01af9dbc563ba02725590a0a535265cce0cff Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Tue, 5 Nov 2024 14:05:55 +0000 Subject: [PATCH 1/3] Fix Budget change reforms break on subset simulations #994 --- CHANGELOG.md | 7 ++++ changelog.yaml | 5 +++ .../contrib/policyengine/budget_change.py | 34 +++++++++++-------- setup.py | 2 +- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5f0d2a72..0d760c1e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.15.1] - 2024-11-05 14:05:53 + +### Fixed + +- Bug in budget change reforms. + ## [2.15.0] - 2024-10-30 17:24:57 ### Added @@ -1591,6 +1597,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +[2.15.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.15.0...2.15.1 [2.15.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.14.1...2.15.0 [2.14.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.14.0...2.14.1 [2.14.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.13.2...2.14.0 diff --git a/changelog.yaml b/changelog.yaml index 0ae9dcb91..f25386a74 100644 --- a/changelog.yaml +++ b/changelog.yaml @@ -1335,3 +1335,8 @@ added: - OBR Autumn 2024 EFO economic factors. date: 2024-10-30 17:24:57 +- bump: patch + changes: + fixed: + - Bug in budget change reforms. + date: 2024-11-05 14:05:53 diff --git a/policyengine_uk/variables/contrib/policyengine/budget_change.py b/policyengine_uk/variables/contrib/policyengine/budget_change.py index bd66d28c6..26a7efffe 100644 --- a/policyengine_uk/variables/contrib/policyengine/budget_change.py +++ b/policyengine_uk/variables/contrib/policyengine/budget_change.py @@ -176,6 +176,11 @@ class nhs_budget_change(Variable): value_type = float def formula(household, period, parameters): + budget_increase = ( + parameters(period).gov.contrib.policyengine.budget.nhs * 1e9 + ) + if budget_increase == 0: + return 0 decile = household( "pre_budget_change_ons_household_income_decile", period ) @@ -195,9 +200,6 @@ def formula(household, period, parameters): decile = pd.Series(decile) - budget_increase = ( - parameters(period).gov.contrib.policyengine.budget.nhs * 1e9 - ) budget_increase_per_decile = { i: budget_increase * DECILE_INCIDENCE[i] for i in range(1, 11) } @@ -223,6 +225,12 @@ class education_budget_change(Variable): value_type = float def formula(household, period, parameters): + + budget_increase = ( + parameters(period).gov.contrib.policyengine.budget.education * 1e9 + ) + if budget_increase == 0: + return 0 decile = household( "pre_budget_change_ons_household_income_decile", period ) @@ -241,10 +249,6 @@ def formula(household, period, parameters): } decile = pd.Series(decile) - - budget_increase = ( - parameters(period).gov.contrib.policyengine.budget.education * 1e9 - ) budget_increase_per_decile = { i: budget_increase * DECILE_INCIDENCE[i] for i in range(1, 11) } @@ -270,6 +274,15 @@ class other_public_spending_budget_change(Variable): value_type = float def formula(household, period, parameters): + + budget_increase = ( + parameters( + period + ).gov.contrib.policyengine.budget.other_public_spending + * 1e9 + ) + if budget_increase == 0: + return 0 decile = household( "pre_budget_change_ons_household_income_decile", period ) @@ -288,13 +301,6 @@ def formula(household, period, parameters): } decile = pd.Series(decile) - - budget_increase = ( - parameters( - period - ).gov.contrib.policyengine.budget.other_public_spending - * 1e9 - ) budget_increase_per_decile = { i: budget_increase * DECILE_INCIDENCE[i] for i in range(1, 11) } diff --git a/setup.py b/setup.py index 7ed87436a..f7ce471e1 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="PolicyEngine-UK", - version="2.15.0", + version="2.15.1", author="PolicyEngine", author_email="nikhil@policyengine.org", classifiers=[ From b619330c8a75b66bd12b08bc81c57be243f8d0a9 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Thu, 5 Dec 2024 12:40:58 +0000 Subject: [PATCH 2/3] Add the Scottish PAWHP --- .../pawhp/amount/base.yaml | 8 +++ .../pawhp/amount/higher.yaml | 6 ++ .../pawhp/amount/lower.yaml | 6 ++ .../eligibility/higher_age_requirement.yaml | 6 ++ .../pawhp/eligibility/require_benefits.yaml | 8 +++ .../state_pension_age_requirement.yaml | 6 ++ policyengine_uk/variables/gov/dwp/WFA.py | 5 +- policyengine_uk/variables/gov/gov_spending.py | 1 + .../gov/social_security_scotland/pawhp.py | 56 +++++++++++++++++++ 9 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/base.yaml create mode 100644 policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/higher.yaml create mode 100644 policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/lower.yaml create mode 100644 policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/higher_age_requirement.yaml create mode 100644 policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/require_benefits.yaml create mode 100644 policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/state_pension_age_requirement.yaml create mode 100644 policyengine_uk/variables/gov/social_security_scotland/pawhp.py diff --git a/policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/base.yaml b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/base.yaml new file mode 100644 index 000000000..0404994bf --- /dev/null +++ b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/base.yaml @@ -0,0 +1,8 @@ +description: Amount paid to non-benefit-claiming pensioners for the PAWHP. +values: + 2024-01-01: 0 + 2025-01-01: 100 +metadata: + unit: currency-GBP + label: PAWHP base payment + uprating: gov.obr.consumer_price_index diff --git a/policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/higher.yaml b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/higher.yaml new file mode 100644 index 000000000..d49c0a04f --- /dev/null +++ b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/higher.yaml @@ -0,0 +1,6 @@ +values: + 2024-01-01: 300 +metadata: + unit: currency-GBP + label: PAWHP lower amount + uprating: gov.obr.consumer_price_index diff --git a/policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/lower.yaml b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/lower.yaml new file mode 100644 index 000000000..f1aa14ed3 --- /dev/null +++ b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/amount/lower.yaml @@ -0,0 +1,6 @@ +values: + 2024-01-01: 200 +metadata: + unit: currency-GBP + label: PAWHP lower amount + uprating: gov.obr.consumer_price_index \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/higher_age_requirement.yaml b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/higher_age_requirement.yaml new file mode 100644 index 000000000..b56cf8d9c --- /dev/null +++ b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/higher_age_requirement.yaml @@ -0,0 +1,6 @@ +description: Age requirement to qualify for the higher PAWHP. +values: + 2000-01-01: 80 +metadata: + unit: year + label: Winter Fuel Payment higher amount age requirement diff --git a/policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/require_benefits.yaml b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/require_benefits.yaml new file mode 100644 index 000000000..1f657da4c --- /dev/null +++ b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/require_benefits.yaml @@ -0,0 +1,8 @@ +description: Whether receipt of means-tested benefits is required to qualify for the Winter Fuel Payment. +values: + 2000-01-01: false + 2024-01-01: + value: true +metadata: + unit: bool + label: PAWHP means-tested benefits requirement diff --git a/policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/state_pension_age_requirement.yaml b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/state_pension_age_requirement.yaml new file mode 100644 index 000000000..862175ec6 --- /dev/null +++ b/policyengine_uk/parameters/gov/social_security_scotland/pawhp/eligibility/state_pension_age_requirement.yaml @@ -0,0 +1,6 @@ +description: Whether individuals must be State Pension Age to qualify for the PAWHP. +values: + 2000-01-01: true +metadata: + unit: bool + label: PAWHP State Pension Age requirement diff --git a/policyengine_uk/variables/gov/dwp/WFA.py b/policyengine_uk/variables/gov/dwp/WFA.py index 937b6954c..45f932357 100644 --- a/policyengine_uk/variables/gov/dwp/WFA.py +++ b/policyengine_uk/variables/gov/dwp/WFA.py @@ -18,6 +18,9 @@ class winter_fuel_allowance(Variable): unit = GBP def formula(household, period, parameters): + in_scotland = ( + household("country", period).decode_to_str() == "SCOTLAND" + ) age = household.members("age", period) is_SP_age = household.members("is_SP_age", period) wfp = parameters(period).gov.dwp.winter_fuel_payment @@ -53,7 +56,7 @@ def formula(household, period, parameters): & ~meets_higher_age_requirement ) - return ( + return ~in_scotland * ( wfp.amount.higher * qualifies_for_higher + wfp.amount.lower * qualifies_for_lower ) diff --git a/policyengine_uk/variables/gov/gov_spending.py b/policyengine_uk/variables/gov/gov_spending.py index 27e86fb95..46bebfd78 100644 --- a/policyengine_uk/variables/gov/gov_spending.py +++ b/policyengine_uk/variables/gov/gov_spending.py @@ -40,6 +40,7 @@ class gov_spending(Variable): "cost_of_living_support_payment", "energy_bills_rebate", "winter_fuel_allowance", + "pawhp", "nhs_budget_change", "education_budget_change", "other_public_spending_budget_change", diff --git a/policyengine_uk/variables/gov/social_security_scotland/pawhp.py b/policyengine_uk/variables/gov/social_security_scotland/pawhp.py new file mode 100644 index 000000000..bfb34aae8 --- /dev/null +++ b/policyengine_uk/variables/gov/social_security_scotland/pawhp.py @@ -0,0 +1,56 @@ +from policyengine_uk.model_api import * + + +class pawhp(Variable): + label = "Pension Age Winter Heating Payment" + entity = Household + definition_period = YEAR + value_type = float + unit = GBP + + def formula(household, period, parameters): + in_scotland = ( + household("country", period).decode_to_str() == "SCOTLAND" + ) + age = household.members("age", period) + is_SP_age = household.members("is_SP_age", period) + wfp = parameters(period).gov.social_security_scotland.pawhp + on_mtb = ( + add( + household, + period, + [ + "pension_credit", + "income_support", + "esa_income", + "jsa_income", + ], + ) + > 0 + ) + meets_mtb_requirement = on_mtb | ~wfp.eligibility.require_benefits + meets_spa_requirement = ( + household.any(is_SP_age) + | ~wfp.eligibility.state_pension_age_requirement + ) + meets_higher_age_requirement = household.any( + age >= wfp.eligibility.higher_age_requirement + ) + qualifies_for_higher = ( + meets_mtb_requirement + & meets_spa_requirement + & meets_higher_age_requirement + ) + qualifies_for_lower = ( + meets_mtb_requirement + & meets_spa_requirement + & ~meets_higher_age_requirement + ) + + qualifies_for_base = ~meets_mtb_requirement & meets_spa_requirement + + return in_scotland * ( + wfp.amount.higher * qualifies_for_higher + + wfp.amount.lower * qualifies_for_lower + + wfp.amount.base * qualifies_for_base + ) From b493b3b5db283a131d670c947ecef5c54bdb97e0 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Thu, 5 Dec 2024 12:43:17 +0000 Subject: [PATCH 3/3] Versioning --- CHANGELOG.md | 7 +++++++ changelog.yaml | 5 +++++ setup.py | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 623952986..c7902f4ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.18.0] - 2024-12-05 12:43:06 + +### Added + +- Scottish Winter Fuel Payment equivalent. + ## [2.17.0] - 2024-12-04 16:48:42 ### Fixed @@ -1609,6 +1615,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +[2.18.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.17.0...2.18.0 [2.17.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.16.0...2.17.0 [2.16.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.15.1...2.16.0 [2.15.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.15.0...2.15.1 diff --git a/changelog.yaml b/changelog.yaml index 8f68232ce..9869f4018 100644 --- a/changelog.yaml +++ b/changelog.yaml @@ -1350,3 +1350,8 @@ fixed: - Scottish baseline matched with Scottish Fiscal Commission. date: 2024-12-04 16:48:42 +- bump: minor + changes: + added: + - Scottish Winter Fuel Payment equivalent. + date: 2024-12-05 12:43:06 diff --git a/setup.py b/setup.py index df5abd8c0..1e71f8e9d 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="PolicyEngine-UK", - version="2.17.0", + version="2.18.0", author="PolicyEngine", author_email="nikhil@policyengine.org", classifiers=[