Skip to content

Commit

Permalink
Merge pull request PolicyEngine#186 from nikhilwoodruff/master
Browse files Browse the repository at this point in the history
Add year information and update table.
  • Loading branch information
MaxGhenis authored Aug 30, 2021
2 parents 35ece34 + d8937d3 commit a522dd9
Showing 1 changed file with 20 additions and 206 deletions.
226 changes: 20 additions & 206 deletions docs/book/validation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,214 +2,29 @@
"cells": [
{
"cell_type": "markdown",
"id": "fd66e88a-ad4c-4c02-bbe1-4bf8466e3877",
"metadata": {},
"source": [
"# Validation\n",
"\n",
"OpenFisca-UK runs unit and integration tests on each new version (see [here](https://github.com/PSLmodels/openfisca-uk/tree/master/tests)). In addition, the table below shows the aggregates produced by the model for the major taxes and benefits, and comparisons with UKMOD (latest [country report](https://www.iser.essex.ac.uk/research/publications/working-papers/cempa/cempa7-20.pdf)) and official sources[^1].\n",
"OpenFisca-UK runs unit and integration tests on each new version (see [here](https://github.com/PSLmodels/openfisca-uk/tree/master/tests)). In addition, the table below shows the aggregates produced by the model for the major taxes and benefits, and comparisons with UKMOD (latest [country report](https://www.iser.essex.ac.uk/research/publications/working-papers/cempa/cempa7-20.pdf)) and official sources[^1]. UKMOD and administrative sources refer to 2018, and OpenFisca-UK is simulated on policy at the end of 2018.\n",
"\n",
"[^1]: From the UKMOD country report: unless otherwise specified: Department for Work and Pensions https://www.gov.uk/government/publications/benefit-expenditure-and-caseload-tables-2018 ; Best Start Grant: https://www2.gov.scot/Topics/Statistics/Browse/Social-Welfare/SocialSecurityforScotland/BSGJune2019; Child tax credit and working tax credit: HMRC statistics \n",
"https://www.gov.uk/government/statistics/child-and-working-tax-credits-statistics-finalised-annual-awards-2016-to-2017; Scottish Child Payment: Scottish Fiscal Commission https://www.fiscalcommission.scot/forecast/supplementary-costing-scottish-child-payment; Scottish Child Winter Heating Assistance: Scottish Fiscal Commission \n",
"https://www.fiscalcommission.scot/forecast/supplementary-costing-child-winter-heating-assistance; Income tax: HMRC statistics https://www.gov.uk/government/statistics/income-tax-liabilities-statistics-tax-year-2014-to-2015-to-tax-year-2017-to-2018; National Insurance Contributions: ONS Blue Book Table 5.2.4s \n"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 73,
"id": "30d4718e-6a2e-44ad-b217-933401b68f05",
"metadata": {
"tags": [
"hide-input"
]
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>OpenFisca-UK</th>\n",
" <th>UKMOD</th>\n",
" <th>External</th>\n",
" <th>OpenFisca-UK / UKMOD</th>\n",
" <th>OpenFisca-UK / External</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Variable</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Income Tax</th>\n",
" <td>171.3</td>\n",
" <td>163.7</td>\n",
" <td>190</td>\n",
" <td>1.05</td>\n",
" <td>0.9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Labour income, basic rate</th>\n",
" <td>95.9</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Labour income, higher rate</th>\n",
" <td>53.0</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Labour income, additional rate</th>\n",
" <td>9.0</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Non-employer National Insurance</th>\n",
" <td>61.0</td>\n",
" <td>64</td>\n",
" <td>55.7</td>\n",
" <td>0.95</td>\n",
" <td>1.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Employee Class 1 NI</th>\n",
" <td>56.5</td>\n",
" <td>55.7</td>\n",
" <td>52</td>\n",
" <td>1.01</td>\n",
" <td>1.09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Employer Class 1 NI</th>\n",
" <td>62.3</td>\n",
" <td>77.8</td>\n",
" <td>79.2</td>\n",
" <td>0.8</td>\n",
" <td>0.79</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Class 2 &amp; 4 NI</th>\n",
" <td>4.0</td>\n",
" <td>5</td>\n",
" <td>3.7</td>\n",
" <td>0.8</td>\n",
" <td>1.08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Universal Credit</th>\n",
" <td>10.4</td>\n",
" <td>11.7</td>\n",
" <td>8.1</td>\n",
" <td>0.89</td>\n",
" <td>1.28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tax Credits</th>\n",
" <td>14.1</td>\n",
" <td>13.9</td>\n",
" <td>22.8</td>\n",
" <td>1.01</td>\n",
" <td>0.62</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Housing Benefit</th>\n",
" <td>25.0</td>\n",
" <td>15.1</td>\n",
" <td>20.7</td>\n",
" <td>1.66</td>\n",
" <td>1.21</td>\n",
" </tr>\n",
" <tr>\n",
" <th>State Pension</th>\n",
" <td>86.4</td>\n",
" <td>86.4</td>\n",
" <td>85.5</td>\n",
" <td>1</td>\n",
" <td>1.01</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" OpenFisca-UK UKMOD External \\\n",
"Variable \n",
"Income Tax 171.3 163.7 190 \n",
"Labour income, basic rate 95.9 \n",
"Labour income, higher rate 53.0 \n",
"Labour income, additional rate 9.0 \n",
"Non-employer National Insurance 61.0 64 55.7 \n",
"Employee Class 1 NI 56.5 55.7 52 \n",
"Employer Class 1 NI 62.3 77.8 79.2 \n",
"Class 2 & 4 NI 4.0 5 3.7 \n",
"Universal Credit 10.4 11.7 8.1 \n",
"Tax Credits 14.1 13.9 22.8 \n",
"Housing Benefit 25.0 15.1 20.7 \n",
"State Pension 86.4 86.4 85.5 \n",
"\n",
" OpenFisca-UK / UKMOD OpenFisca-UK / External \n",
"Variable \n",
"Income Tax 1.05 0.9 \n",
"Labour income, basic rate \n",
"Labour income, higher rate \n",
"Labour income, additional rate \n",
"Non-employer National Insurance 0.95 1.1 \n",
"Employee Class 1 NI 1.01 1.09 \n",
"Employer Class 1 NI 0.8 0.79 \n",
"Class 2 & 4 NI 0.8 1.08 \n",
"Universal Credit 0.89 1.28 \n",
"Tax Credits 1.01 0.62 \n",
"Housing Benefit 1.66 1.21 \n",
"State Pension 1 1.01 "
]
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 2,
"source": [
"from openfisca_uk import Microsimulation\n",
"from openfisca_data import FRS_SPI_Adjusted\n",
"from openfisca_uk_data import FRS_SPI_Adjusted\n",
"import pandas as pd\n",
"\n",
"sim = Microsimulation(dataset=FRS_SPI_Adjusted)\n",
"sim = Microsimulation()\n",
"\n",
"VARIABLES = (\n",
" \"income_tax\",\n",
" \"basic_rate_earned_income_tax\",\n",
" \"higher_rate_earned_income_tax\",\n",
" \"add_rate_earned_income_tax\",\n",
" \"national_insurance\",\n",
" \"employee_NI_class_1\",\n",
" \"employer_NI_class_1\",\n",
Expand All @@ -223,9 +38,6 @@
"df = pd.DataFrame({\"OpenFisca-UK\": sim.df(VARIABLES, map_to=\"household\", period=2019).sum().apply(lambda x: round(x / 1e+9, 1))})\n",
"df[\"Variable\"] = (\n",
" \"Income Tax\",\n",
" \"Labour income, basic rate\",\n",
" \"Labour income, higher rate\",\n",
" \"Labour income, additional rate\",\n",
" \"Non-employer National Insurance\",\n",
" \"Employee Class 1 NI\",\n",
" \"Employer Class 1 NI\",\n",
Expand All @@ -240,9 +52,6 @@
"\n",
"df[\"UKMOD\"] = (\n",
" 163.7,\n",
" _,\n",
" _,\n",
" _,\n",
" 64.0,\n",
" 55.7,\n",
" 77.8,\n",
Expand All @@ -255,9 +64,6 @@
"\n",
"df[\"External\"] = (\n",
" 190.0,\n",
" _,\n",
" _,\n",
" _,\n",
" 55.7,\n",
" 52.0,\n",
" 79.2,\n",
Expand All @@ -279,14 +85,19 @@
"df[\"OpenFisca-UK / External\"] = [safe_ratio(x, y) for x, y in zip(df[\"OpenFisca-UK\"], df[\"External\"])]\n",
"\n",
"df"
]
],
"outputs": [],
"metadata": {
"tags": [
"hide-input"
]
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
"name": "python3",
"display_name": "Python 3.8.8 64-bit ('base': conda)"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -298,9 +109,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
"version": "3.8.8"
},
"interpreter": {
"hash": "d8fe82497dc3af1dafdfcaf67c3f347e622d9ec55d37e96a4812404db83e4772"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}

0 comments on commit a522dd9

Please sign in to comment.