Skip to content

Commit 2a8e50a

Browse files
Improve growthfactor utils, fix uprating bugs (#1170)
* Fix Enable backwards growth factor application #1169 * Fix Uprate non-labour income sources with nominal GDP growth #1172 * Format * Update end year * Reduce end date
1 parent c5e2038 commit 2a8e50a

18 files changed

Lines changed: 146 additions & 101 deletions

docs/book/assumptions/growthfactors.ipynb

Lines changed: 7 additions & 6 deletions
Large diffs are not rendered by default.

policyengine_uk/data/economic_assumptions.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from policyengine_uk.data.dataset_schema import UKDataset
44

55
START_YEAR = 2020
6-
END_YEAR = 2034
6+
END_YEAR = 2029
77

88

99
def create_policyengine_uprating_factors_table():
@@ -45,27 +45,45 @@ def create_policyengine_uprating_factors_table():
4545

4646
file_path = Path(__file__).parent / "uprating_growth_factors.csv"
4747
df_growth["Parameter"] = df.index.map(parameter_by_variable)
48+
df_growth = df_growth[
49+
["Parameter"] + [year for year in range(START_YEAR, END_YEAR + 1)]
50+
]
4851
df_growth.to_csv(file_path)
4952
return pd.read_csv(file_path)
5053

5154

55+
def convert_yoy_growth_to_index(
56+
growth_factors: pd.DataFrame,
57+
):
58+
"""
59+
Convert year-on-year growth factors to an index.
60+
"""
61+
growth_factors = growth_factors.copy()
62+
index = growth_factors[growth_factors.columns[2]] * 0 + 1
63+
for year in growth_factors.columns[2:]:
64+
index *= 1 + growth_factors[year]
65+
growth_factors[year] = index
66+
return growth_factors
67+
68+
5269
def apply_growth_factors(
5370
dataset: UKDataset,
5471
growth_factors: pd.DataFrame,
5572
start_year: int,
5673
end_year: int,
5774
):
75+
start_year = str(start_year)
76+
end_year = str(end_year)
5877
dataset = dataset.copy()
78+
growth_factors_indices = convert_yoy_growth_to_index(growth_factors)
5979
for i in range(len(growth_factors)):
60-
index = 1
6180
variable = growth_factors["Variable"].values[i]
62-
for year in range(start_year, end_year + 1):
63-
growth_factor = growth_factors[str(year)].values[i]
64-
index *= 1 + growth_factor
81+
start_index = growth_factors_indices[start_year].values[i]
82+
end_index = growth_factors_indices[end_year].values[i]
6583

6684
for table in dataset.tables:
6785
if variable in table.columns:
68-
table[variable] *= index
86+
table[variable] *= end_index / start_index
6987

7088
return dataset
7189

policyengine_uk/data/uprating_growth_factors.csv

Lines changed: 75 additions & 76 deletions
Large diffs are not rendered by default.

policyengine_uk/parameters/gov/obr/add_per_capita_parameters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"gov.obr.employment_income",
99
"gov.obr.mixed_income",
1010
"gov.obr.non_labour_income",
11+
"gov.obr.gdp",
1112
]
1213

1314
YEARS = list(range(2019, 2035))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
description: OBR forecast for nominal GDP.
2+
values:
3+
2008-01-01: 1582.7
4+
2009-01-01: 1558.1
5+
2010-01-01: 1627.2
6+
2011-01-01: 1672.3
7+
2012-01-01: 1727.5
8+
2013-01-01: 1800.8
9+
2014-01-01: 1879.5
10+
2015-01-01: 1931.5
11+
2016-01-01: 2015.8
12+
2017-01-01: 2099.8
13+
2018-01-01: 2170.2
14+
2019-01-01: 2240.8
15+
2020-01-01: 2085.6
16+
2021-01-01: 2357.8
17+
2022-01-01: 2583.2
18+
2023-01-01: 2749.0
19+
2024-01-01: 2881.3
20+
2025-01-01: 2993.9
21+
2026-01-01: 3101.4
22+
2027-01-01: 3219.8
23+
2028-01-01: 3339.6
24+
2029-01-01: 3464.1
25+
metadata:
26+
reference:
27+
- title: OBR March 2025 EFO (detailed forecast tables, economy, table 1.2, column O, fiscal years)
28+
href: https://obr.uk/efo/economic-and-fiscal-outlook-march-2025/

policyengine_uk/variables/gov/dwp/afcs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ class afcs(Variable):
77
label = "Armed Forces Compensation Scheme"
88
definition_period = YEAR
99
unit = GBP
10-
uprating = "gov.obr.consumer_price_index"
1110

1211
adds = ["afcs_reported"]

policyengine_uk/variables/gov/gov_spending.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class gov_spending(Variable):
2727
"dla",
2828
"iidb",
2929
"incapacity_benefit",
30-
"jsa_contrib",
3130
"pip",
3231
"sda",
3332
"state_pension",

policyengine_uk/variables/input/dividend_income.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class dividend_income(Variable):
1010
reference = "Income Tax (Trading and Other Income) Act 2005 s. 365(1)(b-d)"
1111
unit = GBP
1212
quantity_type = FLOW
13-
uprating = "gov.obr.per_capita.non_labour_income"
13+
uprating = "gov.obr.per_capita.gdp"

policyengine_uk/variables/input/lump_sum_income.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ class lump_sum_income(Variable):
88
documentation = "Income from lump sums"
99
definition_period = YEAR
1010
unit = GBP
11-
uprating = "gov.obr.per_capita.non_labour_income"
11+
uprating = "gov.obr.per_capita.gdp"

policyengine_uk/variables/input/maintenance_income.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ class maintenance_income(Variable):
88
documentation = "Income from maintenance payments to you"
99
definition_period = YEAR
1010
unit = GBP
11-
uprating = "gov.obr.per_capita.non_labour_income"
11+
uprating = "gov.obr.per_capita.gdp"

0 commit comments

Comments
 (0)