From a8acbca16a90018e1499c3bec81abf5cc4f75ab8 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Wed, 24 Jul 2024 08:41:45 +0100 Subject: [PATCH 1/4] Add economic assumptions --- .../gov/contrib/policyengine/economy/energy_bills.yaml | 6 ++++++ .../gov/contrib/policyengine/economy/gdp_per_capita.yaml | 6 ++++++ .../gov/contrib/policyengine/economy/interest_rates.yaml | 6 ++++++ .../parameters/gov/contrib/policyengine/economy/rent.yaml | 6 ++++++ .../gov/contrib/policyengine/economy/transport.yaml | 6 ++++++ policyengine_uk/variables/household/income/income.py | 7 ++++++- 6 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 policyengine_uk/parameters/gov/contrib/policyengine/economy/energy_bills.yaml create mode 100644 policyengine_uk/parameters/gov/contrib/policyengine/economy/gdp_per_capita.yaml create mode 100644 policyengine_uk/parameters/gov/contrib/policyengine/economy/interest_rates.yaml create mode 100644 policyengine_uk/parameters/gov/contrib/policyengine/economy/rent.yaml create mode 100644 policyengine_uk/parameters/gov/contrib/policyengine/economy/transport.yaml diff --git a/policyengine_uk/parameters/gov/contrib/policyengine/economy/energy_bills.yaml b/policyengine_uk/parameters/gov/contrib/policyengine/economy/energy_bills.yaml new file mode 100644 index 000000000..ddea73fc7 --- /dev/null +++ b/policyengine_uk/parameters/gov/contrib/policyengine/economy/energy_bills.yaml @@ -0,0 +1,6 @@ +description: Raise energy spending by this percentage. +values: + 2000-01-01: 0 +metadata: + unit: /1 + label: Change to energy spending \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/contrib/policyengine/economy/gdp_per_capita.yaml b/policyengine_uk/parameters/gov/contrib/policyengine/economy/gdp_per_capita.yaml new file mode 100644 index 000000000..eca2c4b7f --- /dev/null +++ b/policyengine_uk/parameters/gov/contrib/policyengine/economy/gdp_per_capita.yaml @@ -0,0 +1,6 @@ +description: Raise all market incomes by this percentage. +values: + 2000-01-01: 0 +metadata: + unit: /1 + label: Change to GDP per capita \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/contrib/policyengine/economy/interest_rates.yaml b/policyengine_uk/parameters/gov/contrib/policyengine/economy/interest_rates.yaml new file mode 100644 index 000000000..e6213c256 --- /dev/null +++ b/policyengine_uk/parameters/gov/contrib/policyengine/economy/interest_rates.yaml @@ -0,0 +1,6 @@ +description: Raise the interest rate on mortgages by this percentage. +values: + 2000-01-01: 0 +metadata: + unit: /1 + label: Change to interest rates \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/contrib/policyengine/economy/rent.yaml b/policyengine_uk/parameters/gov/contrib/policyengine/economy/rent.yaml new file mode 100644 index 000000000..949947ac9 --- /dev/null +++ b/policyengine_uk/parameters/gov/contrib/policyengine/economy/rent.yaml @@ -0,0 +1,6 @@ +description: Raise rental expenses by this percentage. +values: + 2000-01-01: 0 +metadata: + unit: /1 + label: Change to rents \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/contrib/policyengine/economy/transport.yaml b/policyengine_uk/parameters/gov/contrib/policyengine/economy/transport.yaml new file mode 100644 index 000000000..ce5f4335e --- /dev/null +++ b/policyengine_uk/parameters/gov/contrib/policyengine/economy/transport.yaml @@ -0,0 +1,6 @@ +description: Raise transport expenses by this percentage. +values: + 2000-01-01: 0 +metadata: + unit: /1 + label: Change to transport spending \ No newline at end of file diff --git a/policyengine_uk/variables/household/income/income.py b/policyengine_uk/variables/household/income/income.py index 1e0a7cbd8..f999a44e7 100644 --- a/policyengine_uk/variables/household/income/income.py +++ b/policyengine_uk/variables/household/income/income.py @@ -190,7 +190,7 @@ class inflation_adjustment(Variable): def formula(household, period, parameters): cpi = parameters.calibration.uprating.CPI current_period_cpi = cpi(period) - now_cpi = cpi(datetime.datetime.now().strftime("%Y-%m-%d")) + now_cpi = cpi(datetime.datetime.now().strftime("%Y-01-01")) return now_cpi / current_period_cpi @@ -360,6 +360,11 @@ class household_market_income(Variable): "capital_gains", ] + def formula(person, period, parameters): + total = add(person, period, household_market_income.adds) + contrib = parameters(period).gov.contrib.policyengine.economy.gdp_per_capita + return total * (contrib + 1) + class household_income_decile(Variable): label = "household income decile" From c6755c37c41ab1ba3af12a272c937f7f6cc3491e Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Wed, 24 Jul 2024 09:28:57 +0100 Subject: [PATCH 2/4] Fix FRS url --- policyengine_uk/data/datasets/frs/frs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policyengine_uk/data/datasets/frs/frs.py b/policyengine_uk/data/datasets/frs/frs.py index 0da42cce7..5da975024 100644 --- a/policyengine_uk/data/datasets/frs/frs.py +++ b/policyengine_uk/data/datasets/frs/frs.py @@ -139,7 +139,7 @@ def generate(self): RawFRS_2022_23, "frs_2022", "FRS 2022-23", - new_url="release://policyengine/non-public-microdata/uk-2024-july/raw_frs_2022.h5", + new_url="release://policyengine/non-public-microdata/uk-2024-july/frs_2022.h5", ) From 67ee3019ef4937b659421a5ab981b718c44fbfaa Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Thu, 25 Jul 2024 11:05:25 +0100 Subject: [PATCH 3/4] Simplify uprating --- changelog_entry.yaml | 4 +++ .../parameters/gov/obr/average_earnings.yaml | 28 +++++++++++++++++++ .../gov/obr/consumer_price_index.yaml | 22 +++++++++++++++ .../parameters/gov/obr/house_prices.yaml | 28 +++++++++++++++++++ .../parameters/gov/obr/mixed_income.yaml | 23 +++++++++++++++ .../parameters/gov/obr/mortgage_interest.yaml | 28 +++++++++++++++++++ .../parameters/gov/obr/non_labour_income.yaml | 23 +++++++++++++++ .../reforms/policyengine/budget_change.py | 1 - ...d_benefits_individual_non_dep_deduction.py | 1 - .../variables/household/income/income.py | 22 +++------------ .../input/consumption/property/maintenance.py | 2 ++ policyengine_uk/variables/input/income.py | 28 ++++++------------- 12 files changed, 171 insertions(+), 39 deletions(-) create mode 100644 policyengine_uk/parameters/gov/obr/average_earnings.yaml create mode 100644 policyengine_uk/parameters/gov/obr/consumer_price_index.yaml create mode 100644 policyengine_uk/parameters/gov/obr/house_prices.yaml create mode 100644 policyengine_uk/parameters/gov/obr/mixed_income.yaml create mode 100644 policyengine_uk/parameters/gov/obr/mortgage_interest.yaml create mode 100644 policyengine_uk/parameters/gov/obr/non_labour_income.yaml diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..4260278f6 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + changed: + - Simplified uprating indices by moving OBR parameters to gov folder. diff --git a/policyengine_uk/parameters/gov/obr/average_earnings.yaml b/policyengine_uk/parameters/gov/obr/average_earnings.yaml new file mode 100644 index 000000000..84071511f --- /dev/null +++ b/policyengine_uk/parameters/gov/obr/average_earnings.yaml @@ -0,0 +1,28 @@ +description: OBR forecast for average earnings (2008 = 100%) +values: + 2008-01-01: 100.0 + 2009-01-01: 101.8 + 2010-01-01: 102.7 + 2011-01-01: 104.3 + 2012-01-01: 105.0 + 2013-01-01: 110.0 + 2014-01-01: 110.7 + 2015-01-01: 112.9 + 2016-01-01: 115.6 + 2017-01-01: 119.3 + 2018-01-01: 122.4 + 2019-01-01: 125.4 + 2020-01-01: 125.7 + 2021-01-01: 133.3 + 2022-01-01: 140.9 + 2023-01-01: 150.0 + 2024-01-01: 154.6 + 2025-01-01: 157.5 + 2026-01-01: 160.9 + 2027-01-01: 164.6 + 2028-01-01: 168.9 +metadata: + unit: /1 + reference: + - title: OBR March 2024 EFO + href: https://obr.uk/efo/economic-and-fiscal-outlook-march-2024/ diff --git a/policyengine_uk/parameters/gov/obr/consumer_price_index.yaml b/policyengine_uk/parameters/gov/obr/consumer_price_index.yaml new file mode 100644 index 000000000..0c13e7eff --- /dev/null +++ b/policyengine_uk/parameters/gov/obr/consumer_price_index.yaml @@ -0,0 +1,22 @@ +description: OBR forecast for CPI +values: + 2014-01-01: 100 + 2015-01-01: 100.1 + 2016-01-01: 101.2 + 2017-01-01: 104.1 + 2018-01-01: 106.4 + 2019-01-01: 108.3 + 2020-01-01: 108.9 + 2021-01-01: 113.2 + 2022-01-01: 124.6 + 2023-01-01: 131.7 + 2024-01-01: 133.8 + 2025-01-01: 135.9 + 2026-01-01: 138.2 + 2027-01-01: 140.9 + 2028-01-01: 143.7 +metadata: + unit: /1 + reference: + - title: OBR March 2024 EFO + href: https://obr.uk/efo/economic-and-fiscal-outlook-march-2024/ \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/obr/house_prices.yaml b/policyengine_uk/parameters/gov/obr/house_prices.yaml new file mode 100644 index 000000000..61128e3a6 --- /dev/null +++ b/policyengine_uk/parameters/gov/obr/house_prices.yaml @@ -0,0 +1,28 @@ +description: OBR forecast for house prices. +values: + 2008-01-01: 88.2 + 2009-01-01: 85.3 + 2010-01-01: 88.4 + 2011-01-01: 87.2 + 2012-01-01: 87.9 + 2013-01-01: 91.3 + 2014-01-01: 98.6 + 2015-01-01: 104.9 + 2016-01-01: 111.2 + 2017-01-01: 116.2 + 2018-01-01: 119.3 + 2019-01-01: 120.4 + 2020-01-01: 125.9 + 2021-01-01: 137.2 + 2022-01-01: 148.7 + 2023-01-01: 147.6 + 2024-01-01: 144.1 + 2025-01-01: 144.8 + 2026-01-01: 148.6 + 2027-01-01: 153.8 + 2028-01-01: 159.5 +metadata: + unit: currency-GBP + reference: + - title: OBR March 2024 EFO + href: https://obr.uk/efo/economic-and-fiscal-outlook-march-2024/ \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/obr/mixed_income.yaml b/policyengine_uk/parameters/gov/obr/mixed_income.yaml new file mode 100644 index 000000000..48b48835d --- /dev/null +++ b/policyengine_uk/parameters/gov/obr/mixed_income.yaml @@ -0,0 +1,23 @@ +description: OBR forecast for mixed income (largely self-employment income). +values: + 2012-01-01: 103.4 + 2013-01-01: 111.5 + 2014-01-01: 114.9 + 2015-01-01: 124.5 + 2016-01-01: 128.0 + 2017-01-01: 140.0 + 2018-01-01: 144.2 + 2019-01-01: 151.3 + 2020-01-01: 153.7 + 2021-01-01: 158.3 + 2022-01-01: 161.9 + 2023-01-01: 171.5 + 2024-01-01: 178.2 + 2025-01-01: 185.3 + 2026-01-01: 193.5 + 2027-01-01: 202.3 + 2028-01-01: 211.8 +metadata: + reference: + - title: OBR March 2024 EFO + href: https://obr.uk/efo/economic-and-fiscal-outlook-march-2024/ \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/obr/mortgage_interest.yaml b/policyengine_uk/parameters/gov/obr/mortgage_interest.yaml new file mode 100644 index 000000000..60e63c2b0 --- /dev/null +++ b/policyengine_uk/parameters/gov/obr/mortgage_interest.yaml @@ -0,0 +1,28 @@ +description: OBR forecast for household debt service costs. +values: + 2008-01-01: 92.7 + 2009-01-01: 69.0 + 2010-01-01: 64.0 + 2011-01-01: 61.6 + 2012-01-01: 61.3 + 2013-01-01: 61.0 + 2014-01-01: 59.2 + 2015-01-01: 57.7 + 2016-01-01: 56.9 + 2017-01-01: 55.8 + 2018-01-01: 56.9 + 2019-01-01: 57.4 + 2020-01-01: 53.1 + 2021-01-01: 52.3 + 2022-01-01: 60.5 + 2023-01-01: 86.6 + 2024-01-01: 110.8 + 2025-01-01: 109.2 + 2026-01-01: 113.2 + 2027-01-01: 119.7 + 2028-01-01: 125.2 +metadata: + unit: currency-GBP + reference: + - title: OBR March 2024 EFO + href: https://obr.uk/efo/economic-and-fiscal-outlook-march-2024/ \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/obr/non_labour_income.yaml b/policyengine_uk/parameters/gov/obr/non_labour_income.yaml new file mode 100644 index 000000000..2f0c95215 --- /dev/null +++ b/policyengine_uk/parameters/gov/obr/non_labour_income.yaml @@ -0,0 +1,23 @@ +description: OBR forecast for non-labour income. +values: + 2012-01-01: 268.6 + 2013-01-01: 281.4 + 2014-01-01: 298.4 + 2015-01-01: 335.0 + 2016-01-01: 329.0 + 2017-01-01: 339.3 + 2018-01-01: 355.1 + 2019-01-01: 363.9 + 2020-01-01: 342.5 + 2021-01-01: 367.1 + 2022-01-01: 425.2 + 2023-01-01: 458.1 + 2024-01-01: 456.5 + 2025-01-01: 482.6 + 2026-01-01: 504.4 + 2027-01-01: 543.6 + 2028-01-01: 585.3 +metadata: + reference: + - title: OBR March 2024 EFO + href: https://obr.uk/efo/economic-and-fiscal-outlook-march-2024/ \ No newline at end of file diff --git a/policyengine_uk/reforms/policyengine/budget_change.py b/policyengine_uk/reforms/policyengine/budget_change.py index 5c0f1dfdf..d2e020e21 100644 --- a/policyengine_uk/reforms/policyengine/budget_change.py +++ b/policyengine_uk/reforms/policyengine/budget_change.py @@ -163,7 +163,6 @@ def formula(household, period, parameters): [equivalised_income <= upper_bounds[i] for i in range(10)], list(range(1, 11)), ) - print(decile) # Set negatives to -1. # This avoids the bottom decile summing to a negative number, # which would flip the % change in the interface. diff --git a/policyengine_uk/variables/gov/dwp/housing_benefit/non_dep_deduction/household_benefits_individual_non_dep_deduction.py b/policyengine_uk/variables/gov/dwp/housing_benefit/non_dep_deduction/household_benefits_individual_non_dep_deduction.py index 674d0b2d6..95b6bcb69 100644 --- a/policyengine_uk/variables/gov/dwp/housing_benefit/non_dep_deduction/household_benefits_individual_non_dep_deduction.py +++ b/policyengine_uk/variables/gov/dwp/housing_benefit/non_dep_deduction/household_benefits_individual_non_dep_deduction.py @@ -13,5 +13,4 @@ def formula(person, period, parameters): p = parameters(period).gov.dwp.housing_benefit.non_dep_deduction weekly_income = person("total_income", period) / WEEKS_IN_YEAR deduction = p.amount.calc(weekly_income, right=True) - print(weekly_income) return deduction * WEEKS_IN_YEAR diff --git a/policyengine_uk/variables/household/income/income.py b/policyengine_uk/variables/household/income/income.py index f999a44e7..03194ef94 100644 --- a/policyengine_uk/variables/household/income/income.py +++ b/policyengine_uk/variables/household/income/income.py @@ -188,7 +188,7 @@ class inflation_adjustment(Variable): unit = "/1" def formula(household, period, parameters): - cpi = parameters.calibration.uprating.CPI + cpi = parameters.gov.obr.consumer_price_index current_period_cpi = cpi(period) now_cpi = cpi(datetime.datetime.now().strftime("%Y-01-01")) return now_cpi / current_period_cpi @@ -208,22 +208,6 @@ def formula(household, period, parameters): return net_income * household("inflation_adjustment", period) -class real_household_net_income(Variable): - label = "Real household net income" - documentation = "Disposable income in January 2015 prices" - entity = Household - definition_period = YEAR - value_type = float - unit = GBP - - def formula(household, period, parameters): - def cpi(period): - return parameters(period).calibration.uprating.CPI - - multiplier = cpi("2015-01-01") / cpi(period) - return household("household_net_income", period) * multiplier - - class hbai_household_net_income_ahc(Variable): value_type = float entity = Household @@ -362,7 +346,9 @@ class household_market_income(Variable): def formula(person, period, parameters): total = add(person, period, household_market_income.adds) - contrib = parameters(period).gov.contrib.policyengine.economy.gdp_per_capita + contrib = parameters( + period + ).gov.contrib.policyengine.economy.gdp_per_capita return total * (contrib + 1) diff --git a/policyengine_uk/variables/input/consumption/property/maintenance.py b/policyengine_uk/variables/input/consumption/property/maintenance.py index 90035f628..44e752acf 100644 --- a/policyengine_uk/variables/input/consumption/property/maintenance.py +++ b/policyengine_uk/variables/input/consumption/property/maintenance.py @@ -44,6 +44,7 @@ class mortgage_interest_repayment(Variable): documentation = "Total amount spent on mortgage interest repayments" definition_period = YEAR unit = GBP + uprating = "gov.obr.mortgage_interest" class mortgage_capital_repayment(Variable): @@ -52,6 +53,7 @@ class mortgage_capital_repayment(Variable): label = "mortgage capital repayments" definition_period = YEAR unit = GBP + uprating = "gov.obr.house_prices" class council_tax(Variable): diff --git a/policyengine_uk/variables/input/income.py b/policyengine_uk/variables/input/income.py index d7d2f2257..01f915ecb 100644 --- a/policyengine_uk/variables/input/income.py +++ b/policyengine_uk/variables/input/income.py @@ -25,7 +25,7 @@ class employment_income_before_lsr(Variable): label = "employment income before labor supply responses" unit = GBP definition_period = YEAR - uprating = "calibration.programs.employment_income.budgetary_impact.UNITED_KINGDOM" + uprating = "gov.obr.average_earnings" class private_pension_income(Variable): @@ -37,9 +37,7 @@ class private_pension_income(Variable): unit = GBP reference = "Income Tax (Earnings and Pensions) Act 2003 s. 1(1)(b)" quantity_type = FLOW - uprating = ( - "calibration.programs.private_pension_income.budgetary_impact.ENGLAND" - ) + uprating = "gov.obr.non_labour_income" def formula(person, period, parameters): # Don't have data, use the old pension income @@ -62,9 +60,7 @@ class pension_income(Variable): unit = GBP reference = "Income Tax (Earnings and Pensions) Act 2003 s. 1(1)(b)" quantity_type = FLOW - uprating = ( - "calibration.programs.private_pension_income.budgetary_impact.ENGLAND" - ) + uprating = "gov.obr.non_labour_income" class state_pension(Variable): @@ -105,7 +101,7 @@ class self_employment_income(Variable): unit = GBP reference = "Income Tax (Trading and Other Income) Act 2005 s. 1(1)(a)" quantity_type = FLOW - uprating = "calibration.programs.self_employment_income.budgetary_impact.UNITED_KINGDOM" + uprating = "gov.obr.mixed_income" class property_income(Variable): @@ -117,9 +113,7 @@ class property_income(Variable): reference = "Income Tax (Trading and Other Income) Act 2005 s. 1(1)(b)" unit = GBP quantity_type = FLOW - uprating = ( - "calibration.programs.property_income.budgetary_impact.UNITED_KINGDOM" - ) + uprating = "gov.obr.non_labour_income" class savings_interest_income(Variable): @@ -131,7 +125,7 @@ class savings_interest_income(Variable): reference = "Income Tax (Trading and Other Income) Act 2005 s. 365(1)(a)" unit = GBP quantity_type = FLOW - uprating = "calibration.programs.savings_interest_income.budgetary_impact.UNITED_KINGDOM" + uprating = "gov.obr.non_labour_income" class dividend_income(Variable): @@ -143,9 +137,7 @@ class dividend_income(Variable): reference = "Income Tax (Trading and Other Income) Act 2005 s. 365(1)(b-d)" unit = GBP quantity_type = FLOW - uprating = ( - "calibration.programs.dividend_income.budgetary_impact.UNITED_KINGDOM" - ) + uprating = "gov.obr.non_labour_income" class sublet_income(Variable): @@ -155,9 +147,7 @@ class sublet_income(Variable): documentation = "Income from subletting properties" definition_period = YEAR unit = GBP - uprating = ( - "calibration.programs.property_income.budgetary_impact.UNITED_KINGDOM" - ) + uprating = "gov.obr.non_labour_income" class miscellaneous_income(Variable): @@ -167,7 +157,7 @@ class miscellaneous_income(Variable): documentation = "Income from any other source" definition_period = YEAR unit = GBP - uprating = "calibration.programs.employment_income.budgetary_impact.UNITED_KINGDOM" + uprating = "gov.obr.non_labour_income" class private_transfer_income(Variable): From f5b9cb60876d0fafe9445d3006d12e6cf4853a8c Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Thu, 25 Jul 2024 19:38:00 +0100 Subject: [PATCH 4/4] Fix variable --- policyengine_uk/variables/household/income/income.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policyengine_uk/variables/household/income/income.py b/policyengine_uk/variables/household/income/income.py index 03194ef94..c47e7ea9a 100644 --- a/policyengine_uk/variables/household/income/income.py +++ b/policyengine_uk/variables/household/income/income.py @@ -198,7 +198,7 @@ class real_household_net_income(Variable): label = ( f"real household net income ({datetime.datetime.now().year} prices)" ) - entity = Person + entity = Household definition_period = YEAR value_type = float unit = GBP