policyengine-uk 2.53.1__py3-none-any.whl → 2.54.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of policyengine-uk might be problematic. Click here for more details.
- policyengine_uk/data/__init__.py +1 -0
- policyengine_uk/data/filter_dataset.py +52 -0
- policyengine_uk/dynamics/labour_supply.py +9 -15
- policyengine_uk/dynamics/progression.py +5 -5
- policyengine_uk/scenarios/uc_reform.py +3 -1
- policyengine_uk/simulation.py +2 -2
- policyengine_uk/tests/microsimulation/reforms_config.yaml +7 -7
- {policyengine_uk-2.53.1.dist-info → policyengine_uk-2.54.1.dist-info}/METADATA +1 -1
- {policyengine_uk-2.53.1.dist-info → policyengine_uk-2.54.1.dist-info}/RECORD +11 -10
- {policyengine_uk-2.53.1.dist-info → policyengine_uk-2.54.1.dist-info}/WHEEL +0 -0
- {policyengine_uk-2.53.1.dist-info → policyengine_uk-2.54.1.dist-info}/licenses/LICENSE +0 -0
policyengine_uk/data/__init__.py
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
if typing.TYPE_CHECKING:
|
|
4
|
+
from policyengine_uk import Microsimulation
|
|
5
|
+
from policyengine_uk.data import UKSingleYearDataset
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def filter_dataset(
|
|
9
|
+
sim: "Microsimulation", household_id: int, year: int = 2026
|
|
10
|
+
) -> "UKSingleYearDataset":
|
|
11
|
+
from policyengine_uk import Microsimulation
|
|
12
|
+
from policyengine_uk.data import UKSingleYearDataset
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
Extract a single household from a simulation dataset.
|
|
16
|
+
|
|
17
|
+
This function creates a new dataset containing only the specified household
|
|
18
|
+
and the associated benefit units and people within that household.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
sim : Microsimulation
|
|
23
|
+
The microsimulation object containing the dataset.
|
|
24
|
+
household_id : int
|
|
25
|
+
The ID of the household to extract.
|
|
26
|
+
year : int, default 2026
|
|
27
|
+
The dataset year to filter.
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
UKSingleYearDataset
|
|
32
|
+
A new dataset containing only data for the specified household.
|
|
33
|
+
"""
|
|
34
|
+
dataset: UKSingleYearDataset = sim.dataset[year]
|
|
35
|
+
new_dataset = dataset.copy()
|
|
36
|
+
new_dataset.person = new_dataset.person[
|
|
37
|
+
new_dataset.person.person_household_id == household_id
|
|
38
|
+
]
|
|
39
|
+
new_dataset.household = new_dataset.household[
|
|
40
|
+
new_dataset.household.household_id == household_id
|
|
41
|
+
]
|
|
42
|
+
benunits = new_dataset.person.person_benunit_id.unique()
|
|
43
|
+
new_dataset.benunit = new_dataset.benunit[
|
|
44
|
+
new_dataset.benunit.benunit_id.isin(benunits)
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
return UKSingleYearDataset(
|
|
48
|
+
person=new_dataset.person,
|
|
49
|
+
household=new_dataset.household,
|
|
50
|
+
benunit=new_dataset.benunit,
|
|
51
|
+
fiscal_year=year,
|
|
52
|
+
)
|
|
@@ -28,7 +28,7 @@ from .participation import (
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
def calculate_excluded_from_labour_supply_responses(
|
|
31
|
-
sim: Simulation, count_adults: int =
|
|
31
|
+
sim: Simulation, count_adults: int = 2
|
|
32
32
|
):
|
|
33
33
|
"""Calculate which individuals are excluded from labour supply responses.
|
|
34
34
|
|
|
@@ -97,10 +97,10 @@ class LabourSupplyResponseData(BaseModel):
|
|
|
97
97
|
|
|
98
98
|
def apply_labour_supply_responses(
|
|
99
99
|
sim: Simulation,
|
|
100
|
-
target_variable: str = "
|
|
100
|
+
target_variable: str = "hbai_household_net_income",
|
|
101
101
|
input_variable: str = "employment_income",
|
|
102
102
|
year: int = 2025,
|
|
103
|
-
count_adults: int =
|
|
103
|
+
count_adults: int = 2,
|
|
104
104
|
delta: float = 1_000,
|
|
105
105
|
) -> pd.DataFrame:
|
|
106
106
|
"""Apply labour supply responses to simulation and return the response vector.
|
|
@@ -197,10 +197,10 @@ def apply_labour_supply_responses(
|
|
|
197
197
|
|
|
198
198
|
def apply_progression_responses(
|
|
199
199
|
sim: Simulation,
|
|
200
|
-
target_variable: str = "
|
|
200
|
+
target_variable: str = "hbai_household_net_income",
|
|
201
201
|
input_variable: str = "employment_income",
|
|
202
202
|
year: int = 2025,
|
|
203
|
-
count_adults: int =
|
|
203
|
+
count_adults: int = 2,
|
|
204
204
|
delta: float = 1_000,
|
|
205
205
|
pre_calculated_income_rel_change: np.ndarray = None,
|
|
206
206
|
) -> pd.DataFrame:
|
|
@@ -233,6 +233,7 @@ def apply_progression_responses(
|
|
|
233
233
|
derivative_changes = derivative_changes.rename(
|
|
234
234
|
columns={col: f"deriv_{col}" for col in derivative_changes.columns}
|
|
235
235
|
)
|
|
236
|
+
derivative_changes["person_id"] = sim.calculate("person_id", year).values
|
|
236
237
|
|
|
237
238
|
# Add in actual implied wages
|
|
238
239
|
gross_wage = sim.calculate("employment_income", year) / sim.calculate(
|
|
@@ -262,20 +263,13 @@ def apply_progression_responses(
|
|
|
262
263
|
|
|
263
264
|
# Calculate changes in income levels (drives income effects)
|
|
264
265
|
if pre_calculated_income_rel_change is not None:
|
|
265
|
-
# Use pre-calculated values
|
|
266
266
|
n_people = len(sim.calculate("person_id", year))
|
|
267
267
|
income_changes = pd.DataFrame(
|
|
268
268
|
{
|
|
269
|
-
"baseline": np.zeros(
|
|
270
|
-
|
|
271
|
-
), # Not needed for behavioral response
|
|
272
|
-
"scenario": np.zeros(
|
|
273
|
-
n_people
|
|
274
|
-
), # Not needed for behavioral response
|
|
269
|
+
"baseline": np.zeros(n_people),
|
|
270
|
+
"scenario": np.zeros(n_people),
|
|
275
271
|
"rel_change": pre_calculated_income_rel_change,
|
|
276
|
-
"abs_change": np.zeros(
|
|
277
|
-
n_people
|
|
278
|
-
), # Not needed for behavioral response
|
|
272
|
+
"abs_change": np.zeros(n_people),
|
|
279
273
|
}
|
|
280
274
|
)
|
|
281
275
|
else:
|
|
@@ -14,7 +14,7 @@ from policyengine_uk import Simulation
|
|
|
14
14
|
|
|
15
15
|
def calculate_derivative(
|
|
16
16
|
sim: Simulation,
|
|
17
|
-
target_variable: str = "
|
|
17
|
+
target_variable: str = "hbai_household_net_income",
|
|
18
18
|
input_variable: str = "employment_income",
|
|
19
19
|
year: int = 2025,
|
|
20
20
|
count_adults: int = 2,
|
|
@@ -72,12 +72,12 @@ def calculate_derivative(
|
|
|
72
72
|
sim.set_input(input_variable, year, input_variable_values)
|
|
73
73
|
|
|
74
74
|
# Clip to ensure rates are between 0 and 1 (0% to 100% retention)
|
|
75
|
-
return rel_marginal_wages.
|
|
75
|
+
return rel_marginal_wages.round(4)
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
def calculate_relative_income_change(
|
|
79
79
|
sim: Simulation,
|
|
80
|
-
target_variable: str = "
|
|
80
|
+
target_variable: str = "hbai_household_net_income",
|
|
81
81
|
year: int = 2025,
|
|
82
82
|
) -> pd.DataFrame:
|
|
83
83
|
"""Calculate relative change in income between baseline and scenario.
|
|
@@ -125,10 +125,10 @@ def calculate_relative_income_change(
|
|
|
125
125
|
|
|
126
126
|
def calculate_derivative_change(
|
|
127
127
|
sim: Simulation,
|
|
128
|
-
target_variable: str = "
|
|
128
|
+
target_variable: str = "hbai_household_net_income",
|
|
129
129
|
input_variable: str = "employment_income",
|
|
130
130
|
year: int = 2025,
|
|
131
|
-
count_adults: int =
|
|
131
|
+
count_adults: int = 2,
|
|
132
132
|
delta: float = 1_000,
|
|
133
133
|
) -> pd.DataFrame:
|
|
134
134
|
"""Calculate change in marginal rates between baseline and scenario.
|
|
@@ -8,7 +8,9 @@ def add_universal_credit_reform(sim: Microsimulation):
|
|
|
8
8
|
sim.tax_benefit_system.parameters.gov.dwp.universal_credit.rebalancing
|
|
9
9
|
)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
generator = np.random.default_rng(43)
|
|
12
|
+
|
|
13
|
+
uc_seed = generator.random(len(sim.calculate("benunit_id")))
|
|
12
14
|
p_uc_post_2026_status = {
|
|
13
15
|
2025: 0,
|
|
14
16
|
2026: 0.11,
|
policyengine_uk/simulation.py
CHANGED
|
@@ -104,8 +104,6 @@ class Simulation(CoreSimulation):
|
|
|
104
104
|
else:
|
|
105
105
|
raise ValueError(f"Unsupported dataset type: {dataset.__class__}")
|
|
106
106
|
|
|
107
|
-
self.input_variables = self.get_known_variables()
|
|
108
|
-
|
|
109
107
|
# Universal Credit reform (July 2025). Needs closer integration in the baseline,
|
|
110
108
|
# but adding here for ease of toggling on/off via the 'active' parameter.
|
|
111
109
|
from policyengine_uk.scenarios import universal_credit_july_2025_reform
|
|
@@ -119,6 +117,8 @@ class Simulation(CoreSimulation):
|
|
|
119
117
|
self.move_values("capital_gains", "capital_gains_before_response")
|
|
120
118
|
self.move_values("employment_income", "employment_income_before_lsr")
|
|
121
119
|
|
|
120
|
+
self.input_variables = self.get_known_variables()
|
|
121
|
+
|
|
122
122
|
if scenario is not None:
|
|
123
123
|
self.baseline = Simulation(
|
|
124
124
|
scenario=None,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
reforms:
|
|
2
2
|
- name: Raise basic rate by 1pp
|
|
3
|
-
expected_impact: 8.
|
|
3
|
+
expected_impact: 8.1
|
|
4
4
|
parameters:
|
|
5
5
|
gov.hmrc.income_tax.rates.uk[0].rate: 0.21
|
|
6
6
|
- name: Raise higher rate by 1pp
|
|
7
|
-
expected_impact:
|
|
7
|
+
expected_impact: 4.9
|
|
8
8
|
parameters:
|
|
9
9
|
gov.hmrc.income_tax.rates.uk[1].rate: 0.42
|
|
10
10
|
- name: Raise personal allowance by ~800GBP/year
|
|
@@ -12,22 +12,22 @@ reforms:
|
|
|
12
12
|
parameters:
|
|
13
13
|
gov.hmrc.income_tax.allowances.personal_allowance.amount: 13000
|
|
14
14
|
- name: Raise child benefit by 25GBP/week per additional child
|
|
15
|
-
expected_impact: -1.
|
|
15
|
+
expected_impact: -1.3
|
|
16
16
|
parameters:
|
|
17
17
|
gov.hmrc.child_benefit.amount.additional: 25
|
|
18
18
|
- name: Reduce Universal Credit taper rate to 20%
|
|
19
|
-
expected_impact: -36.
|
|
19
|
+
expected_impact: -36.0
|
|
20
20
|
parameters:
|
|
21
21
|
gov.dwp.universal_credit.means_test.reduction_rate: 0.2
|
|
22
22
|
- name: Raise Class 1 main employee NICs rate to 10%
|
|
23
|
-
expected_impact: 12.
|
|
23
|
+
expected_impact: 12.5
|
|
24
24
|
parameters:
|
|
25
25
|
gov.hmrc.national_insurance.class_1.rates.employee.main: 0.1
|
|
26
26
|
- name: Raise VAT standard rate by 2pp
|
|
27
|
-
expected_impact:
|
|
27
|
+
expected_impact: 19.1
|
|
28
28
|
parameters:
|
|
29
29
|
gov.hmrc.vat.standard_rate: 0.22
|
|
30
30
|
- name: Raise additional rate by 3pp
|
|
31
|
-
expected_impact: 5
|
|
31
|
+
expected_impact: 4.5
|
|
32
32
|
parameters:
|
|
33
33
|
gov.hmrc.income_tax.rates.uk[2].rate: 0.48
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: policyengine-uk
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.54.1
|
|
4
4
|
Summary: PolicyEngine tax and benefit system for the UK.
|
|
5
5
|
Project-URL: Homepage, https://github.com/PolicyEngine/policyengine-uk
|
|
6
6
|
Project-URL: Repository, https://github.com/PolicyEngine/policyengine-uk
|
|
@@ -3,16 +3,17 @@ policyengine_uk/entities.py,sha256=9yUbkUWQr3WydNE-gHhUudG97HGyXIZY3dkgQ6Z3t9A,1
|
|
|
3
3
|
policyengine_uk/microsimulation.py,sha256=WskrrDrLGfDYwS1CzFk5rJkQSQlTknLkxFufStKRpxc,3379
|
|
4
4
|
policyengine_uk/model_api.py,sha256=KdwJCL2HkXVxDpL6fCsCnQ9Sub6Kqp7Hyxlis3MNIx4,241
|
|
5
5
|
policyengine_uk/modelled_policies.yaml,sha256=TLhvmkuI9ip-Fjq63n66RzDErCkN8K4BzY6XLxLMtFg,463
|
|
6
|
-
policyengine_uk/simulation.py,sha256=
|
|
6
|
+
policyengine_uk/simulation.py,sha256=YR8mxP6D5wSQGdCo2nLO0Jq6isNv5U83ddusVMnoOZk,21265
|
|
7
7
|
policyengine_uk/system.py,sha256=Z-ax_ImUq5k4tycuThczTxQNW5iTE6ikBJIBQdKfIzU,91
|
|
8
8
|
policyengine_uk/tax_benefit_system.py,sha256=CjX1lERyOm_vlgHQcQO92HZtJiwItLH-MxJveJqk6iM,5165
|
|
9
|
-
policyengine_uk/data/__init__.py,sha256=
|
|
9
|
+
policyengine_uk/data/__init__.py,sha256=fF3Qhm01PCx26pbG_WRKddacNzbgbuEoayV_xMETDgc,144
|
|
10
10
|
policyengine_uk/data/dataset_schema.py,sha256=781beGVnPWJhw2FzcG6he-LtmgxtwS1h6keAz7TPoXI,10036
|
|
11
11
|
policyengine_uk/data/economic_assumptions.py,sha256=U3wyBs4zVI5-bcMB-GivELC1qG-895l5NPds3cuWb90,6239
|
|
12
|
+
policyengine_uk/data/filter_dataset.py,sha256=DtIixUMRnY-g-acXZIxaZ5217NYYVAMxVgs1Wa3rya0,1622
|
|
12
13
|
policyengine_uk/data/uprating_indices.yaml,sha256=kQtfeGWyqge4dbJhs0iF4kTMqovuegill_Zfs8orJi4,2394
|
|
13
|
-
policyengine_uk/dynamics/labour_supply.py,sha256=
|
|
14
|
+
policyengine_uk/dynamics/labour_supply.py,sha256=MQnlp2OfD2RboqBOxKoLHzVKfZjP04j6Oif1Jswp1-w,12074
|
|
14
15
|
policyengine_uk/dynamics/participation.py,sha256=g5xUqg-Nj2lQny9GrUfI2D_swLx0-9k-486NXtcWwbM,23238
|
|
15
|
-
policyengine_uk/dynamics/progression.py,sha256=
|
|
16
|
+
policyengine_uk/dynamics/progression.py,sha256=Mym2IxkcL20gKPZXk0JmT6quo0A9XU5_SbpShpa_PxE,14080
|
|
16
17
|
policyengine_uk/parameters/gov/README.md,sha256=bHUep1_2pLHD3Or8SwjStOWXDIbW9OuYxOd4ml8IXcM,13
|
|
17
18
|
policyengine_uk/parameters/gov/benefit_uprating_cpi.yaml,sha256=2zOSdJeUhDZYYsKE2vLkcK-UbKNoOSVwfac0QIAp02g,250
|
|
18
19
|
policyengine_uk/parameters/gov/contrib/README.md,sha256=b282dmUFAmj7cXSfiMLyE81q5Y0Gnehy-6atLus-ESs,70
|
|
@@ -539,13 +540,13 @@ policyengine_uk/scenarios/__init__.py,sha256=OP_05x7RS8qUuwEN6tqoTGwrpk8vYLxCSav
|
|
|
539
540
|
policyengine_uk/scenarios/pip_reform.py,sha256=fv6-HCuRxhzt-XEYv9yLJTEliAWu3EGx6duADSBO4n8,687
|
|
540
541
|
policyengine_uk/scenarios/reindex_benefit_cap.py,sha256=dPUOsTkgYZNRN15e_ax5hg5ObHngk5tizz7FYStkGaE,1070
|
|
541
542
|
policyengine_uk/scenarios/repeal_two_child_limit.py,sha256=vZndQVFNCe7v7k4v-PgneOCPld-YTnCmlveRbX_1czk,250
|
|
542
|
-
policyengine_uk/scenarios/uc_reform.py,sha256=
|
|
543
|
+
policyengine_uk/scenarios/uc_reform.py,sha256=xfgNRVR5S_UMKmd3Zivrc717DvJX4hVqf2gTUlocGQA,1883
|
|
543
544
|
policyengine_uk/tests/test_behavioral_responses.py,sha256=xuKOyuki6nLMrS-XArRqs8nU-o538eyMG2eAB1WDHHY,8191
|
|
544
545
|
policyengine_uk/tests/test_parameter_metadata.py,sha256=_2w2dSokAf5Jskye_KIL8eh80N7yIrUszlmqnZtwQws,450
|
|
545
546
|
policyengine_uk/tests/behavioral_responses/test_labor_supply_responses.yaml,sha256=xR8cy0XjcG8xTL_ufgEl1BHNWhXefVnA2va7X3v6FBk,5783
|
|
546
547
|
policyengine_uk/tests/code_health/test_variables.py,sha256=9Y-KpmzhyRGy9eEqocK9z91NXHX5QIF3mDMNGvegb7Q,1398
|
|
547
548
|
policyengine_uk/tests/microsimulation/README.md,sha256=1toB1Z06ynlUielTrsAaeo9Vb-c3ZrB3tbbR4E1xUGk,3924
|
|
548
|
-
policyengine_uk/tests/microsimulation/reforms_config.yaml,sha256
|
|
549
|
+
policyengine_uk/tests/microsimulation/reforms_config.yaml,sha256=-XQjsQfb3GGs-qwdAP7OVT_OG2g3zHyDbHcw82p5UX8,1086
|
|
549
550
|
policyengine_uk/tests/microsimulation/test_reform_impacts.py,sha256=xM3M2pclEhA9JIFpnuiPMy1fEBFOKcSzroRPk73FPls,2635
|
|
550
551
|
policyengine_uk/tests/microsimulation/test_validity.py,sha256=_mHgrNu-hKzVd9V2GSg_yPQgJctxRzdQM7lM2bUvqNY,636
|
|
551
552
|
policyengine_uk/tests/microsimulation/update_reform_impacts.py,sha256=4m5EpPu4SXTE3qOPkx3eIZnlaOzprfm6GmMCXETZuLk,6890
|
|
@@ -1390,7 +1391,7 @@ policyengine_uk/variables/misc/spi_imputed.py,sha256=iPVlBF_TisM0rtKvO-3-PQ2UYCe
|
|
|
1390
1391
|
policyengine_uk/variables/misc/uc_migrated.py,sha256=zFNcUJaO8gwmbL1iY9GKgUt3G6J9yrCraqBV_5dCvlM,306
|
|
1391
1392
|
policyengine_uk/variables/misc/categories/lower_middle_or_higher.py,sha256=C54tHYz2DmOyvQYCC1bF8RJwRZinhAq_e3aYC-9F5fM,157
|
|
1392
1393
|
policyengine_uk/variables/misc/categories/lower_or_higher.py,sha256=81NIbLLabRr9NwjpUZDuV8IV8_mqmp5NM-CZvt55TwE,129
|
|
1393
|
-
policyengine_uk-2.
|
|
1394
|
-
policyengine_uk-2.
|
|
1395
|
-
policyengine_uk-2.
|
|
1396
|
-
policyengine_uk-2.
|
|
1394
|
+
policyengine_uk-2.54.1.dist-info/METADATA,sha256=1kOpL7EC6aBugy0R27XQ2QpqSzowUF_40vBNSp-sh3c,3995
|
|
1395
|
+
policyengine_uk-2.54.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
1396
|
+
policyengine_uk-2.54.1.dist-info/licenses/LICENSE,sha256=dql8h4yceoMhuzlcK0TT_i-NgTFNIZsgE47Q4t3dUYI,34520
|
|
1397
|
+
policyengine_uk-2.54.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|