Skip to content

Commit 9d0f948

Browse files
authored
Fix fuel duty rates to use OBR November 2025 RPI forecasts (#1442)
* Fix fuel duty rates to use OBR November 2025 RPI forecasts * tests * debug * edit
1 parent afea237 commit 9d0f948

7 files changed

Lines changed: 579 additions & 168 deletions

File tree

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: patch
2+
changes:
3+
fixed:
4+
- Fix fuel duty rates to use OBR November 2025 RPI forecasts.

docs/book/index.ipynb

Lines changed: 0 additions & 149 deletions
This file was deleted.

docs/book/index.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# PolicyEngine-UK
2+
3+
This book contains an introduction to using PolicyEngine-UK to model UK taxes and benefits. It is currently a work in progress and may be added to. PolicyEngine-UK is a microsimulation model of the UK tax and benefit system: it is a model which calculates variable values over UK entities from given policy parameters and structures. In practice, this gives it two main uses: calculating statistics under current tax and benefit law, and simulating effects of potential new changes to the legislation.
4+
5+
We're grateful to the [UKMOD](https://www.iser.essex.ac.uk/research/projects/ukmod) team for publishing descriptions of their model; our ability to reference these descriptions accelerated OpenFisca UK's development. UKMOD is maintained, developed and managed by the Centre for Microsimulation and Policy Analysis at the Institute for Social and Economic Research (ISER), University of Essex.
6+
7+
Code examples and outputs are re-run automatically on each new version of PolicyEngine-UK.
8+
9+
## Short demo
10+
11+
### Baseline estimates
12+
13+
Calculating, for example, the total Income Tax liability by region can be done with the following code:
14+
15+
```python
16+
from policyengine_uk import Microsimulation
17+
import pandas as pd
18+
19+
ENHANCED_FRS = "hf://policyengine/policyengine-uk-data/enhanced_frs_2022_23.h5"
20+
21+
sim = Microsimulation(dataset=ENHANCED_FRS)
22+
23+
df = sim.calculate_dataframe(
24+
[
25+
"household_id", # If the first variable is household level, the dataframe will project everything to households. Same for people.
26+
"income_tax",
27+
"region",
28+
],
29+
period=2025,
30+
)
31+
32+
df.groupby("region").income_tax.sum().sort_values(
33+
ascending=False
34+
) / 1e9 # Weights automatically applied
35+
```
36+
37+
### Reform evaluation
38+
39+
Below is an example of simulating the effects of a reform (namely, increasing the basic rate of income tax from 20% to 23%).
40+
41+
```python
42+
from policyengine_uk.model_api import *
43+
44+
45+
def change_tax_parameters(parameters):
46+
parameters.gov.hmrc.income_tax.rates.uk.brackets[0].rate.update(
47+
period=periods.period("year:2019:10"), value=0.23
48+
)
49+
return parameters
50+
51+
52+
class reform(Reform):
53+
def apply(self):
54+
self.modify_parameters(change_tax_parameters)
55+
56+
57+
baseline = Microsimulation(dataset=ENHANCED_FRS)
58+
reformed = Microsimulation(dataset=ENHANCED_FRS, reform=reform)
59+
revenue = (
60+
reformed.calculate("gov_balance", 2025).sum()
61+
- baseline.calc("gov_balance", 2025).sum()
62+
)
63+
f"Revenue: £{round(revenue / 1e9, 1)}bn"
64+
```

myst.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ project:
1010
branch: master
1111
path: docs/book
1212
toc:
13-
- file: docs/book/index
13+
- file: docs/book/index.md
1414
- title: Usage
1515
children:
1616
- file: docs/book/usage/getting-started

0 commit comments

Comments
 (0)