From 1e7ad034b77a69c9f5015dc3a057880b7979c8f4 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 9 Sep 2024 14:07:43 +0100 Subject: [PATCH 01/15] Add variable changes --- policyengine_uk/variables/gov/dwp/AFCS.py | 4 +- policyengine_uk/variables/gov/dwp/BSP.py | 4 +- .../variables/gov/dwp/ESA_contrib.py | 14 +- .../variables/gov/dwp/ESA_income.py | 42 +---- policyengine_uk/variables/gov/dwp/IIDB.py | 4 +- .../variables/gov/dwp/JSA_contrib.py | 6 +- .../variables/gov/dwp/JSA_income.py | 144 +----------------- .../variables/gov/dwp/dla/self_care.py | 2 +- .../variables/gov/dwp/housing_benefit.py | 0 .../variables/gov/dwp/pip/daily_living.py | 4 +- .../variables/gov/dwp/pip/mobility.py | 2 +- policyengine_uk/variables/gov/dwp/sda.py | 2 +- .../hmrc/national_insurance/ni_employer.py | 12 ++ policyengine_uk/variables/input/disability.py | 2 +- 14 files changed, 46 insertions(+), 196 deletions(-) delete mode 100644 policyengine_uk/variables/gov/dwp/housing_benefit.py create mode 100644 policyengine_uk/variables/gov/hmrc/national_insurance/ni_employer.py diff --git a/policyengine_uk/variables/gov/dwp/AFCS.py b/policyengine_uk/variables/gov/dwp/AFCS.py index c6b01f45d..22d9f4c28 100644 --- a/policyengine_uk/variables/gov/dwp/AFCS.py +++ b/policyengine_uk/variables/gov/dwp/AFCS.py @@ -1,7 +1,7 @@ from policyengine_uk.model_api import * -class AFCS(Variable): +class afcs(Variable): value_type = float entity = Person label = "Armed Forces Compensation Scheme" @@ -12,7 +12,7 @@ class AFCS(Variable): adds = ["AFCS_reported"] -class AFCS_reported(Variable): +class afcs_reported(Variable): value_type = float entity = Person label = "Armed Forces Compensation Scheme (reported)" diff --git a/policyengine_uk/variables/gov/dwp/BSP.py b/policyengine_uk/variables/gov/dwp/BSP.py index b18487fd2..13ff04f0b 100644 --- a/policyengine_uk/variables/gov/dwp/BSP.py +++ b/policyengine_uk/variables/gov/dwp/BSP.py @@ -1,7 +1,7 @@ from policyengine_uk.model_api import * -class BSP(Variable): +class bsp(Variable): value_type = float entity = Person label = "Bereavement Support Payment" @@ -11,7 +11,7 @@ class BSP(Variable): adds = ["BSP_reported"] -class BSP_reported(Variable): +class bsp_reported(Variable): value_type = float entity = Person label = "Bereavement Support Payment (reported)" diff --git a/policyengine_uk/variables/gov/dwp/ESA_contrib.py b/policyengine_uk/variables/gov/dwp/ESA_contrib.py index e55501765..f5844c780 100644 --- a/policyengine_uk/variables/gov/dwp/ESA_contrib.py +++ b/policyengine_uk/variables/gov/dwp/ESA_contrib.py @@ -1,19 +1,27 @@ from policyengine_uk.model_api import * -class ESA_contrib(Variable): +class esa_contrib(Variable): value_type = float entity = Person label = "ESA (contribution-based)" definition_period = YEAR unit = GBP - adds = ["ESA_contrib_reported"] + adds = ["esa_contrib_reported"] -class ESA_contrib_reported(Variable): +class esa_contrib_reported(Variable): value_type = float entity = Person label = "Employment and Support Allowance (contribution-based) (reported)" definition_period = YEAR unit = GBP + +class esa(Variable): + label = "ESA" + entity = Person + definition_period = YEAR + value_type = float + unit = GBP + adds = ["esa_contrib", "esa_income"] diff --git a/policyengine_uk/variables/gov/dwp/ESA_income.py b/policyengine_uk/variables/gov/dwp/ESA_income.py index a15eb2d15..819bb04d4 100644 --- a/policyengine_uk/variables/gov/dwp/ESA_income.py +++ b/policyengine_uk/variables/gov/dwp/ESA_income.py @@ -1,7 +1,7 @@ from policyengine_uk.model_api import * -class ESA_income_reported(Variable): +class esa_income_reported(Variable): value_type = float entity = Person label = "ESA (income-based) (reported amount)" @@ -9,43 +9,7 @@ class ESA_income_reported(Variable): unit = GBP -class would_claim_ESA_income(Variable): - value_type = bool - entity = BenUnit - label = "Would claim income-based ESA" - documentation = "Whether this family would claim income-based Employment Support Allowance if eligible" - definition_period = YEAR - - def formula(benunit, period, parameters): - reports_ESA_income = add(benunit, period, ["ESA_income_reported"]) > 0 - claims_all = benunit("claims_all_entitled_benefits", period) - return reports_ESA_income | claims_all - - -class ESA_income_eligible(Variable): - value_type = bool - entity = BenUnit - label = "ESA (income) eligible" - definition_period = YEAR - - def formula(benunit, period, parameters): - return add(benunit, period, ["ESA_income_reported"]) > 0 - - -class claims_ESA_income(Variable): - value_type = bool - entity = BenUnit - label = "Claims ESA (income)" - documentation = "Claims income-based Employment and Support Allowance" - definition_period = YEAR - - def formula(benunit, period, parameters): - would_claim = benunit("would_claim_ESA_income", period) - claims_legacy_benefits = benunit("claims_legacy_benefits", period) - return would_claim & claims_legacy_benefits - - -class ESA_income(Variable): +class esa_income(Variable): value_type = float entity = BenUnit label = "ESA (income-based)" @@ -53,4 +17,4 @@ class ESA_income(Variable): definition_period = YEAR unit = GBP - adds = ["ESA_income_reported"] + adds = ["esa_income_reported"] diff --git a/policyengine_uk/variables/gov/dwp/IIDB.py b/policyengine_uk/variables/gov/dwp/IIDB.py index 51aed10e3..19a9582c7 100644 --- a/policyengine_uk/variables/gov/dwp/IIDB.py +++ b/policyengine_uk/variables/gov/dwp/IIDB.py @@ -1,7 +1,7 @@ from policyengine_uk.model_api import * -class IIDB(Variable): +class iidb(Variable): value_type = float entity = Person label = "Industrial Injuries Disablement Benefit" @@ -11,7 +11,7 @@ class IIDB(Variable): adds = ["IIDB_reported"] -class IIDB_reported(Variable): +class iidb_reported(Variable): value_type = float entity = Person label = "Industrial Injuries Disablement Benefit (reported)" diff --git a/policyengine_uk/variables/gov/dwp/JSA_contrib.py b/policyengine_uk/variables/gov/dwp/JSA_contrib.py index 0c8c2c5d0..db33e535b 100644 --- a/policyengine_uk/variables/gov/dwp/JSA_contrib.py +++ b/policyengine_uk/variables/gov/dwp/JSA_contrib.py @@ -1,17 +1,17 @@ from policyengine_uk.model_api import * -class JSA_contrib(Variable): +class jsa_contrib(Variable): value_type = float entity = Person label = "JSA (contribution-based)" definition_period = YEAR unit = GBP - adds = ["JSA_contrib_reported"] + adds = ["jsa_contrib_reported"] -class JSA_contrib_reported(Variable): +class jsa_contrib_reported(Variable): value_type = float entity = Person label = "Job Seeker's Allowance (contribution-based) (reported)" diff --git a/policyengine_uk/variables/gov/dwp/JSA_income.py b/policyengine_uk/variables/gov/dwp/JSA_income.py index bda32c2af..684c692df 100644 --- a/policyengine_uk/variables/gov/dwp/JSA_income.py +++ b/policyengine_uk/variables/gov/dwp/JSA_income.py @@ -1,7 +1,7 @@ from policyengine_uk.model_api import * -class JSA_income_reported(Variable): +class jsa_income_reported(Variable): value_type = float entity = Person label = "JSA (income-based) (reported amount)" @@ -9,132 +9,7 @@ class JSA_income_reported(Variable): unit = GBP -class JSA_income_eligible(Variable): - value_type = bool - entity = BenUnit - label = "Eligibility for income-based JSA" - documentation = "Whether the benefit unit is eligible for income-based Jobseekers' Allowance" - definition_period = YEAR - - def formula(benunit, period, parameters): - # Calculate work hours eligibility. - hours_limit = parameters(period).gov.dwp.JSA.hours - hours = benunit("benunit_weekly_hours", period) - single = benunit("is_single", period) - hours_eligible_as_single = single & (hours < hours_limit.single) - couple = benunit("is_couple", period) - hours_eligible_as_couple = couple & (hours < hours_limit.couple) - hours_eligible = hours_eligible_as_single | hours_eligible_as_couple - # Benefit units with state pension age people are ineligible. - all_under_SP_age = ~benunit.any(benunit.members("is_SP_age", period)) - # Must have at least one unemployed person. - employment_statuses = benunit.members("employment_status", period) - unemployed_members = ( - employment_statuses - == employment_statuses.possible_values.UNEMPLOYED - ) - any_unemployed = benunit.any(unemployed_members) - # Cannot claim Income Support. - not_on_income_support = benunit("income_support", period) == 0 - already_claiming = add(benunit, period, ["JSA_income_reported"]) > 0 - return ( - hours_eligible - & all_under_SP_age - & any_unemployed - & not_on_income_support - & already_claiming - ) - - -class JSA_income_applicable_amount(Variable): - value_type = float - entity = BenUnit - label = "Maximum amount of JSA (income-based)" - documentation = "Maximum amount of income-based Jobseeker's Allowance" - definition_period = YEAR - reference = "Jobseekers Act 1995 s. 4" - unit = GBP - - def formula(benunit, period, parameters): - income = parameters(period).gov.dwp.JSA.income - age = benunit("youngest_adult_age", period) - single = benunit("is_single", period) - couple = benunit("is_couple", period) - single_18_24 = single & (age < 25) - single_over_25 = single & (age >= 25) - pa_single_18_24 = single_18_24 * income.amount_18_24 - pa_single_over_25 = single_over_25 * income.amount_over_25 - pa_couple = couple * income.couple - weekly_personal_allowance = ( - pa_single_18_24 + pa_single_over_25 + pa_couple - ) - personal_allowance = weekly_personal_allowance * WEEKS_IN_YEAR - premiums = benunit("benefits_premiums", period) - amount_if_claims = personal_allowance + premiums - eligible = benunit("JSA_income_eligible", period) - claims = benunit("would_claim_JSA", period) - return amount_if_claims * eligible * claims - - -class would_claim_JSA(Variable): - value_type = bool - entity = BenUnit - label = "Would claim income-based JSA" - documentation = ( - "Whether this family would claim income-based JSA if eligible" - ) - definition_period = YEAR - - def formula(benunit, period, parameters): - return add(benunit, period, ["JSA_income_reported"]) > 0 - - -class JSA_income_applicable_income(Variable): - value_type = float - entity = BenUnit - label = "Relevant income for JSA (income-based) means test" - definition_period = YEAR - unit = GBP - - def formula(benunit, period, parameters): - JSA = parameters(period).gov.dwp.JSA - INCOME_COMPONENTS = [ - "employment_income", - "self_employment_income", - "property_income", - "private_pension_income", - ] - bi = parameters(period).gov.contrib.ubi_center.basic_income - if bi.interactions.include_in_means_tests: - INCOME_COMPONENTS.append("basic_income") - income = add(benunit, period, INCOME_COMPONENTS) - tax = add( - benunit, - period, - ["income_tax", "national_insurance"], - ) - income += add(benunit, period, ["social_security_income"]) - income -= tax - income -= add(benunit, period, ["pension_contributions"]) * 0.5 - # Calculate disregard. - family_type = benunit("family_type", period) - families = family_type.possible_values - single = family_type == families.SINGLE - single_disregard = single * JSA.income.income_disregard_single - couple = benunit("is_couple", period) - couple_disregard = couple * JSA.income.income_disregard_couple - lone_parent = family_type == families.LONE_PARENT - lone_parent_disregard = ( - lone_parent * JSA.income.income_disregard_lone_parent - ) - weekly_disregard = ( - single_disregard + couple_disregard + lone_parent_disregard - ) - disregard = weekly_disregard * WEEKS_IN_YEAR - return max_(0, income - disregard) - - -class JSA_income(Variable): +class jsa_income(Variable): value_type = float entity = BenUnit label = "JSA (income-based)" @@ -142,22 +17,13 @@ class JSA_income(Variable): unit = GBP def formula(benunit, period, parameters): - applicable_amount = benunit("JSA_income_applicable_amount", period) - applicable_income = benunit("JSA_income_applicable_income", period) - amount_if_claims = max_(0, applicable_amount - applicable_income) - claims = benunit("would_claim_JSA", period) - eligible = benunit("JSA_income_eligible", period) - return amount_if_claims * claims * eligible + return benunit("jsa_income_reported", period) -class JSA(Variable): +class jsa(Variable): value_type = float entity = BenUnit label = "Amount of Jobseeker's Allowance for this family" definition_period = YEAR unit = GBP - - def formula(benunit, period, parameters): - JSA_contrib = add(benunit, period, ["JSA_contrib"]) - JSA_income = benunit("JSA_income", period) - return JSA_contrib + JSA_income + adds = ["jsa_income", "jsa_contrib"] diff --git a/policyengine_uk/variables/gov/dwp/dla/self_care.py b/policyengine_uk/variables/gov/dwp/dla/self_care.py index 460fb2872..ec9a5bf81 100644 --- a/policyengine_uk/variables/gov/dwp/dla/self_care.py +++ b/policyengine_uk/variables/gov/dwp/dla/self_care.py @@ -4,7 +4,7 @@ ) -class DLA_SC_reported(Variable): +class dla_sc_reported(Variable): value_type = float entity = Person label = "DLA (self-care) (reported)" diff --git a/policyengine_uk/variables/gov/dwp/housing_benefit.py b/policyengine_uk/variables/gov/dwp/housing_benefit.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/policyengine_uk/variables/gov/dwp/pip/daily_living.py b/policyengine_uk/variables/gov/dwp/pip/daily_living.py index f87190bbf..d2c58ac2c 100644 --- a/policyengine_uk/variables/gov/dwp/pip/daily_living.py +++ b/policyengine_uk/variables/gov/dwp/pip/daily_living.py @@ -2,10 +2,10 @@ from policyengine_uk.variables.gov.dwp.pip.pip import PIPCategory -class PIP_DL_reported(Variable): +class pip_dl_reported(Variable): value_type = float entity = Person - label = "PIP (self-care) (reported)" + label = "PIP (daily living) (reported)" definition_period = YEAR unit = GBP diff --git a/policyengine_uk/variables/gov/dwp/pip/mobility.py b/policyengine_uk/variables/gov/dwp/pip/mobility.py index 9e3756db7..150fed815 100644 --- a/policyengine_uk/variables/gov/dwp/pip/mobility.py +++ b/policyengine_uk/variables/gov/dwp/pip/mobility.py @@ -2,7 +2,7 @@ from policyengine_uk.variables.gov.dwp.pip.pip import PIPCategory -class PIP_M_reported(Variable): +class pip_m_reported(Variable): value_type = float entity = Person label = "PIP (mobility) (reported)" diff --git a/policyengine_uk/variables/gov/dwp/sda.py b/policyengine_uk/variables/gov/dwp/sda.py index abad97aa0..4701d78c5 100644 --- a/policyengine_uk/variables/gov/dwp/sda.py +++ b/policyengine_uk/variables/gov/dwp/sda.py @@ -17,7 +17,7 @@ def formula(person, period, parameters): return reported * rate * WEEKS_IN_YEAR -class SDA_reported(Variable): +class sda_reported(Variable): value_type = float entity = Person label = "Severe Disablement Allowance (reported)" diff --git a/policyengine_uk/variables/gov/hmrc/national_insurance/ni_employer.py b/policyengine_uk/variables/gov/hmrc/national_insurance/ni_employer.py new file mode 100644 index 000000000..063dc1e01 --- /dev/null +++ b/policyengine_uk/variables/gov/hmrc/national_insurance/ni_employer.py @@ -0,0 +1,12 @@ +from policyengine_uk.model_api import * + + +class ni_employer(Variable): + value_type = float + entity = Person + label = "employer-side National Insurance" + definition_period = YEAR + unit = GBP + adds = [ + "ni_class_1_employer", + ] diff --git a/policyengine_uk/variables/input/disability.py b/policyengine_uk/variables/input/disability.py index 9967a556c..d97bbe4d6 100644 --- a/policyengine_uk/variables/input/disability.py +++ b/policyengine_uk/variables/input/disability.py @@ -23,7 +23,7 @@ def formula(person, period, parameters): dla_sc = parameters(period).gov.dwp.dla.self_care SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation reported_weekly_dla_sc = ( - person("DLA_SC_reported", period) / WEEKS_IN_YEAR + person("dla_sc_reported", period) / WEEKS_IN_YEAR ) return select( [ From 6e53e195449c5b2a8031d51b38843bedcedd8afc Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 9 Sep 2024 15:33:52 +0100 Subject: [PATCH 02/15] Add renames --- CHANGELOG.md | 2 +- changelog.yaml | 2 +- docs/summary/VARIABLE_STATS.md | 38 ++-- policyengine_uk/data/datasets/frs/frs.py | 14 +- .../families/by_program_participation.yaml | 4 +- .../parameters/gov/dwp/JSA/income/takeup.yaml | 2 +- .../guarantee_credit/income.yaml | 4 +- .../savings_credit_excluded_sources.yaml | 4 +- .../dwp/pension_credit/income/sources.yaml | 4 +- .../savings_credit/excluded_income.yaml | 4 +- .../income_definitions/unearned.yaml | 2 +- .../qualifying_benefits.yaml | 4 +- .../reforms/policyengine/budget_change.py | 28 +-- .../tests/microsimulation/statistics.yaml | 2 +- .../finance/benefit/family/JSA_income.yaml | 18 +- .../housing_benefit_applicable_income.yaml | 20 +-- .../income/uc_unearned_income.yaml | 2 +- .../pension_credit/pension_credit_income.yaml | 4 +- policyengine_uk/tools/takeup.py | 2 +- policyengine_uk/variables/gov/dwp/AFCS.py | 2 +- policyengine_uk/variables/gov/dwp/BSP.py | 2 +- policyengine_uk/variables/gov/dwp/IIDB.py | 2 +- policyengine_uk/variables/gov/dwp/WFA.py | 4 +- .../variables/gov/dwp/attendance_allowance.py | 4 +- .../variables/gov/dwp/benefit_cap.py | 12 +- .../variables/gov/dwp/dla/mobility.py | 2 +- .../housing_benefit_applicable_income.py | 25 ++- .../variables/gov/dwp/income_support.py | 4 +- policyengine_uk/variables/gov/dwp/sda.py | 2 +- .../variables/gov/dwp/tax_credits.py | 2 +- .../variables/gov/hmrc/income_tax/base.py | 4 +- .../household/demographic/disability.py | 2 +- .../variables/household/income/benefit.py | 163 ++---------------- policyengine_uk/variables/input/disability.py | 6 +- 34 files changed, 139 insertions(+), 257 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f0bf4e3c..fc26d0308 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1254,7 +1254,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Apply Working Tax Credit old-age provision to 60-year-olds. - Qualify people working 30 hours for the Working Tax Credit. -- Point AFCS to AFCS_reported instead of AA_reported. +- Point afcs to afcs_reported instead of AA_reported. - Fix units on some variables. ## [0.7.17] - 2021-12-23 00:00:00 diff --git a/changelog.yaml b/changelog.yaml index eb23c8795..8359e2315 100644 --- a/changelog.yaml +++ b/changelog.yaml @@ -173,7 +173,7 @@ fixed: - Apply Working Tax Credit old-age provision to 60-year-olds. - Qualify people working 30 hours for the Working Tax Credit. - - Point AFCS to AFCS_reported instead of AA_reported. + - Point afcs to afcs_reported instead of AA_reported. - Fix units on some variables. date: 2021-12-27 00:00:00 - bump: patch diff --git a/docs/summary/VARIABLE_STATS.md b/docs/summary/VARIABLE_STATS.md index 8de9dd48b..ebc4e2fc6 100644 --- a/docs/summary/VARIABLE_STATS.md +++ b/docs/summary/VARIABLE_STATS.md @@ -449,7 +449,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 31,491,391.659608364 -- ESA_income: +- esa_income: - Type: float - Entity: household - Description: Household gross income @@ -469,7 +469,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 27,594,714.97113228 -- ESA_income_reported: +- esa_income_reported: - Type: float - Entity: household - Description: Household net income @@ -479,7 +479,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 31,431,782.814266205 -- claims_ESA_income: +- claims_esa_income: - Type: bool - Entity: person - Description: Worked some hours @@ -489,7 +489,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 36,800,484.87847948 -- would_claim_ESA_income: +- would_claim_esa_income: - Type: bool - Entity: benunit - Description: Would claim income-based ESA @@ -499,7 +499,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 402,875.4299545288 -- IIDB: +- iidb: - Type: float - Entity: person - Description: Lump sum income @@ -509,7 +509,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 191,086.9439239502 -- IIDB_reported: +- iidb_reported: - Type: float - Entity: person - Description: Maintenance payments @@ -519,7 +519,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 722,952.5704650879 -- JSA_contrib: +- jsa_contrib: - Type: float - Entity: person - Description: Market income @@ -529,7 +529,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 45,137,423.94413638 -- JSA_contrib_reported: +- jsa_contrib_reported: - Type: float - Entity: person - Description: Minimum wage @@ -979,7 +979,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 19,360,939.249423504 -- JSA_income: +- jsa_income: - Type: float - Entity: household - Description: Household furnishings @@ -989,7 +989,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 30,109,011.32818985 -- JSA_income_applicable_amount: +- jsa_income_applicable_amount: - Type: float - Entity: household - Description: Housing, water and electricity @@ -999,7 +999,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 31,534,885.703243256 -- JSA_income_applicable_income: +- jsa_income_applicable_income: - Type: float - Entity: household - Description: Miscellaneous @@ -1019,7 +1019,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 15,787,098.954917908 -- JSA_income_reported: +- jsa_income_reported: - Type: float - Entity: household - Description: Recreation @@ -1059,7 +1059,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 12,678,011.265280724 -- BSP: +- bsp: - Type: float - Entity: person - Description: Cost of childcare @@ -1095,7 +1095,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 28,641,752.4251194 -- BSP_reported: +- bsp_reported: - Type: float - Entity: household - Description: Domestic rates @@ -1650,7 +1650,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 27,250,437.19493723 -- ESA_contrib: +- esa_contrib: - Type: float - Entity: person - Description: Person's household ID @@ -1660,7 +1660,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 67,106,864.33584666 -- ESA_contrib_reported: +- esa_contrib_reported: - Type: float - Entity: person - Description: Employment and Support Allowance (contribution-based) (reported) @@ -1670,7 +1670,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 331,941.6319360733 -- AFCS: +- afcs: - Type: float - Entity: person - Description: Armed Forces Compensation Scheme @@ -1680,7 +1680,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 57,022.80386734009 -- AFCS_reported: +- afcs_reported: - Type: float - Entity: person - Description: Armed Forces Compensation Scheme (reported) @@ -3270,7 +3270,7 @@ All statistics generated from the uprated (to 2022) 2019-20 Family Resources Sur - Non-zero count: 485,548.13566589355 -- ESA_income_eligible: +- esa_income_eligible: - Type: bool - Entity: benunit - Description: ESA (income) eligible diff --git a/policyengine_uk/data/datasets/frs/frs.py b/policyengine_uk/data/datasets/frs/frs.py index 5da975024..47a42284f 100644 --- a/policyengine_uk/data/datasets/frs/frs.py +++ b/policyengine_uk/data/datasets/frs/frs.py @@ -659,10 +659,10 @@ def add_benefit_income( AA=12, DLA_SC=1, DLA_M=2, - IIDB=15, + iidb=15, carers_allowance=13, SDA=10, - AFCS=8, + afcs=8, maternity_allowance=21, ssmg=22, pension_credit=4, @@ -686,7 +686,7 @@ def add_benefit_income( * 52 ) - frs["JSA_contrib_reported"] = ( + frs["jsa_contrib_reported"] = ( sum_to_entity( benefits.BENAMT * (benefits.VAR2.isin((1, 3))) @@ -696,7 +696,7 @@ def add_benefit_income( ) * 52 ) - frs["JSA_income_reported"] = ( + frs["jsa_income_reported"] = ( sum_to_entity( benefits.BENAMT * (benefits.VAR2.isin((2, 4))) @@ -706,7 +706,7 @@ def add_benefit_income( ) * 52 ) - frs["ESA_contrib_reported"] = ( + frs["esa_contrib_reported"] = ( sum_to_entity( benefits.BENAMT * (benefits.VAR2.isin((1, 3))) @@ -716,7 +716,7 @@ def add_benefit_income( ) * 52 ) - frs["ESA_income_reported"] = ( + frs["esa_income_reported"] = ( sum_to_entity( benefits.BENAMT * (benefits.VAR2.isin((2, 4))) @@ -727,7 +727,7 @@ def add_benefit_income( * 52 ) - frs["BSP_reported"] = ( + frs["bsp_reported"] = ( sum_to_entity( benefits.BENAMT * (benefits.BENEFIT.isin((6, 9))), benefits.person_id, diff --git a/policyengine_uk/parameters/calibration/demographics/families/by_program_participation.yaml b/policyengine_uk/parameters/calibration/demographics/families/by_program_participation.yaml index 0f6d7279a..23fcd6e10 100644 --- a/policyengine_uk/parameters/calibration/demographics/families/by_program_participation.yaml +++ b/policyengine_uk/parameters/calibration/demographics/families/by_program_participation.yaml @@ -1,4 +1,4 @@ -JSA_income: +jsa_income: description: Number of families claiming income-based JSA. values: 2018-01-01: 274_000 @@ -129,7 +129,7 @@ child_benefit: - title: "Child Benefit Statistics: Annual Releast, August 2020" href: https://www.gov.uk/government/statistics/child-benefit-statistics-annual-release-august-2020 -ESA_income: +esa_income: description: Number of families claiming income-based ESA. values: 2019-01-01: 1_056_000 diff --git a/policyengine_uk/parameters/gov/dwp/JSA/income/takeup.yaml b/policyengine_uk/parameters/gov/dwp/JSA/income/takeup.yaml index a8e6aa1d1..f3189c96a 100644 --- a/policyengine_uk/parameters/gov/dwp/JSA/income/takeup.yaml +++ b/policyengine_uk/parameters/gov/dwp/JSA/income/takeup.yaml @@ -3,7 +3,7 @@ description: Share of eligible Income-based Jobseeker's Allowance recipients tha metadata: economy: false label: Income-based Jobseeker's Allowance take-up rate - name: JSA_income_takeup + name: jsa_income_takeup reference: href: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/645577/income-related-benefits-estimates-of-take-up-2015-16.pdf name: 'Income-related benefits: estimates of take-up: financial year 2015/16 | diff --git a/policyengine_uk/parameters/gov/dwp/pension_credit/guarantee_credit/income.yaml b/policyengine_uk/parameters/gov/dwp/pension_credit/guarantee_credit/income.yaml index 0bd95fad3..57f92d17d 100644 --- a/policyengine_uk/parameters/gov/dwp/pension_credit/guarantee_credit/income.yaml +++ b/policyengine_uk/parameters/gov/dwp/pension_credit/guarantee_credit/income.yaml @@ -16,5 +16,5 @@ values: - state_pension - private_pension_income - capital_income - - ESA_contrib - - JSA_contrib + - esa_contrib + - jsa_contrib diff --git a/policyengine_uk/parameters/gov/dwp/pension_credit/income/savings_credit_excluded_sources.yaml b/policyengine_uk/parameters/gov/dwp/pension_credit/income/savings_credit_excluded_sources.yaml index 2570fbea1..bedb5dd94 100644 --- a/policyengine_uk/parameters/gov/dwp/pension_credit/income/savings_credit_excluded_sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/pension_credit/income/savings_credit_excluded_sources.yaml @@ -8,5 +8,5 @@ metadata: unit: currency-GBP values: 2002-01-01: - - JSA_contrib - - ESA_contrib + - jsa_contrib + - esa_contrib diff --git a/policyengine_uk/parameters/gov/dwp/pension_credit/income/sources.yaml b/policyengine_uk/parameters/gov/dwp/pension_credit/income/sources.yaml index 4d4bb2a5a..0758ae171 100644 --- a/policyengine_uk/parameters/gov/dwp/pension_credit/income/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/pension_credit/income/sources.yaml @@ -15,5 +15,5 @@ values: - state_pension - private_pension_income - capital_income - - ESA_contrib - - JSA_contrib + - esa_contrib + - jsa_contrib diff --git a/policyengine_uk/parameters/gov/dwp/pension_credit/savings_credit/excluded_income.yaml b/policyengine_uk/parameters/gov/dwp/pension_credit/savings_credit/excluded_income.yaml index 60899f07d..ec24334f7 100644 --- a/policyengine_uk/parameters/gov/dwp/pension_credit/savings_credit/excluded_income.yaml +++ b/policyengine_uk/parameters/gov/dwp/pension_credit/savings_credit/excluded_income.yaml @@ -9,5 +9,5 @@ metadata: unit: currency-GBP values: 2002-01-01: - - JSA_contrib - - ESA_contrib + - jsa_contrib + - esa_contrib diff --git a/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/income_definitions/unearned.yaml b/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/income_definitions/unearned.yaml index cbef9ba31..0f5ec53ce 100644 --- a/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/income_definitions/unearned.yaml +++ b/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/income_definitions/unearned.yaml @@ -13,7 +13,7 @@ metadata: values: 2010-01-01: - carers_allowance - - JSA_contrib + - jsa_contrib - private_pension_income - savings_interest_income - dividend_income diff --git a/policyengine_uk/parameters/gov/treasury/cost_of_living_support/means_tested_households/qualifying_benefits.yaml b/policyengine_uk/parameters/gov/treasury/cost_of_living_support/means_tested_households/qualifying_benefits.yaml index 7b0f8b9a4..f9383b040 100644 --- a/policyengine_uk/parameters/gov/treasury/cost_of_living_support/means_tested_households/qualifying_benefits.yaml +++ b/policyengine_uk/parameters/gov/treasury/cost_of_living_support/means_tested_households/qualifying_benefits.yaml @@ -14,7 +14,7 @@ values: - universal_credit - pension_credit - housing_benefit - - JSA_income + - jsa_income - income_support - - ESA_income + - esa_income - pension_credit diff --git a/policyengine_uk/reforms/policyengine/budget_change.py b/policyengine_uk/reforms/policyengine/budget_change.py index 67816427b..5b80c5104 100644 --- a/policyengine_uk/reforms/policyengine/budget_change.py +++ b/policyengine_uk/reforms/policyengine/budget_change.py @@ -10,23 +10,23 @@ class pre_budget_change_household_benefits(Variable): unit = GBP adds = [ "child_benefit", - "ESA_income", + "esa_income", "housing_benefit", "income_support", - "JSA_income", + "jsa_income", "pension_credit", "universal_credit", "working_tax_credit", "child_tax_credit", "attendance_allowance", - "AFCS", - "BSP", + "afcs", + "bsp", "carers_allowance", "dla", - "ESA_contrib", - "IIDB", + "esa_contrib", + "iidb", "incapacity_benefit", - "JSA_contrib", + "jsa_contrib", "pip", "sda", "state_pension", @@ -368,23 +368,23 @@ class household_benefits(Variable): unit = GBP adds = [ "child_benefit", - "ESA_income", + "esa_income", "housing_benefit", "income_support", - "JSA_income", + "jsa_income", "pension_credit", "universal_credit", "working_tax_credit", "child_tax_credit", "attendance_allowance", - "AFCS", - "BSP", + "afcs", + "bsp", "carers_allowance", "dla", - "ESA_contrib", - "IIDB", + "esa_contrib", + "iidb", "incapacity_benefit", - "JSA_contrib", + "jsa_contrib", "pip", "sda", "state_pension", diff --git a/policyengine_uk/tests/microsimulation/statistics.yaml b/policyengine_uk/tests/microsimulation/statistics.yaml index 595aa8a6e..43946d67c 100644 --- a/policyengine_uk/tests/microsimulation/statistics.yaml +++ b/policyengine_uk/tests/microsimulation/statistics.yaml @@ -17,7 +17,7 @@ housing_benefit: test: - absolute_aggregate_error_less_than: 6.e+9 - relative_caseload_error_less_than: 0.15 -JSA_income: +jsa_income: test: - relative_aggregate_error_less_than: 1.1 - absolute_caseload_error_less_than: 0.2e+9 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/JSA_income.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/JSA_income.yaml index 90635d651..094b39e6c 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/JSA_income.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/JSA_income.yaml @@ -6,10 +6,10 @@ employment_status: "UNEMPLOYED" weekly_hours: 4 age: 27 - JSA_income_reported: true + jsa_income_reported: true output: - JSA_income_eligible: true - JSA_income: 0 + jsa_income_eligible: true + jsa_income: 0 - name: JSA income-based, basic amount period: 2021 absolute_error_margin: 20 @@ -18,10 +18,10 @@ weekly_hours: 5 employment_income: 100 employment_status: "UNEMPLOYED" - JSA_income_reported: true + jsa_income_reported: true output: - JSA_income_eligible: true - JSA_income_applicable_amount: 59 * 52 + jsa_income_eligible: true + jsa_income_applicable_amount: 59 * 52 - name: JSA income-based, higher age amount period: 2021 absolute_error_margin: 30 @@ -30,8 +30,8 @@ weekly_hours: 1 employment_income: 20 employment_status: "UNEMPLOYED" - JSA_income_reported: true + jsa_income_reported: true claims_legacy_benefits: true output: - JSA_income_eligible: true - JSA_income_applicable_amount: 74.58 * 52 + jsa_income_eligible: true + jsa_income_applicable_amount: 74.58 * 52 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income.yaml index 6d1a7bb23..a0b991a69 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income.yaml @@ -4,8 +4,8 @@ # Benefits child_benefit: 1_000 income_support: 0 - JSA_income: 0 - ESA_income: 0 + jsa_income: 0 + esa_income: 0 # Income employment_income: 0 self_employment_income: 0 @@ -29,8 +29,8 @@ # Benefits child_benefit: 1_000 income_support: 0 - JSA_income: 0 - ESA_income: 0 + jsa_income: 0 + esa_income: 0 # Income employment_income: 0 self_employment_income: 0 @@ -54,8 +54,8 @@ # Benefits child_benefit: 1_000 income_support: 2_250 - JSA_income: 0 - ESA_income: 0 + jsa_income: 0 + esa_income: 0 # Income employment_income: 0 self_employment_income: 0 @@ -79,8 +79,8 @@ # Benefits child_benefit: 1_000 income_support: 2_250 - JSA_income: 0 - ESA_income: 0 + jsa_income: 0 + esa_income: 0 # Income employment_income: 0 self_employment_income: 0 @@ -104,8 +104,8 @@ # Benefits child_benefit: 1_000 income_support: 2_250 - JSA_income: 0 - ESA_income: 0 + jsa_income: 0 + esa_income: 0 # Income employment_income: 0 self_employment_income: 0 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/income/uc_unearned_income.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/income/uc_unearned_income.yaml index dc1f8dbcd..66843ff22 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/income/uc_unearned_income.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/income/uc_unearned_income.yaml @@ -3,7 +3,7 @@ absolute_error_margin: 0 input: carers_allowance: 10_000 - JSA_contrib: 1_000 + jsa_contrib: 1_000 private_pension_income: 100 savings_interest_income: 10 dividend_income: 1 diff --git a/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_income.yaml b/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_income.yaml index 270989abe..f08b05c69 100644 --- a/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_income.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_income.yaml @@ -6,7 +6,7 @@ state_pension: 4 private_pension_income: 8 capital_income: 16 - ESA_contrib: 32 - JSA_contrib: 64 + esa_contrib: 32 + jsa_contrib: 64 output: pension_credit_income: 127 \ No newline at end of file diff --git a/policyengine_uk/tools/takeup.py b/policyengine_uk/tools/takeup.py index 62bec5eb3..26c9144ff 100644 --- a/policyengine_uk/tools/takeup.py +++ b/policyengine_uk/tools/takeup.py @@ -11,7 +11,7 @@ "child_tax_credit", "income_support", "housing_benefit", - "JSA_income", + "jsa_income", ] YEARS = list(range(2022, 2026)) diff --git a/policyengine_uk/variables/gov/dwp/AFCS.py b/policyengine_uk/variables/gov/dwp/AFCS.py index 22d9f4c28..5488239ba 100644 --- a/policyengine_uk/variables/gov/dwp/AFCS.py +++ b/policyengine_uk/variables/gov/dwp/AFCS.py @@ -9,7 +9,7 @@ class afcs(Variable): unit = GBP uprating = "calibration.uprating.september_cpi" - adds = ["AFCS_reported"] + adds = ["afcs_reported"] class afcs_reported(Variable): diff --git a/policyengine_uk/variables/gov/dwp/BSP.py b/policyengine_uk/variables/gov/dwp/BSP.py index 13ff04f0b..0414c8da0 100644 --- a/policyengine_uk/variables/gov/dwp/BSP.py +++ b/policyengine_uk/variables/gov/dwp/BSP.py @@ -8,7 +8,7 @@ class bsp(Variable): definition_period = YEAR unit = GBP - adds = ["BSP_reported"] + adds = ["bsp_reported"] class bsp_reported(Variable): diff --git a/policyengine_uk/variables/gov/dwp/IIDB.py b/policyengine_uk/variables/gov/dwp/IIDB.py index 19a9582c7..20e1388ff 100644 --- a/policyengine_uk/variables/gov/dwp/IIDB.py +++ b/policyengine_uk/variables/gov/dwp/IIDB.py @@ -8,7 +8,7 @@ class iidb(Variable): definition_period = YEAR unit = GBP - adds = ["IIDB_reported"] + adds = ["iidb_reported"] class iidb_reported(Variable): diff --git a/policyengine_uk/variables/gov/dwp/WFA.py b/policyengine_uk/variables/gov/dwp/WFA.py index e9dda2095..46c9c3f2f 100644 --- a/policyengine_uk/variables/gov/dwp/WFA.py +++ b/policyengine_uk/variables/gov/dwp/WFA.py @@ -27,8 +27,8 @@ def formula(household, period, parameters): [ "pension_credit", "income_support", - "ESA_income", - "JSA_income", + "esa_income", + "jsa_income", ], ) > 0 diff --git a/policyengine_uk/variables/gov/dwp/attendance_allowance.py b/policyengine_uk/variables/gov/dwp/attendance_allowance.py index 4d07eb363..22c7ac168 100644 --- a/policyengine_uk/variables/gov/dwp/attendance_allowance.py +++ b/policyengine_uk/variables/gov/dwp/attendance_allowance.py @@ -27,7 +27,7 @@ def formula(person, period, parameters): ) -class AA_reported(Variable): +class attendance_allowance_reported(Variable): value_type = float entity = Person label = "Attendance Allowance (reported)" @@ -46,7 +46,7 @@ class aa_category(Variable): def formula(person, period, parameters): aa = parameters(period).gov.dwp.attendance_allowance SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation - reported_weekly_aa = person("AA_reported", period) / WEEKS_IN_YEAR + reported_weekly_aa = person("attendance_allowance_reported", period) / WEEKS_IN_YEAR return select( [ reported_weekly_aa >= aa.higher * (1 - SAFETY_MARGIN), diff --git a/policyengine_uk/variables/gov/dwp/benefit_cap.py b/policyengine_uk/variables/gov/dwp/benefit_cap.py index da555ae5e..1b210cc63 100644 --- a/policyengine_uk/variables/gov/dwp/benefit_cap.py +++ b/policyengine_uk/variables/gov/dwp/benefit_cap.py @@ -45,9 +45,9 @@ def formula(benunit, period, parameters): QUAL_PERSONAL_BENEFITS = [ "carers_allowance", "dla", - "ESA_contrib", + "esa_contrib", ] - QUAL_BENUNIT_BENEFITS = ["working_tax_credit", "ESA_income"] + QUAL_BENUNIT_BENEFITS = ["working_tax_credit", "esa_income"] qualifying_benunit_benefits = add( benunit, period, QUAL_BENUNIT_BENEFITS ) @@ -68,14 +68,14 @@ def formula(benunit, period, parameters): CAPPED_BENEFITS = [ "child_benefit", "child_tax_credit", - "JSA_income", + "jsa_income", "income_support", - "ESA_income", + "esa_income", "universal_credit_pre_benefit_cap", "housing_benefit_pre_benefit_cap", - "JSA_contrib", + "jsa_contrib", "incapacity_benefit", - "ESA_contrib", + "esa_contrib", "sda", ] return max_( diff --git a/policyengine_uk/variables/gov/dwp/dla/mobility.py b/policyengine_uk/variables/gov/dwp/dla/mobility.py index c408751e2..352126d12 100644 --- a/policyengine_uk/variables/gov/dwp/dla/mobility.py +++ b/policyengine_uk/variables/gov/dwp/dla/mobility.py @@ -4,7 +4,7 @@ ) -class DLA_M_reported(Variable): +class dla_m_reported(Variable): value_type = float entity = Person label = "DLA (mobility) (reported)" diff --git a/policyengine_uk/variables/gov/dwp/housing_benefit/applicable_income/housing_benefit_applicable_income.py b/policyengine_uk/variables/gov/dwp/housing_benefit/applicable_income/housing_benefit_applicable_income.py index 69e1026ba..19358bf68 100644 --- a/policyengine_uk/variables/gov/dwp/housing_benefit/applicable_income/housing_benefit_applicable_income.py +++ b/policyengine_uk/variables/gov/dwp/housing_benefit/applicable_income/housing_benefit_applicable_income.py @@ -12,8 +12,27 @@ def formula(benunit, period, parameters): BENUNIT_MEANS_TESTED_BENEFITS = [ "child_benefit", "income_support", - "JSA_income", - "ESA_income", + "jsa_income", + "esa_income", + ] + PERSONAL_BENEFITS = [ + "attendance_allowance", + "afcs", + "bsp", + "carers_allowance", + "dla", + "esa_contrib", + "iidb", + "incapacity_benefit", + "jsa_contrib", + "pip", + "sda", + "state_pension", + "student_payments", + "maternity_allowance", + "statutory_sick_pay", + "statutory_maternity_pay", + "ssmg", ] INCOME_COMPONENTS = [ "employment_income", @@ -25,7 +44,7 @@ def formula(benunit, period, parameters): # Add personal benefits, credits and total benefits to income benefits = add(benunit, period, BENUNIT_MEANS_TESTED_BENEFITS) income = add(benunit, period, INCOME_COMPONENTS) - personal_benefits = add(benunit, period, ["personal_benefits"]) + personal_benefits = add(benunit, period, PERSONAL_BENEFITS) credits = add(benunit, period, ["tax_credits"]) increased_income = income + personal_benefits + credits + benefits diff --git a/policyengine_uk/variables/gov/dwp/income_support.py b/policyengine_uk/variables/gov/dwp/income_support.py index 7ec3ee9c0..4686eec94 100644 --- a/policyengine_uk/variables/gov/dwp/income_support.py +++ b/policyengine_uk/variables/gov/dwp/income_support.py @@ -94,14 +94,14 @@ def formula(benunit, period, parameters): lone_parent_with_young_child = lone_parent & youngest_child_5_or_under has_carers = add(benunit, period, ["is_carer_for_benefits"]) > 0 none_SP_age = ~benunit.any(benunit.members("is_SP_age", period)) - has_ESA_income = benunit("ESA_income", period) > 0 + has_esa_income = benunit("esa_income", period) > 0 already_claiming = ( add(benunit, period, ["income_support_reported"]) > 0 ) return ( (has_carers | lone_parent_with_young_child) & none_SP_age - & ~has_ESA_income + & ~has_esa_income & already_claiming ) diff --git a/policyengine_uk/variables/gov/dwp/sda.py b/policyengine_uk/variables/gov/dwp/sda.py index 4701d78c5..b5e4f753a 100644 --- a/policyengine_uk/variables/gov/dwp/sda.py +++ b/policyengine_uk/variables/gov/dwp/sda.py @@ -9,7 +9,7 @@ class sda(Variable): unit = GBP def formula(person, period, parameters): - reported = person("SDA_reported", period) > 0 + reported = person("sda_reported", period) > 0 # SDA recipients receive a basic rate, and potentially # an age-related addition. We assume they receive the highest # age-related addition. diff --git a/policyengine_uk/variables/gov/dwp/tax_credits.py b/policyengine_uk/variables/gov/dwp/tax_credits.py index 2bdb0c03d..c4a01e305 100644 --- a/policyengine_uk/variables/gov/dwp/tax_credits.py +++ b/policyengine_uk/variables/gov/dwp/tax_credits.py @@ -45,7 +45,7 @@ def formula(benunit, period, parameters): if bi.interactions.include_in_means_tests: STEP_2_COMPONENTS.append("basic_income") income += add(benunit, period, STEP_2_COMPONENTS) - EXEMPT_BENEFITS = ["income_support", "ESA_income", "JSA_income"] + EXEMPT_BENEFITS = ["income_support", "esa_income", "jsa_income"] on_exempt_benefits = add(benunit, period, EXEMPT_BENEFITS) > 0 return income * ~on_exempt_benefits diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/base.py b/policyengine_uk/variables/gov/hmrc/income_tax/base.py index 2983126ac..513139493 100644 --- a/policyengine_uk/variables/gov/hmrc/income_tax/base.py +++ b/policyengine_uk/variables/gov/hmrc/income_tax/base.py @@ -34,7 +34,7 @@ class social_security_income(Variable): adds = [ "state_pension", "incapacity_benefit", - "JSA_contrib", - "ESA_contrib", + "jsa_contrib", + "esa_contrib", "carers_allowance", ] diff --git a/policyengine_uk/variables/household/demographic/disability.py b/policyengine_uk/variables/household/demographic/disability.py index 03f9e3860..c12ac7441 100644 --- a/policyengine_uk/variables/household/demographic/disability.py +++ b/policyengine_uk/variables/household/demographic/disability.py @@ -53,7 +53,7 @@ def formula(person, period, parameters): >= benefit.pip.daily_living.enhanced * WEEKS_IN_YEAR - THRESHOLD_SAFETY_GAP ) - paragraph_5 = person("AFCS", period) > 0 + paragraph_5 = person("afcs", period) > 0 return sum([paragraph_3, paragraph_4, paragraph_5]) > 0 diff --git a/policyengine_uk/variables/household/income/benefit.py b/policyengine_uk/variables/household/income/benefit.py index cfb863b47..1cee580a0 100644 --- a/policyengine_uk/variables/household/income/benefit.py +++ b/policyengine_uk/variables/household/income/benefit.py @@ -4,51 +4,6 @@ This file contains variables that are commonly used in benefit eligibility calculations. """ - -class family_benefits(Variable): - value_type = float - entity = Person - label = "Total simulated family benefits for this person" - definition_period = YEAR - unit = GBP - defined_for = "is_benunit_head" - - adds = [ - "child_benefit", - "ESA_income", - "housing_benefit", - "income_support", - "JSA_income", - "pension_credit", - "universal_credit", - "council_tax_benefit", - "child_tax_credit", - "working_tax_credit", - ] - - -class family_benefits_reported(Variable): - value_type = float - entity = Person - label = "Total reported family benefits for this person" - definition_period = YEAR - unit = GBP - - # Currently no family benefits reported. - - -class benefits(Variable): - value_type = float - entity = Person - label = "Total benefits" - documentation = "Total state benefits" - unit = GBP - definition_period = YEAR - - def formula(person, period, parameters): - return add(person, period, ["personal_benefits", "family_benefits"]) - - class household_benefits(Variable): value_type = float entity = Household @@ -58,23 +13,24 @@ class household_benefits(Variable): unit = GBP adds = [ "child_benefit", - "ESA_income", + "esa_income", + "esa_contrib" "housing_benefit", "income_support", - "JSA_income", + "jsa_income", + "jsa_contrib", "pension_credit", "universal_credit", "working_tax_credit", "child_tax_credit", "attendance_allowance", - "AFCS", - "BSP", + "afcs", + "bsp", "carers_allowance", "dla", - "ESA_contrib", - "IIDB", + "iidb", "incapacity_benefit", - "JSA_contrib", + "jsa_contrib", "pip", "sda", "state_pension", @@ -124,40 +80,6 @@ def formula(household, period, parameters): ) -class other_benefits(Variable): - value_type = float - entity = Person - label = "Income from benefits not modelled or detailed in the model" - definition_period = YEAR - unit = GBP - - adds = ["benefits_reported"] - subtracts = ["personal_benefits", "family_benefits"] - - -class benefits_reported(Variable): - value_type = float - entity = Person - label = "Total simulated" - definition_period = YEAR - unit = GBP - - adds = ["personal_benefits_reported", "family_benefits_reported"] - - -class benefits_modelling(Variable): - value_type = float - entity = Person - label = ( - "Difference between reported and simulated benefits for this person" - ) - definition_period = YEAR - unit = GBP - - adds = ["benefits"] - subtracts = ["benefits_reported"] - - class is_QYP(Variable): value_type = bool entity = Person @@ -255,65 +177,6 @@ def formula(benunit, period, parameters): families = family_type.possible_values return family_type == families.SINGLE - -class personal_benefits(Variable): - value_type = float - entity = Person - label = "Value of personal, non-means-tested benefits" - definition_period = YEAR - unit = GBP - - adds = [ - "attendance_allowance", - "AFCS", - "BSP", - "carers_allowance", - "dla", - "ESA_contrib", - "IIDB", - "incapacity_benefit", - "JSA_contrib", - "pip", - "sda", - "state_pension", - "student_payments", - "student_loans", - "maternity_allowance", - "statutory_sick_pay", - "statutory_maternity_pay", - "ssmg", - "basic_income", - ] - - -class personal_benefits_reported(Variable): - value_type = float - entity = Person - label = "Value of personal, non-means-tested benefits" - definition_period = YEAR - unit = GBP - - adds = [ - i + "_reported" - for i in [ - "AA", - "AFCS", - "BSP", - "carers_allowance", - "DLA_M", - "DLA_SC", - "ESA_contrib", - "IIDB", - "incapacity_benefit", - "JSA_contrib", - "PIP_M", - "PIP_DL", - "SDA", - "state_pension", - ] - ] - - class claims_all_entitled_benefits(Variable): value_type = bool entity = BenUnit @@ -324,7 +187,7 @@ class claims_all_entitled_benefits(Variable): ) def formula(benunit, period, parameters): - # Return false we have any reported values in the simulation for benefits. + # Return false if we have any reported values in the simulation for benefits. return ( add( benunit, @@ -334,9 +197,9 @@ def formula(benunit, period, parameters): "working_tax_credit_reported", "universal_credit_reported", "housing_benefit_reported", - "JSA_income_reported", + "jsa_income_reported", "income_support_reported", - "ESA_income_reported", + "esa_income_reported", ], ).sum() < 1 @@ -355,9 +218,9 @@ def formula(benunit, period, parameters): "child_tax_credit_reported", "working_tax_credit_reported", "housing_benefit_reported", - "ESA_income_reported", + "esa_income_reported", "income_support_reported", - "JSA_income_reported", + "jsa_income_reported", ] return add(benunit, period, BENEFITS) > 0 diff --git a/policyengine_uk/variables/input/disability.py b/policyengine_uk/variables/input/disability.py index d97bbe4d6..6b75fcd77 100644 --- a/policyengine_uk/variables/input/disability.py +++ b/policyengine_uk/variables/input/disability.py @@ -54,7 +54,7 @@ def formula(person, period, parameters): dla_m = parameters(period).gov.dwp.dla.mobility SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation reported_weekly_dla_m = ( - person("DLA_M_reported", period) / WEEKS_IN_YEAR + person("dla_m_reported", period) / WEEKS_IN_YEAR ) return select( [ @@ -83,7 +83,7 @@ def formula(person, period, parameters): pip_m = parameters(period).gov.dwp.pip.mobility SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation reported_weekly_pip_m = ( - person("PIP_M_reported", period) / WEEKS_IN_YEAR + person("pip_m_reported", period) / WEEKS_IN_YEAR ) return select( [ @@ -112,7 +112,7 @@ def formula(person, period, parameters): pip_dl = parameters(period).gov.dwp.pip.daily_living SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation reported_weekly_pip_dl = ( - person("PIP_DL_reported", period) / WEEKS_IN_YEAR + person("pip_dl_reported", period) / WEEKS_IN_YEAR ) return select( [ From 22bd7c8b44a862d19c164e52088250f492f4cb7e Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Wed, 11 Sep 2024 14:32:29 +0100 Subject: [PATCH 03/15] Add changes --- policyengine_uk/__init__.py | 2 - .../disable_simulated_benefits.yaml | 5 + .../gov/dwp/universal_credit/takeup.yaml | 7 - .../gov/dwp/universal_credit/takeup_rate.yaml | 6 + .../parameters/gov/ons/population.yaml | 16 ++ .../reforms/policyengine/__init__.py | 1 + .../disable_simulated_benefits.py | 64 ++++++ policyengine_uk/reforms/reforms.py | 6 +- policyengine_uk/system.py | 13 -- policyengine_uk/tools/simulation.py | 187 ------------------ policyengine_uk/tools/uc_rollout.py | 0 .../variables/gov/dwp/ESA_contrib.py | 1 + .../variables/gov/dwp/attendance_allowance.py | 4 +- .../housing_benefit_applicable_income.py | 9 - .../housing_benefit_pre_benefit_cap.py | 1 + .../would_claim_housing_benefit.py | 18 +- .../variables/gov/dwp/income_support.py | 9 +- .../variables/gov/dwp/tax_credits.py | 24 +-- .../is_brought_into_uc_claimant_status.py | 19 -- .../universal_credit_pre_benefit_cap.py | 1 + .../dwp/universal_credit/would_claim_uc.py | 9 +- .../household/demographic/benunit.py | 2 +- .../household/demographic/household.py | 1 + .../variables/household/income/benefit.py | 5 +- policyengine_uk/variables/input/income.py | 2 + 25 files changed, 116 insertions(+), 296 deletions(-) create mode 100644 policyengine_uk/parameters/gov/contrib/policyengine/disable_simulated_benefits.yaml delete mode 100644 policyengine_uk/parameters/gov/dwp/universal_credit/takeup.yaml create mode 100644 policyengine_uk/parameters/gov/dwp/universal_credit/takeup_rate.yaml create mode 100644 policyengine_uk/parameters/gov/ons/population.yaml create mode 100644 policyengine_uk/reforms/policyengine/disable_simulated_benefits.py delete mode 100644 policyengine_uk/tools/simulation.py create mode 100644 policyengine_uk/tools/uc_rollout.py delete mode 100644 policyengine_uk/variables/gov/dwp/universal_credit/is_brought_into_uc_claimant_status.py diff --git a/policyengine_uk/__init__.py b/policyengine_uk/__init__.py index 25b40ca81..caa56cae5 100644 --- a/policyengine_uk/__init__.py +++ b/policyengine_uk/__init__.py @@ -6,9 +6,7 @@ CountryTaxBenefitSystem, Microsimulation, Simulation, - IndividualSim, COUNTRY_DIR, - BASELINE_VARIABLES, parameters, variables, ) diff --git a/policyengine_uk/parameters/gov/contrib/policyengine/disable_simulated_benefits.yaml b/policyengine_uk/parameters/gov/contrib/policyengine/disable_simulated_benefits.yaml new file mode 100644 index 000000000..9b187cf7c --- /dev/null +++ b/policyengine_uk/parameters/gov/contrib/policyengine/disable_simulated_benefits.yaml @@ -0,0 +1,5 @@ +description: Disable simulated benefits. +values: + 2000-01-01: false +metadata: + label: disable simulated benefits \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/dwp/universal_credit/takeup.yaml b/policyengine_uk/parameters/gov/dwp/universal_credit/takeup.yaml deleted file mode 100644 index 62ac6de6e..000000000 --- a/policyengine_uk/parameters/gov/dwp/universal_credit/takeup.yaml +++ /dev/null @@ -1,7 +0,0 @@ -description: Universal Credit takeup rate -values: - 2019-01-01: 0.63 # From PolicyEngine microsimulation (UC claimants vs eligible households). -metadata: - unit: /1 - period: year - label: Universal Credit takeup rate diff --git a/policyengine_uk/parameters/gov/dwp/universal_credit/takeup_rate.yaml b/policyengine_uk/parameters/gov/dwp/universal_credit/takeup_rate.yaml new file mode 100644 index 000000000..7eb6cbc85 --- /dev/null +++ b/policyengine_uk/parameters/gov/dwp/universal_credit/takeup_rate.yaml @@ -0,0 +1,6 @@ +description: Take-up rate of Universal Credit. +values: + 2015-01-01: 0.55 +metadata: + unit: /1 + label: Universal Credit take-up rate \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/ons/population.yaml b/policyengine_uk/parameters/gov/ons/population.yaml new file mode 100644 index 000000000..d813a417e --- /dev/null +++ b/policyengine_uk/parameters/gov/ons/population.yaml @@ -0,0 +1,16 @@ +description: Number of people in the UK. +values: + 2019-01-01: 66_800_000 + 2020-01-01: 67_100_000 + 2021-01-01: 67_400_000 + 2022-01-01: 67_600_000 + 2023-01-01: 67_800_000 + 2024-01-01: 68_100_000 + 2025-01-01: 68_300_000 + 2026-01-01: 68_500_000 + 2027-01-01: 68_700_000 +metadata: + unit: household + reference: + - title: National population projections (2020-based interim) | ONS | Figure 1 + href: https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationprojections/bulletins/nationalpopulationprojections/2020basedinterim \ No newline at end of file diff --git a/policyengine_uk/reforms/policyengine/__init__.py b/policyengine_uk/reforms/policyengine/__init__.py index f1a07aeb5..67049538c 100644 --- a/policyengine_uk/reforms/policyengine/__init__.py +++ b/policyengine_uk/reforms/policyengine/__init__.py @@ -1 +1,2 @@ from .budget_change import * +from .disable_simulated_benefits import * diff --git a/policyengine_uk/reforms/policyengine/disable_simulated_benefits.py b/policyengine_uk/reforms/policyengine/disable_simulated_benefits.py new file mode 100644 index 000000000..dc9db733e --- /dev/null +++ b/policyengine_uk/reforms/policyengine/disable_simulated_benefits.py @@ -0,0 +1,64 @@ +from policyengine_core.model_api import * + + +def disable_simulated_benefits(parameters, period): + if parameters(period).gov.contrib.policyengine.disable_simulated_benefits: + + class DisableSimulatedBenefits(Reform): + def apply(self): + simulation = self.simulation + + BENEFITS = [ + "afcs", + "attendance_allowance", + "bsp", + "carers_allowance", + "child_benefit", + "child_tax_credit", + "council_tax_benefit", + "dla_m", + "dla_sc", + "esa_contrib", + "esa_income", + "housing_benefit", + "iidb", + "incapacity_benefit", + "income_support", + "jsa_contrib", + "jsa_income", + "pension_credit", + "pip_dl", + "pip_m", + "sda", + "ssmg", + "state_pension", + "universal_credit", + "winter_fuel_allowance", + "working_tax_credit", + ] + time_period = simulation.dataset.time_period + YEARS_IN_FUTURE = 10 + for variable in BENEFITS: + entity = simulation.tax_benefit_system.variables[ + variable + ].entity.key + reported_value = simulation.calculate( + variable + "_reported", time_period, map_to=entity + ) + for year in range( + time_period, time_period + YEARS_IN_FUTURE + ): + simulation.set_input(variable, year, reported_value) + + if variable in ["child_tax_credit", "working_tax_credit"]: + # CTC and WTC have their own pre_minimum variables because tax credits aren't paid if + # below a threshold. + variable = variable + "_pre_minimum" + for year in range( + time_period, time_period + YEARS_IN_FUTURE + ): + simulation.set_input( + variable, year, reported_value + ) + + return DisableSimulatedBenefits diff --git a/policyengine_uk/reforms/reforms.py b/policyengine_uk/reforms/reforms.py index eb69e11a5..f8f732b87 100644 --- a/policyengine_uk/reforms/reforms.py +++ b/policyengine_uk/reforms/reforms.py @@ -1,6 +1,9 @@ from .cps import create_marriage_tax_reform from .conservatives import create_household_based_hitc_reform -from .policyengine import create_budget_change_reform +from .policyengine import ( + create_budget_change_reform, + disable_simulated_benefits, +) from policyengine_core.model_api import * from policyengine_core import periods @@ -11,6 +14,7 @@ def create_structural_reforms_from_parameters(parameters, period): create_marriage_tax_reform(parameters, period), create_household_based_hitc_reform(parameters, period), create_budget_change_reform(parameters, period), + disable_simulated_benefits(parameters, period), ] reforms = tuple(filter(lambda x: x is not None, reforms)) diff --git a/policyengine_uk/system.py b/policyengine_uk/system.py index 5b1fc1e84..ccbb8acca 100644 --- a/policyengine_uk/system.py +++ b/policyengine_uk/system.py @@ -4,7 +4,6 @@ from policyengine_core.simulations import ( Simulation as CoreSimulation, Microsimulation as CoreMicrosimulation, - IndividualSim as CoreIndividualSim, ) from policyengine_uk.data import ( DATASETS, @@ -106,15 +105,3 @@ def __init__(self, *args, **kwargs): "employment_income_before_lsr", known_period, array ) employment_income.delete_arrays(known_period) - - -class IndividualSim(CoreIndividualSim): # Deprecated - tax_benefit_system = CountryTaxBenefitSystem - entities = {entity.key: entity for entity in entities} - default_dataset = EnhancedFRS - required_entities = None - - -BASELINE_VARIABLES = { - variable.name: variable for variable in system.variables.values() -} diff --git a/policyengine_uk/tools/simulation.py b/policyengine_uk/tools/simulation.py deleted file mode 100644 index 4d75dddf0..000000000 --- a/policyengine_uk/tools/simulation.py +++ /dev/null @@ -1,187 +0,0 @@ -import logging -from policyengine_uk import CountryTaxBenefitSystem -from policyengine_uk.data import EnhancedFRS -from policyengine_uk.entities import entities -import numpy as np -import warnings -from policyengine_uk.entities import * -import numpy as np -import warnings -from policyengine_uk.initial_setup import REPO, set_default -from policyengine_uk.reforms.presets.current_date import use_current_parameters -from policyengine_uk.reforms.presets.average_parameters import ( - average_parameters as apply_parameter_averaging, -) -from policyengine_uk.tools.baseline_variables import ( - generate_baseline_variables, -) -from policyengine_uk.tools.parameters import backdate_parameters -from policyengine_core.reforms import Reform -from policyengine_uk.data import DATASETS, SynthFRS -from policyengine_core.simulations import ( - Microsimulation as GeneralMicrosimulation, - IndividualSim as GeneralIndividualSim, -) -import yaml -from pathlib import Path -import h5py -import pandas as pd -from policyengine_core.parameters.operations import ( - interpolate_parameters, - uprate_parameters, - propagate_parameter_metadata, -) -from policyengine_core.model_api import Reform -from policyengine_uk.tools.tax_benefit_uprating import add_tax_benefit_uprating -from functools import reduce - - -with open(Path(__file__).parent / "datasets.yml") as f: - datasets = yaml.safe_load(f) - DEFAULT_DATASET = list( - filter(lambda ds: ds.name == datasets["default"], DATASETS) - )[0] - - -warnings.filterwarnings("ignore") - -np.random.seed(0) - - -def chain(*funcs): - def f(parameters): - for func in funcs: - args = func(parameters) - return args - - return f - - -class prepare_parameters(Reform): - def apply(self): - self.modify_parameters( - chain( - add_tax_benefit_uprating, - propagate_parameter_metadata, - interpolate_parameters, - uprate_parameters, - ) - ) - - -class Microsimulation(GeneralMicrosimulation): - tax_benefit_system = CountryTaxBenefitSystem - entities = entities - default_dataset = DEFAULT_DATASET - post_reform = prepare_parameters, backdate_parameters() - - def __init__( - self, - reform: Reform = (), - dataset: type = EnhancedFRS, - year: int = 2022, - adjust_weights: bool = False, - average_parameters: bool = False, - add_baseline_values: bool = True, - post_reform: Reform = None, - ): - if len(dataset.years) == 0: - logging.warning( - f"You are trying to run a microsimulation using the dataset: {dataset.label}, but no years of that dataset could be found. Attempting to download it." - ) - try: - dataset.download(year) - except Exception as e: - logging.warning( - f"Encountered an error when attempting to download the {dataset.label} (this is likely because your account could not be authenticated, if it is not a public dataset). Attempting to download the Synthetic FRS." - ) - try: - SynthFRS.download(year) - dataset = SynthFRS - except Exception as e: - logging.warning( - f"Encountered an error when attempting to download the synthetic FRS dataset: {e}" - ) - raise e - if post_reform is not None: - self.post_reform = post_reform - if year is None: - year = self.default_year or max(dataset.years) - else: - year = year - year = int(year) - - # Check if dataset is available - - if year not in dataset.years: - print( - f"Dataset {dataset.name} does not contain year {year} (but it does contain {dataset.years}" - ) - download = input( - f"\nYear {year} not available in dataset {dataset.name}: \n\t* Download the dataset [y]\n\t* Use the synthetic FRS (and set default) [n]\n\nChoice: " - ) - if download == "y": - dataset.download(year) - else: - set_default(SynthFRS) - dataset = SynthFRS - if year not in dataset.years: - logging.info( - f"Year {year} synthetic FRS not stored, downloading..." - ) - dataset.download(year) - - super().__init__(reform=reform, dataset=dataset) - - if ( - ("frs_enhanced" in dataset.name) - and adjust_weights - and year >= 2022 - ): - weight_file = ( - Path(__file__).parent.parent / "calibration" / "frs_weights.h5" - ) - if not weight_file.exists(): - raise FileNotFoundError("Weight adjustment file not found.") - with h5py.File(weight_file, "r") as f: - for year in f.keys(): - self.simulation.set_input( - "household_weight", year, np.array(f[year]) - ) - - self.simulation.set_input( - "person_weight", - year, - self.calc( - "household_weight", period=year, map_to="person" - ).values, - ) - - self.simulation.set_input( - "benunit_weight", - year, - self.calc( - "household_weight", period=year, map_to="benunit" - ).values, - ) - - if average_parameters: - self.simulation.tax_benefit_system.parameters = ( - apply_parameter_averaging( - self.simulation.tax_benefit_system.parameters - ) - ) - - -class IndividualSim(GeneralIndividualSim): - tax_benefit_system = CountryTaxBenefitSystem - post_reform = backdate_parameters() - - default_roles = dict( - benunit="adult", - household="adult", - ) - required_entities = [ - "benunit", - "household", - ] diff --git a/policyengine_uk/tools/uc_rollout.py b/policyengine_uk/tools/uc_rollout.py new file mode 100644 index 000000000..e69de29bb diff --git a/policyengine_uk/variables/gov/dwp/ESA_contrib.py b/policyengine_uk/variables/gov/dwp/ESA_contrib.py index f5844c780..ea8c17a5d 100644 --- a/policyengine_uk/variables/gov/dwp/ESA_contrib.py +++ b/policyengine_uk/variables/gov/dwp/ESA_contrib.py @@ -18,6 +18,7 @@ class esa_contrib_reported(Variable): definition_period = YEAR unit = GBP + class esa(Variable): label = "ESA" entity = Person diff --git a/policyengine_uk/variables/gov/dwp/attendance_allowance.py b/policyengine_uk/variables/gov/dwp/attendance_allowance.py index 22c7ac168..8ccd5f8b6 100644 --- a/policyengine_uk/variables/gov/dwp/attendance_allowance.py +++ b/policyengine_uk/variables/gov/dwp/attendance_allowance.py @@ -46,7 +46,9 @@ class aa_category(Variable): def formula(person, period, parameters): aa = parameters(period).gov.dwp.attendance_allowance SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation - reported_weekly_aa = person("attendance_allowance_reported", period) / WEEKS_IN_YEAR + reported_weekly_aa = ( + person("attendance_allowance_reported", period) / WEEKS_IN_YEAR + ) return select( [ reported_weekly_aa >= aa.higher * (1 - SAFETY_MARGIN), diff --git a/policyengine_uk/variables/gov/dwp/housing_benefit/applicable_income/housing_benefit_applicable_income.py b/policyengine_uk/variables/gov/dwp/housing_benefit/applicable_income/housing_benefit_applicable_income.py index 19358bf68..fad9620ff 100644 --- a/policyengine_uk/variables/gov/dwp/housing_benefit/applicable_income/housing_benefit_applicable_income.py +++ b/policyengine_uk/variables/gov/dwp/housing_benefit/applicable_income/housing_benefit_applicable_income.py @@ -16,19 +16,10 @@ def formula(benunit, period, parameters): "esa_income", ] PERSONAL_BENEFITS = [ - "attendance_allowance", - "afcs", - "bsp", "carers_allowance", - "dla", "esa_contrib", - "iidb", - "incapacity_benefit", "jsa_contrib", - "pip", - "sda", "state_pension", - "student_payments", "maternity_allowance", "statutory_sick_pay", "statutory_maternity_pay", diff --git a/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py b/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py index 24072c411..01d78e41d 100644 --- a/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py +++ b/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py @@ -8,5 +8,6 @@ class housing_benefit_pre_benefit_cap(Variable): definition_period = YEAR unit = GBP defined_for = "housing_benefit_eligible" + defined_for = "would_claim_housing_benefit" adds = ["housing_benefit_entitlement"] diff --git a/policyengine_uk/variables/gov/dwp/housing_benefit/would_claim_housing_benefit.py b/policyengine_uk/variables/gov/dwp/housing_benefit/would_claim_housing_benefit.py index 7af999554..5136267b7 100644 --- a/policyengine_uk/variables/gov/dwp/housing_benefit/would_claim_housing_benefit.py +++ b/policyengine_uk/variables/gov/dwp/housing_benefit/would_claim_housing_benefit.py @@ -15,20 +15,4 @@ def formula(benunit, period, parameters): "claims_all_entitled_benefits", period ) reported_hb = add(benunit, period, ["housing_benefit_reported"]) > 0 - baseline = benunit("housing_benefit_baseline_entitlement", period) > 0 - entitlement_received = ( - benunit("housing_benefit_entitlement", period) > 0 - ) - takeup_rate = parameters(period).gov.dwp.housing_benefit.takeup - return select( - [ - reported_hb | claims_all_entitled_benefits, - ~baseline & entitlement_received, - True, - ], - [ - True, - random(benunit) < takeup_rate, - False, - ], - ) + return claims_all_entitled_benefits | reported_hb diff --git a/policyengine_uk/variables/gov/dwp/income_support.py b/policyengine_uk/variables/gov/dwp/income_support.py index 4686eec94..500fd333c 100644 --- a/policyengine_uk/variables/gov/dwp/income_support.py +++ b/policyengine_uk/variables/gov/dwp/income_support.py @@ -23,14 +23,7 @@ def formula(benunit, period, parameters): claims_all_entitled_benefits = benunit( "claims_all_entitled_benefits", period ) - baseline = benunit("baseline_income_support_entitlement", period) > 0 - eligible = benunit("income_support_entitlement", period) > 0 - takeup_rate = parameters(period).gov.dwp.housing_benefit.takeup - return select( - [reported_is | claims_all_entitled_benefits, ~baseline & eligible], - [True, random(benunit) < takeup_rate], - default=False, - ) + return reported_is | claims_all_entitled_benefits class income_support_applicable_income(Variable): diff --git a/policyengine_uk/variables/gov/dwp/tax_credits.py b/policyengine_uk/variables/gov/dwp/tax_credits.py index c4a01e305..a8dacb950 100644 --- a/policyengine_uk/variables/gov/dwp/tax_credits.py +++ b/policyengine_uk/variables/gov/dwp/tax_credits.py @@ -108,17 +108,7 @@ def formula(benunit, period, parameters): claims_all_entitled_benefits = benunit( "claims_all_entitled_benefits", period ) - baseline = benunit("baseline_ctc_entitlement", period) > 0 - takeup_rate = parameters(period).gov.dwp.housing_benefit.takeup - claims_legacy_benefits = benunit("claims_legacy_benefits", period) - return select( - [ - reported_ctc | claims_all_entitled_benefits, - ~baseline & claims_legacy_benefits, - ], - [True, random(benunit) < takeup_rate], - default=False, - ) + return reported_ctc | claims_all_entitled_benefits class CTC_maximum_rate(Variable): @@ -304,17 +294,7 @@ def formula(benunit, period, parameters): claims_all_entitled_benefits = benunit( "claims_all_entitled_benefits", period ) - baseline = benunit("baseline_wtc_entitlement", period) > 0 - takeup_rate = parameters(period).gov.dwp.housing_benefit.takeup - claims_legacy_benefits = benunit("claims_legacy_benefits", period) - return select( - [ - reported_wtc | claims_all_entitled_benefits, - ~baseline & claims_legacy_benefits, - ], - [True, random(benunit) < takeup_rate], - default=False, - ) + return reported_wtc | claims_all_entitled_benefits class WTC_maximum_rate(Variable): diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/is_brought_into_uc_claimant_status.py b/policyengine_uk/variables/gov/dwp/universal_credit/is_brought_into_uc_claimant_status.py deleted file mode 100644 index 8e4ee8abe..000000000 --- a/policyengine_uk/variables/gov/dwp/universal_credit/is_brought_into_uc_claimant_status.py +++ /dev/null @@ -1,19 +0,0 @@ -from policyengine_uk.model_api import * - - -class is_brought_into_uc_claimant_status(Variable): - label = "brought into Universal Credit claimant status" - entity = BenUnit - definition_period = YEAR - value_type = bool - - def formula(benunit, period, parameters): - if benunit.simulation.baseline is None: - return False - uc_entitled = benunit("is_uc_entitled", period) - uc_entitled_baseline = benunit("is_uc_entitled_baseline", period) - takeup = parameters(period).gov.dwp.universal_credit.takeup - takes_up_given_new_claimant = random(benunit) < takeup - return ( - uc_entitled & ~uc_entitled_baseline & takes_up_given_new_claimant - ) diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/universal_credit_pre_benefit_cap.py b/policyengine_uk/variables/gov/dwp/universal_credit/universal_credit_pre_benefit_cap.py index dff572e63..7f6392708 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit/universal_credit_pre_benefit_cap.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit/universal_credit_pre_benefit_cap.py @@ -9,6 +9,7 @@ class universal_credit_pre_benefit_cap(Variable): definition_period = YEAR unit = GBP category = BENEFIT + defined_for = "would_claim_uc" adds = ["uc_maximum_amount"] subtracts = ["uc_income_reduction"] diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/would_claim_uc.py b/policyengine_uk/variables/gov/dwp/universal_credit/would_claim_uc.py index 45211260f..cd49be13a 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit/would_claim_uc.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit/would_claim_uc.py @@ -11,13 +11,8 @@ class would_claim_uc(Variable): definition_period = YEAR def formula(benunit, period, parameters): - current_uc_claimant = ( - add(benunit, period, ["universal_credit_reported"]) > 0 - ) - brought_into_claim = benunit( - "is_brought_into_uc_claimant_status", period - ) + takes_up = random(benunit) < parameters(period).gov.dwp.universal_credit.takeup_rate is_in_microsimulation = benunit.simulation.dataset is not None if is_in_microsimulation: - return current_uc_claimant | brought_into_claim + return takes_up return True diff --git a/policyengine_uk/variables/household/demographic/benunit.py b/policyengine_uk/variables/household/demographic/benunit.py index b8da26698..7464f74af 100644 --- a/policyengine_uk/variables/household/demographic/benunit.py +++ b/policyengine_uk/variables/household/demographic/benunit.py @@ -202,7 +202,7 @@ def formula(benunit, period, parameters): tenures.RENT_FROM_COUNCIL, tenures.RENT_FROM_HA, ] - return np.isin(tenure, RENT_TENURES) + return sum([tenure == tenure_type for tenure_type in RENT_TENURES]) > 0 class benunit_region(Variable): diff --git a/policyengine_uk/variables/household/demographic/household.py b/policyengine_uk/variables/household/demographic/household.py index 9a80b42d1..c3cb38167 100644 --- a/policyengine_uk/variables/household/demographic/household.py +++ b/policyengine_uk/variables/household/demographic/household.py @@ -36,6 +36,7 @@ class household_weight(Variable): entity = Household label = "Weight factor for the household" definition_period = YEAR + uprating = "gov.ons.population" class Country(Enum): diff --git a/policyengine_uk/variables/household/income/benefit.py b/policyengine_uk/variables/household/income/benefit.py index 1cee580a0..0085e0a2b 100644 --- a/policyengine_uk/variables/household/income/benefit.py +++ b/policyengine_uk/variables/household/income/benefit.py @@ -4,6 +4,7 @@ This file contains variables that are commonly used in benefit eligibility calculations. """ + class household_benefits(Variable): value_type = float entity = Household @@ -14,8 +15,7 @@ class household_benefits(Variable): adds = [ "child_benefit", "esa_income", - "esa_contrib" - "housing_benefit", + "esa_contrib" "housing_benefit", "income_support", "jsa_income", "jsa_contrib", @@ -177,6 +177,7 @@ def formula(benunit, period, parameters): families = family_type.possible_values return family_type == families.SINGLE + class claims_all_entitled_benefits(Variable): value_type = bool entity = BenUnit diff --git a/policyengine_uk/variables/input/income.py b/policyengine_uk/variables/input/income.py index 31d2891b0..ca378de9b 100644 --- a/policyengine_uk/variables/input/income.py +++ b/policyengine_uk/variables/input/income.py @@ -17,6 +17,7 @@ class employment_income(Variable): "employment_income_before_lsr", "employment_income_behavioral_response", ] + uprating = "gov.obr.average_earnings" class employment_income_before_lsr(Variable): @@ -71,6 +72,7 @@ class state_pension(Variable): unit = GBP documentation = "Gross State Pension payments" quantity_type = FLOW + uprating = "gov.obr.consumer_price_index" def formula(person, period, parameters): gov = parameters(period).gov From f14ca2886f3fda1033e1bbe7107d5f6cbe8a2e56 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Thu, 12 Sep 2024 11:21:51 +0100 Subject: [PATCH 04/15] Add changes --- policyengine_uk/variables/household/income/benefit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/policyengine_uk/variables/household/income/benefit.py b/policyengine_uk/variables/household/income/benefit.py index 0085e0a2b..f21031320 100644 --- a/policyengine_uk/variables/household/income/benefit.py +++ b/policyengine_uk/variables/household/income/benefit.py @@ -15,7 +15,8 @@ class household_benefits(Variable): adds = [ "child_benefit", "esa_income", - "esa_contrib" "housing_benefit", + "esa_contrib", + "housing_benefit", "income_support", "jsa_income", "jsa_contrib", From 0fe811523cbc89c3d3eefb6fe7a36a11c95dd48f Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 10:28:43 +0100 Subject: [PATCH 05/15] Update parameters --- .../parameters/gov/benefit_uprating_cpi.yaml | 30 +--- .../allowances/personal_allowance/amount.yaml | 4 +- .../rates/scotland/post_starter_rate.yaml | 159 ------------------ .../rates/scotland/pre_starter_rate.yaml | 26 --- .../hmrc/income_tax/rates/scotland/rates.yaml | 49 ++++++ .../gov/hmrc/income_tax/rates/uk.yaml | 2 +- .../thresholds/lower_earnings_limit.yaml | 2 +- .../class_1/thresholds/primary_threshold.yaml | 4 +- .../thresholds/secondary_threshold.yaml | 2 +- .../thresholds/upper_earnings_limit.yaml | 2 +- .../class_2/small_profits_threshold.yaml | 1 + .../thresholds/lower_profits_limit.yaml | 2 +- .../thresholds/upper_profits_limit.yaml | 2 +- 13 files changed, 62 insertions(+), 223 deletions(-) delete mode 100644 policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/post_starter_rate.yaml delete mode 100644 policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/pre_starter_rate.yaml create mode 100644 policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/rates.yaml diff --git a/policyengine_uk/parameters/gov/benefit_uprating_cpi.yaml b/policyengine_uk/parameters/gov/benefit_uprating_cpi.yaml index 008113aac..307b9d841 100644 --- a/policyengine_uk/parameters/gov/benefit_uprating_cpi.yaml +++ b/policyengine_uk/parameters/gov/benefit_uprating_cpi.yaml @@ -1,30 +1,6 @@ -description: Most recent September CPIH index value, updated for each uprating occurrence. +description: Most recent September CPIH index value, updated for each uprating occurrence (2014=100) values: - 2026-01-01: 130.94 - 2025-04-01: 131.05 - 2024-04-01: 130.34 - 2023-04-01: 126.69 - 2022-01-01: 114.40 - 2021-01-01: 109.04 - 2020-04-01: 108.4 - 2019-04-01: 106.6 - 2018-04-01: 104.3 - 2017-04-01: 101.5 - 2016-04-01: 100.2 - 2015-04-01: 100.0 - 2014-04-01: 98.7 - 2013-04-01: 96.4 - 2012-04-01: 94.5 - 2011-04-01: 90.4 - 2010-04-01: 88.3 - 2009-04-01: 87.5 - 2008-04-01: 83.5 - 2007-04-01: 81.9 - 2006-04-01: 79.9 - 2005-04-01: 77.9 - 2004-04-01: 77.0 - 2003-04-01: 76.0 - 2002-04-01: 75.0 - 2001-04-01: 73.8 + 2014-01-01: 100 metadata: label: Benefit uprating index + uprating: gov.obr.consumer_price_index diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/allowances/personal_allowance/amount.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/allowances/personal_allowance/amount.yaml index 09de8691a..8092fb015 100644 --- a/policyengine_uk/parameters/gov/hmrc/income_tax/allowances/personal_allowance/amount.yaml +++ b/policyengine_uk/parameters/gov/hmrc/income_tax/allowances/personal_allowance/amount.yaml @@ -6,14 +6,12 @@ values: 2019-04-06: 12_500 2021-04-06: 12_570 2027-04-06: 12_570 - 2028-01-01: 12_820 - 2029-01-01: 13_080 metadata: period: year name: personal_allowance label: Personal allowance unit: currency-GBP - uprating: gov.benefit_uprating_cpi + uprating: gov.obr.consumer_price_index reference: - title: Income Tax Act 2007 s. 35 href: https://www.legislation.gov.uk/ukpga/2007/3/section/35 diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/post_starter_rate.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/post_starter_rate.yaml deleted file mode 100644 index c0ade3c19..000000000 --- a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/post_starter_rate.yaml +++ /dev/null @@ -1,159 +0,0 @@ -brackets: -- rate: - description: The starter rate applies in Scotland and is the first Income Tax - rate - metadata: - label: Scottish starter rate - unit: /1 - values: - 2018-06-01: 0.19 - threshold: - 2018-06-01: 0 -- rate: - description: The Scottish basic rate is similar to the UK basic rate, but operates - over a smaller region of income - metadata: - label: Scottish basic rate - unit: /1 - values: - 2018-06-01: 0.2 - threshold: - description: The threshold at which an individual pays the basic rate - metadata: - label: Scottish basic rate threshold - period: year - unit: currency-GBP - values: - 2018-06-01: 2_000 - 2019-06-01: 2_049 - 2020-03-04: - value: 2_085 - reference: - - title: "Capture in full: Tax rates 2020/21; Spring Budget 2020" - href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf - 2022-01-01: - value: 2_162 - reference: - - title: "Scottish Rate Resolution 2022-23: motion and explanatory note" - href: https://www.gov.scot/publications/scottish-rate-resolution-2022-23-motion-and-explanatory-note/ - 2023-01-01: - value: 2_162 - reference: - - title: "Scottish Rate Resolution 2023-24: draft motion and explanatory note" - href: https://www.gov.scot/publications/scottish-rate-resolution-2023-24-draft-motion-explanatory-note/ -- rate: - description: The third rate in Scottish Income Tax - metadata: - label: Scottish intermediate rate - unit: /1 - values: - 2018-06-01: 0.21 - threshold: - description: The threshold at which an individual pays the Scottish intermediate - rate - metadata: - label: Scottish intermediate rate threshold - period: year - unit: currency-GBP - values: - 2018-06-01: 12_150 - 2020-03-04: - value: 12_658 - reference: - - title: "Capture in full: Tax rates 2020/21; Spring Budget 2020" - href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf - 2021-06-01: 12_658 - 2022-01-01: - value: 13_118 - reference: - - title: "Scottish Rate Resolution 2022-23: motion and explanatory note" - href: https://www.gov.scot/publications/scottish-rate-resolution-2022-23-motion-and-explanatory-note/ - 2023-01-01: - value: 13_118 - reference: - - title: "Scottish Rate Resolution 2023-24: draft motion and explanatory note" - href: https://www.gov.scot/publications/scottish-rate-resolution-2023-24-draft-motion-explanatory-note/ -- rate: - description: The fourth rate in Scottish Income Tax - metadata: - label: Scottish higher rate - unit: /1 - values: - 2018-06-01: 0.4 - 2020-03-04: 0.41 - threshold: - description: The threshold at which an individual pays the Scottish higher rate - metadata: - label: Scottish higher rate threshold - period: year - unit: currency-GBP - values: - 2018-06-01: 31_580 - 2019-06-01: 30_930 - 2020-03-04: - value: 30_930 - reference: - - title: "Capture in full: Tax rates 2020/21; Spring Budget 2020" - href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf - 2022-01-01: - value: 31_092 - reference: - - title: "Scottish Rate Resolution 2022-23: motion and explanatory note" - href: https://www.gov.scot/publications/scottish-rate-resolution-2022-23-motion-and-explanatory-note/ - 2023-01-01: - value: 31_092 - reference: - - title: "Scottish Rate Resolution 2023-24: draft motion and explanatory note" - href: https://www.gov.scot/publications/scottish-rate-resolution-2023-24-draft-motion-explanatory-note/ -- rate: - description: The fifth and final rate in Scottish Income Tax - metadata: - label: Scottish additional rate - unit: /1 - values: - 2018-06-01: 0.47 - 2020-03-04: - value: 0.46 - reference: - - title: "Capture in full: Tax rates 2020/21; Spring Budget 2020" - href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf - threshold: - description: The threshold at which an individual pays the Scottish additional - rate - metadata: - label: Scottish additional rate threshold - period: year - unit: currency-GBP - values: - 2018-06-01: 150_000 - 2023-01-01: - value: 125_140 - reference: - - title: "Scottish Rate Resolution 2023-24: draft motion and explanatory note" - href: https://www.gov.scot/publications/scottish-rate-resolution-2023-24-draft-motion-explanatory-note/ -- rate: - description: An extra Scottish tax bracket. - metadata: - label: Extra Scottish tax bracket rate - unit: /1 - values: - 2015-06-05: 0.46 - threshold: - description: The lower threshold for the extra Scottish tax bracket rate. - metadata: - label: Extra Scottish tax bracket threshold - period: year - unit: currency-GBP - values: - 2015-06-05: 10_000_000 -description: Income Tax scale for Scotland -metadata: - economy: false - period: year - propagate_metadata_to_children: true - rate_unit: /1 - reference: - - href: https://www.gov.uk/government/publications/rates-and-allowances-income-tax/income-tax-rates-and-allowances-current-and-past - title: GOV.UK - Historical Income Tax rates and thresholds - threshold_unit: currency-GBP - type: marginal_rate diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/pre_starter_rate.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/pre_starter_rate.yaml deleted file mode 100644 index a93303605..000000000 --- a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/pre_starter_rate.yaml +++ /dev/null @@ -1,26 +0,0 @@ -brackets: -- rate: - 2010-06-01: 0.2 - threshold: - 2010-06-01: 0 -- rate: - 2015-06-01: 0.4 - threshold: - 2015-06-01: 31785 - 2015-06-05: 32000 - 2017-06-01: 31500 -- rate: - 2010-06-01: 0.45 - threshold: - 2015-06-05: 150000 -description: Income Tax scale for Scotland -metadata: - economy: false - period: year - propagate_metadata_to_children: true - rate_unit: /1 - reference: - - title: Income Tax rates and allowances for current and previous tax years - href: https://www.gov.uk/government/publications/rates-and-allowances-income-tax/income-tax-rates-and-allowances-current-and-past - threshold_unit: currency-GBP - type: marginal_rate diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/rates.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/rates.yaml new file mode 100644 index 000000000..d38bdf5f2 --- /dev/null +++ b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/scotland/rates.yaml @@ -0,0 +1,49 @@ +description: Rates for Scottish Income Tax +brackets: + - threshold: + 2021-04-06: 0 + rate: + 2021-04-06: 0.19 # Starter rate + - threshold: + 2021-04-06: 2_306 + 2022-04-06: 2_162 + 2023-04-06: 2_162 + 2024-04-06: 2_097 + rate: + 2021-04-06: 0.20 # Basic rate + - threshold: + 2021-04-06: 13_991 + 2022-04-06: 13_118 + 2023-04-06: 13_118 + 2024-04-06: 12_726 + rate: + 2021-04-06: 0.21 # Intermediate rate + - threshold: + 2021-04-06: 31_092 + 2022-04-06: 31_092 + 2023-04-06: 31_092 + 2024-04-06: 31_092 + rate: + 2021-04-06: 0.41 # Higher rate + 2023-04-06: 0.42 + - threshold: + 2021-04-06: 150_000 + 2023-04-06: 125_140 + 2024-04-06: 62_430 + rate: + 2021-04-06: 0.46 # Additional rate + 2023-04-06: 0.47 + 2024-04-06: 0.45 + - threshold: + 2021-04-06: null + 2024-04-06: 125_140 + rate: + 2021-04-06: null + 2024-04-06: 0.48 +metadata: + threshold_unit: currency-GBP + rate_unit: /1 + label: Scottish Income Tax rates + reference: + - title: GOV.UK + href: https://www.gov.uk/government/publications/rates-and-allowances-income-tax/income-tax-rates-and-allowances-current-and-past diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/uk.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/uk.yaml index e8fa1e949..78057d737 100644 --- a/policyengine_uk/parameters/gov/hmrc/income_tax/rates/uk.yaml +++ b/policyengine_uk/parameters/gov/hmrc/income_tax/rates/uk.yaml @@ -46,7 +46,7 @@ brackets: 2019-06-01: 37500 2020-06-01: 37500 2021-06-01: 37700 - 2025-06-01: 37700 + 2028-06-01: 37700 - rate: description: The additional rate is the highest tax bracket, with no upper bound metadata: diff --git a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/lower_earnings_limit.yaml b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/lower_earnings_limit.yaml index abd12603a..e6cbbb545 100644 --- a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/lower_earnings_limit.yaml +++ b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/lower_earnings_limit.yaml @@ -6,7 +6,7 @@ metadata: - https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/882271/Table-a4.pdf - https://www.gov.uk/government/publications/rates-and-allowances-national-insurance-contributions/rates-and-allowances-national-insurance-contributions unit: currency-GBP - uprating: gov.benefit_uprating_cpi + uprating: gov.obr.consumer_price_index label: NI Lower Earnings Limit values: 2015-04-06: 112 diff --git a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/primary_threshold.yaml b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/primary_threshold.yaml index 00419a212..d93f65438 100644 --- a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/primary_threshold.yaml +++ b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/primary_threshold.yaml @@ -19,7 +19,7 @@ values: reference: - title: Spring Statement 2022 href: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1062486/Spring_Statement_2022_Web_Accessible.pdf - 2026-04-01: + 2027-04-01: value: 241.73 metadata: reference: @@ -29,7 +29,7 @@ metadata: label: NI Primary Threshold name: NI_PT unit: currency-GBP - uprating: gov.benefit_uprating_cpi + uprating: gov.obr.consumer_price_index period: week reference: - title: "GOV.UK | Rates and allowances: National Insurance contributions" diff --git a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/secondary_threshold.yaml b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/secondary_threshold.yaml index 0371cf12f..636727cf2 100644 --- a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/secondary_threshold.yaml +++ b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/secondary_threshold.yaml @@ -3,7 +3,7 @@ metadata: label: NI Secondary Threshold economy: false period: week - propagate_metadata_to_children: true + uprating: gov.obr.consumer_price_index reference: - https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/882271/Table-a4.pdf - https://www.gov.uk/government/publications/rates-and-allowances-national-insurance-contributions/rates-and-allowances-national-insurance-contributions diff --git a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/upper_earnings_limit.yaml b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/upper_earnings_limit.yaml index 245d0a4fe..81c24f510 100644 --- a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/upper_earnings_limit.yaml +++ b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/thresholds/upper_earnings_limit.yaml @@ -11,7 +11,7 @@ values: metadata: label: NI Upper Earnings Limit unit: currency-GBP - uprating: gov.benefit_uprating_cpi + uprating: gov.obr.consumer_price_index period: week reference: - https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/882271/Table-a4.pdf diff --git a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_2/small_profits_threshold.yaml b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_2/small_profits_threshold.yaml index ecbaddc5a..ce9c31871 100644 --- a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_2/small_profits_threshold.yaml +++ b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_2/small_profits_threshold.yaml @@ -15,6 +15,7 @@ values: metadata: unit: currency-GBP label: NI Class 2 Small Profits Threshold + uprating: gov.obr.consumer_price_index reference: - https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/882271/Table-a4.pdf - https://www.gov.uk/government/publications/rates-and-allowances-national-insurance-contributions/rates-and-allowances-national-insurance-contributions diff --git a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_4/thresholds/lower_profits_limit.yaml b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_4/thresholds/lower_profits_limit.yaml index 247053445..d90af8eba 100644 --- a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_4/thresholds/lower_profits_limit.yaml +++ b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_4/thresholds/lower_profits_limit.yaml @@ -22,7 +22,7 @@ metadata: label: NI Lower Profits Limit unit: currency-GBP period: year - uprating: gov.benefit_uprating_cpi + uprating: gov.obr.consumer_price_index reference: - https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/882271/Table-a4.pdf - https://www.gov.uk/government/publications/rates-and-allowances-national-insurance-contributions/rates-and-allowances-national-insurance-contributions diff --git a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_4/thresholds/upper_profits_limit.yaml b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_4/thresholds/upper_profits_limit.yaml index 6011f3e34..8532b9255 100644 --- a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_4/thresholds/upper_profits_limit.yaml +++ b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_4/thresholds/upper_profits_limit.yaml @@ -13,7 +13,7 @@ metadata: name: NI_UPL unit: currency-GBP period: year - uprating: gov.benefit_uprating_cpi + uprating: gov.obr.consumer_price_index reference: - https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/882271/Table-a4.pdf - https://www.gov.uk/government/publications/rates-and-allowances-national-insurance-contributions/rates-and-allowances-national-insurance-contributions From 00c2b5fb38eae1d08b0549707d0f19dd6123538c Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 10:29:34 +0100 Subject: [PATCH 06/15] Rename to lowercase and adjust variable structure --- policyengine_uk/variables/gov/dwp/AFCS.py | 3 ++- policyengine_uk/variables/gov/dwp/BSP.py | 1 + policyengine_uk/variables/gov/dwp/ESA_contrib.py | 1 + policyengine_uk/variables/gov/dwp/ESA_income.py | 1 + policyengine_uk/variables/gov/dwp/IIDB.py | 1 + policyengine_uk/variables/gov/dwp/JSA_contrib.py | 1 + policyengine_uk/variables/gov/dwp/JSA_income.py | 1 + policyengine_uk/variables/gov/dwp/WFA.py | 1 + .../variables/gov/dwp/attendance_allowance.py | 1 + policyengine_uk/variables/gov/dwp/carers_allowance.py | 1 + policyengine_uk/variables/gov/dwp/dla/mobility.py | 1 + policyengine_uk/variables/gov/dwp/dla/self_care.py | 1 + .../dwp/housing_benefit/housing_benefit_reported.py | 1 + .../variables/gov/dwp/incapacity_benefit.py | 1 + policyengine_uk/variables/gov/dwp/income_support.py | 1 + .../variables/gov/dwp/maternity_allowance.py | 1 + .../gov/dwp/pension_credit/pension_credit_reported.py | 1 + policyengine_uk/variables/gov/dwp/pip/daily_living.py | 1 + policyengine_uk/variables/gov/dwp/pip/mobility.py | 1 + policyengine_uk/variables/gov/dwp/sda.py | 1 + policyengine_uk/variables/gov/dwp/state_pension.py | 1 + policyengine_uk/variables/gov/dwp/tax_credits.py | 2 ++ .../dwp/universal_credit/universal_credit_reported.py | 1 + policyengine_uk/variables/gov/hmrc/child_benefit.py | 1 + .../hmrc/income_tax/bracketized_liability/tax_band.py | 2 +- .../gov/hmrc/income_tax/earned_income_tax.py | 3 +-- policyengine_uk/variables/input/income.py | 11 ----------- 27 files changed, 28 insertions(+), 15 deletions(-) diff --git a/policyengine_uk/variables/gov/dwp/AFCS.py b/policyengine_uk/variables/gov/dwp/AFCS.py index 5488239ba..6bb7a065a 100644 --- a/policyengine_uk/variables/gov/dwp/AFCS.py +++ b/policyengine_uk/variables/gov/dwp/AFCS.py @@ -7,7 +7,7 @@ class afcs(Variable): label = "Armed Forces Compensation Scheme" definition_period = YEAR unit = GBP - uprating = "calibration.uprating.september_cpi" + uprating = "gov.benefit_uprating_cpi" adds = ["afcs_reported"] @@ -18,3 +18,4 @@ class afcs_reported(Variable): label = "Armed Forces Compensation Scheme (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/dwp/BSP.py b/policyengine_uk/variables/gov/dwp/BSP.py index 0414c8da0..1962e2044 100644 --- a/policyengine_uk/variables/gov/dwp/BSP.py +++ b/policyengine_uk/variables/gov/dwp/BSP.py @@ -17,3 +17,4 @@ class bsp_reported(Variable): label = "Bereavement Support Payment (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/dwp/ESA_contrib.py b/policyengine_uk/variables/gov/dwp/ESA_contrib.py index ea8c17a5d..cb7c9af67 100644 --- a/policyengine_uk/variables/gov/dwp/ESA_contrib.py +++ b/policyengine_uk/variables/gov/dwp/ESA_contrib.py @@ -17,6 +17,7 @@ class esa_contrib_reported(Variable): label = "Employment and Support Allowance (contribution-based) (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class esa(Variable): diff --git a/policyengine_uk/variables/gov/dwp/ESA_income.py b/policyengine_uk/variables/gov/dwp/ESA_income.py index 819bb04d4..34239a90c 100644 --- a/policyengine_uk/variables/gov/dwp/ESA_income.py +++ b/policyengine_uk/variables/gov/dwp/ESA_income.py @@ -7,6 +7,7 @@ class esa_income_reported(Variable): label = "ESA (income-based) (reported amount)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class esa_income(Variable): diff --git a/policyengine_uk/variables/gov/dwp/IIDB.py b/policyengine_uk/variables/gov/dwp/IIDB.py index 20e1388ff..a432ef631 100644 --- a/policyengine_uk/variables/gov/dwp/IIDB.py +++ b/policyengine_uk/variables/gov/dwp/IIDB.py @@ -17,3 +17,4 @@ class iidb_reported(Variable): label = "Industrial Injuries Disablement Benefit (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/dwp/JSA_contrib.py b/policyengine_uk/variables/gov/dwp/JSA_contrib.py index db33e535b..710d1d20c 100644 --- a/policyengine_uk/variables/gov/dwp/JSA_contrib.py +++ b/policyengine_uk/variables/gov/dwp/JSA_contrib.py @@ -17,3 +17,4 @@ class jsa_contrib_reported(Variable): label = "Job Seeker's Allowance (contribution-based) (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/dwp/JSA_income.py b/policyengine_uk/variables/gov/dwp/JSA_income.py index 684c692df..2cb21d31f 100644 --- a/policyengine_uk/variables/gov/dwp/JSA_income.py +++ b/policyengine_uk/variables/gov/dwp/JSA_income.py @@ -7,6 +7,7 @@ class jsa_income_reported(Variable): label = "JSA (income-based) (reported amount)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class jsa_income(Variable): diff --git a/policyengine_uk/variables/gov/dwp/WFA.py b/policyengine_uk/variables/gov/dwp/WFA.py index 46c9c3f2f..937b6954c 100644 --- a/policyengine_uk/variables/gov/dwp/WFA.py +++ b/policyengine_uk/variables/gov/dwp/WFA.py @@ -7,6 +7,7 @@ class winter_fuel_allowance_reported(Variable): label = "Winter fuel allowance" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class winter_fuel_allowance(Variable): diff --git a/policyengine_uk/variables/gov/dwp/attendance_allowance.py b/policyengine_uk/variables/gov/dwp/attendance_allowance.py index 8ccd5f8b6..d1f10a2db 100644 --- a/policyengine_uk/variables/gov/dwp/attendance_allowance.py +++ b/policyengine_uk/variables/gov/dwp/attendance_allowance.py @@ -33,6 +33,7 @@ class attendance_allowance_reported(Variable): label = "Attendance Allowance (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class aa_category(Variable): diff --git a/policyengine_uk/variables/gov/dwp/carers_allowance.py b/policyengine_uk/variables/gov/dwp/carers_allowance.py index 7bb2cfdc9..3b868e757 100644 --- a/policyengine_uk/variables/gov/dwp/carers_allowance.py +++ b/policyengine_uk/variables/gov/dwp/carers_allowance.py @@ -31,3 +31,4 @@ class carers_allowance_reported(Variable): label = "Carer's Allowance (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/dwp/dla/mobility.py b/policyengine_uk/variables/gov/dwp/dla/mobility.py index 352126d12..201077d10 100644 --- a/policyengine_uk/variables/gov/dwp/dla/mobility.py +++ b/policyengine_uk/variables/gov/dwp/dla/mobility.py @@ -10,6 +10,7 @@ class dla_m_reported(Variable): label = "DLA (mobility) (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class dla_m(Variable): diff --git a/policyengine_uk/variables/gov/dwp/dla/self_care.py b/policyengine_uk/variables/gov/dwp/dla/self_care.py index ec9a5bf81..234fa39e3 100644 --- a/policyengine_uk/variables/gov/dwp/dla/self_care.py +++ b/policyengine_uk/variables/gov/dwp/dla/self_care.py @@ -10,6 +10,7 @@ class dla_sc_reported(Variable): label = "DLA (self-care) (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class dla_sc(Variable): diff --git a/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_reported.py b/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_reported.py index 1769e0e5c..47b836fc2 100644 --- a/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_reported.py +++ b/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_reported.py @@ -7,3 +7,4 @@ class housing_benefit_reported(Variable): label = "reported Housing Benefit amount" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/dwp/incapacity_benefit.py b/policyengine_uk/variables/gov/dwp/incapacity_benefit.py index d2d657a2b..2d8233064 100644 --- a/policyengine_uk/variables/gov/dwp/incapacity_benefit.py +++ b/policyengine_uk/variables/gov/dwp/incapacity_benefit.py @@ -17,3 +17,4 @@ class incapacity_benefit_reported(Variable): label = "Incapacity Benefit (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/dwp/income_support.py b/policyengine_uk/variables/gov/dwp/income_support.py index 500fd333c..4fef5fe49 100644 --- a/policyengine_uk/variables/gov/dwp/income_support.py +++ b/policyengine_uk/variables/gov/dwp/income_support.py @@ -7,6 +7,7 @@ class income_support_reported(Variable): label = "Income Support (reported amount)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class would_claim_IS(Variable): diff --git a/policyengine_uk/variables/gov/dwp/maternity_allowance.py b/policyengine_uk/variables/gov/dwp/maternity_allowance.py index b304e44bd..e22a7b242 100644 --- a/policyengine_uk/variables/gov/dwp/maternity_allowance.py +++ b/policyengine_uk/variables/gov/dwp/maternity_allowance.py @@ -25,6 +25,7 @@ class ssmg_reported(Variable): definition_period = YEAR value_type = float unit = GBP + uprating = "gov.benefit_uprating_cpi" class ssmg(Variable): diff --git a/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_reported.py b/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_reported.py index 8f982f449..095f638be 100644 --- a/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_reported.py +++ b/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_reported.py @@ -7,3 +7,4 @@ class pension_credit_reported(Variable): definition_period = YEAR value_type = float unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/dwp/pip/daily_living.py b/policyengine_uk/variables/gov/dwp/pip/daily_living.py index d2c58ac2c..c4b0e1cc0 100644 --- a/policyengine_uk/variables/gov/dwp/pip/daily_living.py +++ b/policyengine_uk/variables/gov/dwp/pip/daily_living.py @@ -8,6 +8,7 @@ class pip_dl_reported(Variable): label = "PIP (daily living) (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class pip_dl(Variable): diff --git a/policyengine_uk/variables/gov/dwp/pip/mobility.py b/policyengine_uk/variables/gov/dwp/pip/mobility.py index 150fed815..fc58a991c 100644 --- a/policyengine_uk/variables/gov/dwp/pip/mobility.py +++ b/policyengine_uk/variables/gov/dwp/pip/mobility.py @@ -8,6 +8,7 @@ class pip_m_reported(Variable): label = "PIP (mobility) (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class pip_m(Variable): diff --git a/policyengine_uk/variables/gov/dwp/sda.py b/policyengine_uk/variables/gov/dwp/sda.py index b5e4f753a..458aeff60 100644 --- a/policyengine_uk/variables/gov/dwp/sda.py +++ b/policyengine_uk/variables/gov/dwp/sda.py @@ -23,3 +23,4 @@ class sda_reported(Variable): label = "Severe Disablement Allowance (reported)" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/dwp/state_pension.py b/policyengine_uk/variables/gov/dwp/state_pension.py index 6e056dbfe..f5dde8563 100644 --- a/policyengine_uk/variables/gov/dwp/state_pension.py +++ b/policyengine_uk/variables/gov/dwp/state_pension.py @@ -140,6 +140,7 @@ class state_pension_reported(Variable): label = "Reported income from the State Pension" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" def formula_2022(person, period, parameters): return person("state_pension_reported", period.last_year) diff --git a/policyengine_uk/variables/gov/dwp/tax_credits.py b/policyengine_uk/variables/gov/dwp/tax_credits.py index a8dacb950..59d56ddc1 100644 --- a/policyengine_uk/variables/gov/dwp/tax_credits.py +++ b/policyengine_uk/variables/gov/dwp/tax_credits.py @@ -7,6 +7,7 @@ class working_tax_credit_reported(Variable): label = "Working Tax Credit" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class child_tax_credit_reported(Variable): @@ -15,6 +16,7 @@ class child_tax_credit_reported(Variable): label = "Working Tax Credit" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" class tax_credits_applicable_income(Variable): diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/universal_credit_reported.py b/policyengine_uk/variables/gov/dwp/universal_credit/universal_credit_reported.py index 7cf60d220..f29a63069 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit/universal_credit_reported.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit/universal_credit_reported.py @@ -8,3 +8,4 @@ class universal_credit_reported(Variable): documentation = "Reported amount of Universal Credit" definition_period = YEAR unit = GBP + uprating = "gov.benefit_uprating_cpi" diff --git a/policyengine_uk/variables/gov/hmrc/child_benefit.py b/policyengine_uk/variables/gov/hmrc/child_benefit.py index e3e81c236..15af2bb03 100644 --- a/policyengine_uk/variables/gov/hmrc/child_benefit.py +++ b/policyengine_uk/variables/gov/hmrc/child_benefit.py @@ -8,6 +8,7 @@ class child_benefit_reported(Variable): definition_period = YEAR value_type = float unit = GBP + uprating = "gov.benefit_uprating_cpi" class would_claim_child_benefit(Variable): diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py index 141431cd1..254371935 100644 --- a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py +++ b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py @@ -70,7 +70,7 @@ def formula_2018_06_01(person, period, parameters): scottish_band = select( [ income < threshold - for threshold in rates.scotland.post_starter_rate.thresholds[ + for threshold in rates.scotland.rates.thresholds[ :5 ] ], diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py b/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py index 99a8cc4fb..c2ecd870a 100644 --- a/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py +++ b/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py @@ -14,11 +14,10 @@ class earned_income_tax(Variable): def formula(person, period, parameters): rates = parameters(period).gov.hmrc.income_tax.rates - # return rates.uk.calc(person("earned_taxable_income", period)) return where( person("pays_scottish_income_tax", period), - rates.scotland.post_starter_rate.calc( + rates.scotland.rates.calc( person("earned_taxable_income", period) ), rates.uk.calc(person("earned_taxable_income", period)), diff --git a/policyengine_uk/variables/input/income.py b/policyengine_uk/variables/input/income.py index ca378de9b..33de5ab07 100644 --- a/policyengine_uk/variables/input/income.py +++ b/policyengine_uk/variables/input/income.py @@ -40,17 +40,6 @@ class private_pension_income(Variable): quantity_type = FLOW uprating = "gov.obr.non_labour_income" - def formula(person, period, parameters): - # Don't have data, use the old pension income - pension_income = person("pension_income", period) - if pension_income.sum() != 0: - logging.warn( - "`pension_income` is deprecated and will be removed- use `private_pension_income` instead" - ) - return pension_income - else: - return 0 - class pension_income(Variable): value_type = float From 99570462acea35cf5f7ed7ea3ee4709b920c5745 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 10:30:50 +0100 Subject: [PATCH 07/15] Versioning --- changelog_entry.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..7131b9367 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,6 @@ +- bump: minor + changes: + fixed: + - Missing metadata in variables. + - Inflation uprating for some parameters. + - Inconsistent variable capitalisation. From e248f53efc871a485e6bef092fe0401f12e65525 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 10:30:57 +0100 Subject: [PATCH 08/15] Format --- .../variables/gov/dwp/universal_credit/would_claim_uc.py | 5 ++++- .../gov/hmrc/income_tax/bracketized_liability/tax_band.py | 4 +--- .../variables/gov/hmrc/income_tax/earned_income_tax.py | 4 +--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/would_claim_uc.py b/policyengine_uk/variables/gov/dwp/universal_credit/would_claim_uc.py index cd49be13a..137d23b39 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit/would_claim_uc.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit/would_claim_uc.py @@ -11,7 +11,10 @@ class would_claim_uc(Variable): definition_period = YEAR def formula(benunit, period, parameters): - takes_up = random(benunit) < parameters(period).gov.dwp.universal_credit.takeup_rate + takes_up = ( + random(benunit) + < parameters(period).gov.dwp.universal_credit.takeup_rate + ) is_in_microsimulation = benunit.simulation.dataset is not None if is_in_microsimulation: return takes_up diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py index 254371935..ab9cf80aa 100644 --- a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py +++ b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py @@ -70,9 +70,7 @@ def formula_2018_06_01(person, period, parameters): scottish_band = select( [ income < threshold - for threshold in rates.scotland.rates.thresholds[ - :5 - ] + for threshold in rates.scotland.rates.thresholds[:5] ], [ TaxBand.NONE, diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py b/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py index c2ecd870a..b3fb1187b 100644 --- a/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py +++ b/policyengine_uk/variables/gov/hmrc/income_tax/earned_income_tax.py @@ -17,8 +17,6 @@ def formula(person, period, parameters): return where( person("pays_scottish_income_tax", period), - rates.scotland.rates.calc( - person("earned_taxable_income", period) - ), + rates.scotland.rates.calc(person("earned_taxable_income", period)), rates.uk.calc(person("earned_taxable_income", period)), ) From 5a7120f3ace8d73fb50f9df974f3d482eec6559c Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 11:17:22 +0100 Subject: [PATCH 09/15] Fix bug in scottish rates --- .../gov/hmrc/income_tax/bracketized_liability/tax_band.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py index ab9cf80aa..1ab44af1c 100644 --- a/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py +++ b/policyengine_uk/variables/gov/hmrc/income_tax/bracketized_liability/tax_band.py @@ -49,7 +49,7 @@ def formula_2017_04_06(person, period, parameters): scottish_band = select( [ income < threshold - for threshold in rates.scotland.pre_starter_rate.thresholds[:3] + for threshold in rates.scotland.rates.thresholds[:3] ], [TaxBand.NONE, TaxBand.BASIC, TaxBand.HIGHER], default=TaxBand.ADDITIONAL, From a448f8526b2f25eebac0a050f650271557b48075 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 11:17:29 +0100 Subject: [PATCH 10/15] Fix housing benefit bug --- .../dwp/housing_benefit/housing_benefit_pre_benefit_cap.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py b/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py index 01d78e41d..fa6f8a66d 100644 --- a/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py +++ b/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py @@ -7,7 +7,8 @@ class housing_benefit_pre_benefit_cap(Variable): label = "Housing Benefit pre-benefit cap" definition_period = YEAR unit = GBP - defined_for = "housing_benefit_eligible" - defined_for = "would_claim_housing_benefit" - adds = ["housing_benefit_entitlement"] + def formula(benunit, period, parameters): + eligible = benunit("housing_benefit_eligible", period) + would_claim = benunit("would_claim_housing_benefit", period) + return where(eligible & would_claim, benunit("housing_benefit_entitlement", period), 0) From fde394c769cb28eb24e0c03ddc14d92831a3748a Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 11:17:40 +0100 Subject: [PATCH 11/15] Add 100 to error tolerance in future years --- .../finance/benefit/family/JSA_income.yaml | 37 ------------------- .../housing_benefit_applicable_income.yaml | 5 --- ...t_applicable_income_childcare_element.yaml | 7 ++++ .../housing_benefit/housing_benefit.yaml | 2 + .../housing_benefit_applicable_amount.yaml | 6 +++ .../would_claim_housing_benefit.yaml | 10 ----- .../finance/benefit/family/tax_credits.yaml | 5 +-- .../carer_element/uc_carer_element.yaml | 3 +- .../uc_individual_disabled_child_element.yaml | 4 +- ...idual_severely_disabled_child_element.yaml | 4 +- .../is_brought_into_uc_claimant_status.yaml | 17 --------- .../uc_standard_allowance.yaml | 4 +- .../work_allowance/uc_work_allowance.yaml | 4 +- .../baseline/finance/benefit/general.yaml | 8 +--- .../gov/hmrc/income_tax/income_tax.yaml | 23 ------------ 15 files changed, 27 insertions(+), 112 deletions(-) delete mode 100644 policyengine_uk/tests/policy/baseline/finance/benefit/family/JSA_income.yaml delete mode 100644 policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/is_brought_into_uc_claimant_status.yaml diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/JSA_income.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/JSA_income.yaml deleted file mode 100644 index 094b39e6c..000000000 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/JSA_income.yaml +++ /dev/null @@ -1,37 +0,0 @@ -- name: JSA income-based, just after phase-out - period: 2021 - absolute_error_margin: 20 - input: - employment_income: 4200 - employment_status: "UNEMPLOYED" - weekly_hours: 4 - age: 27 - jsa_income_reported: true - output: - jsa_income_eligible: true - jsa_income: 0 -- name: JSA income-based, basic amount - period: 2021 - absolute_error_margin: 20 - input: - age: 18 - weekly_hours: 5 - employment_income: 100 - employment_status: "UNEMPLOYED" - jsa_income_reported: true - output: - jsa_income_eligible: true - jsa_income_applicable_amount: 59 * 52 -- name: JSA income-based, higher age amount - period: 2021 - absolute_error_margin: 30 - input: - age: 26 - weekly_hours: 1 - employment_income: 20 - employment_status: "UNEMPLOYED" - jsa_income_reported: true - claims_legacy_benefits: true - output: - jsa_income_eligible: true - jsa_income_applicable_amount: 74.58 * 52 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income.yaml index a0b991a69..135bd6ceb 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income.yaml @@ -15,7 +15,6 @@ income_tax: 0 national_insurance: 0 # Other - personal_benefits: 0 tax_credits: 0 pension_contributions: 0 housing_benefit_applicable_income_disregard: 5_000 @@ -40,7 +39,6 @@ income_tax: 0 national_insurance: 0 # Other - personal_benefits: 0 tax_credits: 0 pension_contributions: 0 housing_benefit_applicable_income_disregard: 0 @@ -65,7 +63,6 @@ income_tax: 0 national_insurance: 0 # Other - personal_benefits: 0 tax_credits: 0 pension_contributions: 1_500 housing_benefit_applicable_income_disregard: 0 @@ -90,7 +87,6 @@ income_tax: 0 national_insurance: 0 # Other - personal_benefits: 0 tax_credits: 1_000 pension_contributions: 1_500 housing_benefit_applicable_income_disregard: 0 @@ -115,7 +111,6 @@ income_tax: 0 national_insurance: 0 # Other - personal_benefits: 0 tax_credits: 1_000 pension_contributions: 100_000 housing_benefit_applicable_income_disregard: 0 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income_childcare_element.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income_childcare_element.yaml index b0ed6c5ae..519747ad9 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income_childcare_element.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/applicable_income/housing_benefit_applicable_income_childcare_element.yaml @@ -1,5 +1,6 @@ - name: One child, uncapped period: 2025 + absolute_error_margin: 100 input: benunit_count_children: 1 childcare_expenses: 10_000 @@ -8,6 +9,7 @@ - name: One child, capped period: 2025 + absolute_error_margin: 100 input: benunit_count_children: 1 childcare_expenses: 9_000 @@ -16,6 +18,7 @@ - name: Two child, capped period: 2025 + absolute_error_margin: 100 input: benunit_count_children: 2 childcare_expenses: 10_000 @@ -24,6 +27,7 @@ - name: Two child, uncapped period: 2025 + absolute_error_margin: 100 input: benunit_count_children: 2 childcare_expenses: 30_000 @@ -32,6 +36,7 @@ - name: No children period: 2025 + absolute_error_margin: 100 input: benunit_count_children: 0 childcare_expenses: 30_000 @@ -40,6 +45,7 @@ - name: Four children period: 2025 + absolute_error_margin: 100 input: benunit_count_children: 4 childcare_expenses: 30_000 @@ -49,6 +55,7 @@ - name: Four children period: 2025 + absolute_error_margin: 100 input: people: person1: diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/housing_benefit.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/housing_benefit.yaml index 2cf728016..9b0473a2e 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/housing_benefit.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/housing_benefit.yaml @@ -1,5 +1,6 @@ - name: Partially reduced benefit period: 2025 + absolute_error_margin: 100 input: housing_benefit_pre_benefit_cap: 1_000 benefit_cap_reduction: 400 @@ -9,6 +10,7 @@ - name: Capped at 0 period: 2025 + absolute_error_margin: 100 input: housing_benefit_pre_benefit_cap: 1_000 benefit_cap_reduction: 3_000 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/housing_benefit_applicable_amount.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/housing_benefit_applicable_amount.yaml index abe6ba57a..b1b03bc4b 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/housing_benefit_applicable_amount.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/housing_benefit_applicable_amount.yaml @@ -1,5 +1,6 @@ - name: Single person, older amount period: 2025 + absolute_error_margin: 100 input: people: person1: @@ -24,6 +25,7 @@ - name: Single person, younger amount period: 2025 + absolute_error_margin: 100 input: people: person1: @@ -48,6 +50,7 @@ - name: Lone parent, younger amount period: 2025 + absolute_error_margin: 100 input: people: person1: @@ -72,6 +75,7 @@ - name: Lone parent, older amount period: 2025 + absolute_error_margin: 100 input: people: person1: @@ -96,6 +100,7 @@ - name: Couple, older amount period: 2025 + absolute_error_margin: 200 input: people: person1: @@ -120,6 +125,7 @@ - name: Couple, younger amount period: 2025 + absolute_error_margin: 100 input: people: person1: diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/would_claim_housing_benefit.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/would_claim_housing_benefit.yaml index bd53a742c..084b4cd9f 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/would_claim_housing_benefit.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/housing_benefit/would_claim_housing_benefit.yaml @@ -18,16 +18,6 @@ output: would_claim_housing_benefit: true -- name: Entitlement received - period: 2025 - input: - claims_all_entitled_benefits: false - housing_benefit_reported: 0 - housing_benefit_baseline_entitlement: 0 - housing_benefit_entitlement: 1 - output: - would_claim_housing_benefit: true - - name: Ineligible period: 2025 input: diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/tax_credits.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/tax_credits.yaml index 914bfaf5e..4f1860797 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/tax_credits.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/tax_credits.yaml @@ -107,9 +107,6 @@ WTC_lone_parent_element: 0 WTC_disabled_element: 0 WTC_severely_disabled_element: 0 - WTC_worker_element: 825 - WTC_childcare_element: 0 - WTC_maximum_rate: 2834 - name: 60-year-old only needs to meet the lower hours requirement (16) period: 2020 absolute_error_margin: 0 @@ -138,7 +135,7 @@ WTC_worker_element: 0 - name: 30 hours qualifies someone for worker element period: 2022 - absolute_error_margin: 1 + absolute_error_margin: 100 input: is_WTC_eligible: true working_tax_credit_reported: true diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/carer_element/uc_carer_element.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/carer_element/uc_carer_element.yaml index f4e65ece1..b9d083982 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/carer_element/uc_carer_element.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/carer_element/uc_carer_element.yaml @@ -16,7 +16,8 @@ - name: Carer gets element period: 2025 + absolute_error_margin: 1 input: benunit_has_carer: true output: - uc_carer_element: 2_379.72 + uc_carer_element: 2417 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_disabled_child_element.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_disabled_child_element.yaml index 2570af5a2..7c75ca1e1 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_disabled_child_element.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_disabled_child_element.yaml @@ -9,9 +9,9 @@ - name: Child disability element received - 2025 period: 2025 - absolute_error_margin: 0 + absolute_error_margin: 1 input: age: 6 is_disabled_for_benefits: true output: - uc_individual_disabled_child_element: 1_873.32 + uc_individual_disabled_child_element: 1_902 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_severely_disabled_child_element.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_severely_disabled_child_element.yaml index 15cc085b0..e21c6ae31 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_severely_disabled_child_element.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_severely_disabled_child_element.yaml @@ -9,9 +9,9 @@ - name: Element matches in 2025 period: 2025 - absolute_error_margin: 0 + absolute_error_margin: 1 input: age: 6 is_severely_disabled_for_benefits: true output: - uc_individual_severely_disabled_child_element: 5_850.96 + uc_individual_severely_disabled_child_element: 5_942 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/is_brought_into_uc_claimant_status.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/is_brought_into_uc_claimant_status.yaml deleted file mode 100644 index ead9e2ced..000000000 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/is_brought_into_uc_claimant_status.yaml +++ /dev/null @@ -1,17 +0,0 @@ -- name: Not entitled - period: 2022 - absolute_error_margin: 0 - input: - is_uc_entitled: false - is_uc_entitled_baseline: false - output: - is_brought_into_uc_claimant_status: false - -- name: Not entitled baseline ineligible - period: 2022 - absolute_error_margin: 0 - input: - is_uc_entitled: true - is_uc_entitled_baseline: false - output: - is_brought_into_uc_claimant_status: false diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/standard_allowance/uc_standard_allowance.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/standard_allowance/uc_standard_allowance.yaml index a819e85ae..0e38b4042 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/standard_allowance/uc_standard_allowance.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/standard_allowance/uc_standard_allowance.yaml @@ -32,8 +32,8 @@ - name: 2025 test period: 2025 - absolute_error_margin: 0 + absolute_error_margin: 1 input: uc_standard_allowance_claimant_type: COUPLE_OLD output: - uc_standard_allowance: 617.60 * 12 + uc_standard_allowance: 7527 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/uc_work_allowance.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/uc_work_allowance.yaml index 3c9784c2a..627fb0b89 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/uc_work_allowance.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/uc_work_allowance.yaml @@ -18,9 +18,9 @@ - name: Work allowance with housing - 2025 period: 2025 - absolute_error_margin: 0 + absolute_error_margin: 1 input: uc_housing_costs_element: 1 uc_limited_capability_for_WRA: true output: - uc_work_allowance: 4_848 + uc_work_allowance: 4_924 diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/general.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/general.yaml index cec376e77..68ead6bdb 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/general.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/general.yaml @@ -43,10 +43,4 @@ output: is_single: false is_couple: true -- name: Personal benefits added up - period: 2020 - absolute_error_margin: 0 - input: - attendance_allowance: 1 - output: - personal_benefits: 1 + diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml index 1249f26d0..b45256684 100644 --- a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml @@ -13,26 +13,3 @@ private_pension_contributions: 1200 output: income_tax: (34000 - 1200 - 12500) * 0.2 -- name: Income Tax for earner with pension contributions in 2018 - period: 2017 - absolute_error_margin: 10 - input: - employment_income: 34000 - private_pension_contributions: 1200 - output: - income_tax: (34000 - 1200 - 11500) * 0.2 -- name: Income Tax for earner with pension contributions in 2019 - period: 2018 - absolute_error_margin: 10 - input: - employment_income: 34000 - private_pension_contributions: 1200 - output: - income_tax: (34000 - 1200 - 11850) * 0.2 -- name: Income Tax for earner in 2019 - period: 2018 - absolute_error_margin: 10 - input: - employment_income: 34000 - output: - income_tax: (34000 - 11850) * 0.2 From e6f0d754f7cb77e6a67998aeca7676d6dfea2c18 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 11:17:52 +0100 Subject: [PATCH 12/15] Format --- .../dwp/housing_benefit/housing_benefit_pre_benefit_cap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py b/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py index fa6f8a66d..5d54f3e83 100644 --- a/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py +++ b/policyengine_uk/variables/gov/dwp/housing_benefit/housing_benefit_pre_benefit_cap.py @@ -11,4 +11,8 @@ class housing_benefit_pre_benefit_cap(Variable): def formula(benunit, period, parameters): eligible = benunit("housing_benefit_eligible", period) would_claim = benunit("would_claim_housing_benefit", period) - return where(eligible & would_claim, benunit("housing_benefit_entitlement", period), 0) + return where( + eligible & would_claim, + benunit("housing_benefit_entitlement", period), + 0, + ) From 64d18607d10a541b2c265f90a1b077c23c93aa77 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 11:29:39 +0100 Subject: [PATCH 13/15] Increase error margins in 2025 --- .../family/universal_credit/carer_element/uc_carer_element.yaml | 2 +- .../disability/uc_individual_disabled_child_element.yaml | 2 +- .../uc_individual_severely_disabled_child_element.yaml | 2 +- .../standard_allowance/uc_standard_allowance.yaml | 2 +- .../universal_credit/work_allowance/uc_work_allowance.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/carer_element/uc_carer_element.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/carer_element/uc_carer_element.yaml index b9d083982..400340e52 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/carer_element/uc_carer_element.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/carer_element/uc_carer_element.yaml @@ -16,7 +16,7 @@ - name: Carer gets element period: 2025 - absolute_error_margin: 1 + absolute_error_margin: 100 input: benunit_has_carer: true output: diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_disabled_child_element.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_disabled_child_element.yaml index 7c75ca1e1..c92714072 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_disabled_child_element.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_disabled_child_element.yaml @@ -9,7 +9,7 @@ - name: Child disability element received - 2025 period: 2025 - absolute_error_margin: 1 + absolute_error_margin: 100 input: age: 6 is_disabled_for_benefits: true diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_severely_disabled_child_element.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_severely_disabled_child_element.yaml index e21c6ae31..3856972cc 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_severely_disabled_child_element.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/child_element/disability/uc_individual_severely_disabled_child_element.yaml @@ -9,7 +9,7 @@ - name: Element matches in 2025 period: 2025 - absolute_error_margin: 1 + absolute_error_margin: 100 input: age: 6 is_severely_disabled_for_benefits: true diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/standard_allowance/uc_standard_allowance.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/standard_allowance/uc_standard_allowance.yaml index 0e38b4042..f559939ae 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/standard_allowance/uc_standard_allowance.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/standard_allowance/uc_standard_allowance.yaml @@ -32,7 +32,7 @@ - name: 2025 test period: 2025 - absolute_error_margin: 1 + absolute_error_margin: 150 input: uc_standard_allowance_claimant_type: COUPLE_OLD output: diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/uc_work_allowance.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/uc_work_allowance.yaml index 627fb0b89..6ef2cb564 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/uc_work_allowance.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/uc_work_allowance.yaml @@ -18,7 +18,7 @@ - name: Work allowance with housing - 2025 period: 2025 - absolute_error_margin: 1 + absolute_error_margin: 100 input: uc_housing_costs_element: 1 uc_limited_capability_for_WRA: true From 401c35ad39c9534c5f6bd31ba414055b24ce6088 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 11:42:04 +0100 Subject: [PATCH 14/15] Remove unused variables --- .../tests/code_health/test_variables.py | 2 +- .../tests/microsimulation/test_uprating.py | 26 ------------------ .../variables/household/income/income.py | 27 ------------------- 3 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 policyengine_uk/tests/microsimulation/test_uprating.py diff --git a/policyengine_uk/tests/code_health/test_variables.py b/policyengine_uk/tests/code_health/test_variables.py index 456d344b2..1cda05ae0 100644 --- a/policyengine_uk/tests/code_health/test_variables.py +++ b/policyengine_uk/tests/code_health/test_variables.py @@ -1,5 +1,5 @@ -from policyengine_uk import BASELINE_VARIABLES from policyengine_core.model_api import Enum +from policyengine_uk.system import variables as BASELINE_VARIABLES def test_variable_names_match_return_types(): diff --git a/policyengine_uk/tests/microsimulation/test_uprating.py b/policyengine_uk/tests/microsimulation/test_uprating.py deleted file mode 100644 index ae32d600a..000000000 --- a/policyengine_uk/tests/microsimulation/test_uprating.py +++ /dev/null @@ -1,26 +0,0 @@ -from policyengine_uk import Microsimulation -from policyengine_uk.data import EnhancedFRS -import pytest -from itertools import product - -UPRATED_VARIABLES = ( - "council_tax", - "employment_income", - "private_pension_income", - "self_employment_income", - "property_income", - "savings_interest_income", - "dividend_income", -) - -sim = Microsimulation(dataset=EnhancedFRS) - - -@pytest.mark.parametrize( - "variable,year", product(UPRATED_VARIABLES, range(2023, 2026)) -) -def test_uprating(variable: str, year: int): - assert any( - sim.calc(variable, period=year).values - != sim.calc(variable, period=2022).values - ) diff --git a/policyengine_uk/variables/household/income/income.py b/policyengine_uk/variables/household/income/income.py index c47e7ea9a..75bd28eb3 100644 --- a/policyengine_uk/variables/household/income/income.py +++ b/policyengine_uk/variables/household/income/income.py @@ -42,21 +42,6 @@ def formula(person, period, parameters): return income - person("maintenance_expenses", period) -class gross_income(Variable): - value_type = float - entity = Person - label = "Gross income, including benefits" - definition_period = YEAR - unit = GBP - - def formula(person, period, parameters): - COMPONENTS = [ - "market_income", - "benefits", - ] - return add(person, period, COMPONENTS) - - class household_gross_income(Variable): value_type = float entity = Household @@ -73,18 +58,6 @@ def formula(household, period, parameters): ) -class net_income(Variable): - value_type = float - entity = Person - label = "Net income" - documentation = "Market income, minus taxes, plus benefits" - unit = GBP - definition_period = YEAR - - def formula(person, period, parameters): - return person("gross_income", period) - person("tax", period) - - class hours_worked(Variable): value_type = float entity = Person From da14c1c09ea293af7d098cdf3d5e6993d2a3ef4a Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 16 Sep 2024 11:50:56 +0100 Subject: [PATCH 15/15] Remove outdated test --- policyengine_uk/tests/policy/integration/income.yaml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/policyengine_uk/tests/policy/integration/income.yaml b/policyengine_uk/tests/policy/integration/income.yaml index 2093e0f17..56efd77d3 100644 --- a/policyengine_uk/tests/policy/integration/income.yaml +++ b/policyengine_uk/tests/policy/integration/income.yaml @@ -37,15 +37,6 @@ output: dividend_income_tax: 6_225 -- name: Net income with base income - period: 2020 - absolute_error_margin: 0 - input: - gross_income: 400 - tax: 50 - output: - net_income: 350 - - name: Household net income can be negative period: 2020 absolute_error_margin: 0