diff --git a/.github/workflows/versioning.yaml b/.github/workflows/versioning.yaml index 53709c4e..c4ccf09b 100644 --- a/.github/workflows/versioning.yaml +++ b/.github/workflows/versioning.yaml @@ -4,10 +4,11 @@ name: Versioning updates on: push: branches: - - main + - main paths: - - changelog_entry.yaml + - changelog_entry.yaml + - "!pyproject.toml" jobs: Versioning: diff --git a/Makefile b/Makefile index c1b795b7..49972175 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ all: build documentation: jb clean docs jb build docs + python docs/add_plotly_to_book.py docs/ install: pip install -e .[dev] diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29b..d1b35788 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + added: + - Chart generation for macro charts. diff --git a/docs/_toc.yml b/docs/_toc.yml index 6b3c3baa..e901296a 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -4,4 +4,9 @@ parts: - caption: Reference chapters: - file: reference/simulation + - file: reference/calculate_single_household + - file: reference/calculate_household_comparison + - file: reference/calculate_single_economy + - file: reference/calculate_economy_comparison + - file: reference/create_charts \ No newline at end of file diff --git a/docs/add_plotly_to_book.py b/docs/add_plotly_to_book.py new file mode 100644 index 00000000..822e77ab --- /dev/null +++ b/docs/add_plotly_to_book.py @@ -0,0 +1,27 @@ +import argparse +from pathlib import Path + +# This command-line tools enables Plotly charts to show in the HTML files for the Jupyter Book documentation. + +parser = argparse.ArgumentParser() +parser.add_argument("book_path", help="Path to the Jupyter Book.") + +args = parser.parse_args() + +# Find every HTML file in the Jupyter Book. Then, add a script tag to the start of the
tag in each file, with the contents: +# + +book_folder = Path(args.book_path) + +for html_file in book_folder.glob("**/*.html"): + with open(html_file, "r") as f: + html = f.read() + + # Add the script tag to the start of the tag. + html = html.replace( + "", + '', + ) + + with open(html_file, "w") as f: + f.write(html) diff --git a/docs/reference/calculate_economy_comparison.ipynb b/docs/reference/calculate_economy_comparison.ipynb new file mode 100644 index 00000000..2d6fcfd4 --- /dev/null +++ b/docs/reference/calculate_economy_comparison.ipynb @@ -0,0 +1,267 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compare outcomes for large population scenarios\n", + "\n", + "Use `Simulation.calculate_economy_comparison()` to use PolicyEngine's tax-benefit model to compare how taxes, benefits and other household properties change under a reform scenario. This notebook demonstrates how to use this function." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "EconomyComparison(headlines=Headlines(budgetary_impact=-20688882917.062927, poverty_impact=-0.009522052793635733, winner_share=0.8345739005338316), fiscal=FiscalComparison(baseline=FiscalSummary(tax_revenue=658911285719.5891, federal_tax=658911285719.5891, federal_balance=309089098855.4849, state_tax=0.0, government_spending=349822186864.1042, tax_benefit_programs={'income_tax': 333376287037.05945, 'national_insurance': 52985626776.773834, 'ni_employer': 126330649370.35953, 'vat': 211671832822.39133, 'council_tax': 49007055050.00724, 'fuel_duty': 26506672341.204205, 'tax_credits': -34929879.49872104, 'universal_credit': -73459549194.97665, 'child_benefit': -14311471487.935827, 'state_pension': -132795868621.44594, 'pension_credit': -6252358021.417119}, household_net_income=1566028514855.0789), reform=FiscalSummary(tax_revenue=637686731286.3723, federal_tax=637686731286.3723, federal_balance=288400215938.422, state_tax=0.0, government_spending=349286515347.9503, tax_benefit_programs={'income_tax': 312151564998.6612, 'national_insurance': 52985626776.773834, 'ni_employer': 126330649370.35953, 'vat': 211671832822.39133, 'council_tax': 49007055050.00724, 'fuel_duty': 26506672341.204205, 'tax_credits': -34929879.49872104, 'universal_credit': -73099552696.20555, 'child_benefit': -14311471487.935827, 'state_pension': -132795868621.44594, 'pension_credit': -6181432287.167828}, household_net_income=1586717263122.5647), change=FiscalSummary(tax_revenue=-21224554433.216797, federal_tax=-21224554433.216797, federal_balance=-20688882917.062927, state_tax=0.0, government_spending=-535671516.1538696, tax_benefit_programs={'income_tax': -21224722038.398254, 'national_insurance': 0.0, 'ni_employer': 0.0, 'vat': 0.0, 'council_tax': 0.0, 'fuel_duty': 0.0, 'tax_credits': 0.0, 'universal_credit': 359996498.7711029, 'child_benefit': 0.0, 'state_pension': 0.0, 'pension_credit': 70925734.24929142}, household_net_income=20688748267.48584), relative_change=FiscalSummary(tax_revenue=-0.03221155092227281, federal_tax=-0.03221155092227281, federal_balance=-0.06693501321680725, state_tax=0.0, government_spending=-0.0015312679877619157, tax_benefit_programs={'income_tax': -0.06366596204858095, 'national_insurance': 0.0, 'ni_employer': 0.0, 'vat': 0.0, 'council_tax': 0.0, 'fuel_duty': 0.0, 'tax_credits': -0.0, 'universal_credit': -0.004900608603186478, 'child_benefit': -0.0, 'state_pension': -0.0, 'pension_credit': -0.01134383763795021}, household_net_income=0.013210965235457662)), inequality=InequalityComparison(baseline=InequalitySummary(gini=0.36255397405553097, top_10_share=0.3260927004295773, top_1_share=0.13145609415091833), reform=InequalitySummary(gini=0.36210731670764496, top_10_share=0.32470725674255146, top_1_share=0.1300325825945402), change=InequalitySummary(gini=-0.00044665734788601474, top_10_share=-0.0013854436870258113, top_1_share=-0.0014235115563781264), relative_change=InequalitySummary(gini=-0.0012319747674800056, top_10_share=-0.004248619135603775, top_1_share=-0.010828798509286775)), distributional=DecileImpacts(income=IncomeMeasureSpecificDecileImpacts(income_change=IncomeMeasureSpecificDecileIncomeChange(relative={1: 0.006888474767108438, 2: 0.012069475259054711, 3: 0.01362845736941666, 4: 0.016099117695117186, 5: 0.01374886913709005, 6: 0.016868831714948112, 7: 0.01753355279609095, 8: 0.016653943875645758, 9: 0.016768055951517695, 10: 0.007412182918826308}, average={1: 104.9760740138715, 2: 345.3564489476293, 3: 505.97466813661975, 4: 693.4608276094718, 5: 633.0583755079966, 6: 916.7936598562601, 7: 1160.9595929383368, 8: 1339.97187253835, 9: 1645.9437072259466, 10: 1555.8434910392261}), winners_and_losers=IncomeMeasureSpecificDecileWinnersLosers(deciles={1: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.00016742770708814546, lose_share=0.00016742770708814546, no_change_share=0.7777537048412824, gain_share=0.22207886745162944, gain_less_than_5_percent_share=0.1144106783823729, gain_more_than_5_percent_share=0.10766818906925654), 2: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.008307581771885529, lose_share=0.008307581771885529, no_change_share=0.32972785891469386, gain_share=0.6619645593134206, gain_less_than_5_percent_share=0.5622028657847857, gain_more_than_5_percent_share=0.09976169352863486), 3: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=7.96157411760938e-05, lose_share=7.96157411760938e-05, no_change_share=0.24138511806270913, gain_share=0.7585352661961148, gain_less_than_5_percent_share=0.5985049210228661, gain_more_than_5_percent_share=0.16003034517324866), 4: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.1274989463786316, gain_share=0.8725010536213684, gain_less_than_5_percent_share=0.8390939448490379, gain_more_than_5_percent_share=0.033407108772330475), 5: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.039569164250678565, gain_share=0.9604308357493214, gain_less_than_5_percent_share=0.9576740433060911, gain_more_than_5_percent_share=0.002756792443230341), 6: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.047391872522306096, gain_share=0.9526081274776939, gain_less_than_5_percent_share=0.9027059122375464, gain_more_than_5_percent_share=0.049902215240147485), 7: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=5.104037721866914e-07, lose_share=5.104037721866914e-07, no_change_share=0.018556113733354175, gain_share=0.9814433758628737, gain_less_than_5_percent_share=0.9347186693787157, gain_more_than_5_percent_share=0.046724706484157955), 8: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.0078485273494483, gain_share=0.9921514726505517, gain_less_than_5_percent_share=0.9786379299391095, gain_more_than_5_percent_share=0.013513542711442263), 9: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.015484773300234851, gain_share=0.9845152266997651, gain_less_than_5_percent_share=0.9787986406237482, gain_more_than_5_percent_share=0.00571658607601697), 10: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.09527409658848911, gain_share=0.9047259034115109, gain_less_than_5_percent_share=0.9047259034115109, gain_more_than_5_percent_share=0.0)}, all=IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0008383266758003545, lose_share=0.0008383266758003545, no_change_share=0.16458777279036807, gain_share=0.8345739005338316, gain_less_than_5_percent_share=0.7829682328930914, gain_more_than_5_percent_share=0.051605667640740344))), wealth=IncomeMeasureSpecificDecileImpacts(income_change=IncomeMeasureSpecificDecileIncomeChange(relative={1: 0.008709379861137914, 2: 0.009055801198624003, 3: 0.012492298883059996, 4: 0.011526120801509328, 5: 0.013211703237973082, 6: 0.015499285448067033, 7: 0.01507564337455649, 8: 0.013872555873086258, 9: 0.01486308861202786, 10: 0.013423195198765777}, average={1: 369.7032427197275, 2: 348.23782779938443, 3: 552.8656647582718, 4: 568.6862981673706, 5: 788.7199254212952, 6: 1082.0251273410129, 7: 995.5414649462065, 8: 980.0266932010006, 9: 1104.9136440223838, 10: 1148.3564916388677}), winners_and_losers=IncomeMeasureSpecificDecileWinnersLosers(deciles={1: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=2.6088522714454665e-05, lose_share=2.6088522714454665e-05, no_change_share=0.4508804429091072, gain_share=0.5490934685681783, gain_less_than_5_percent_share=0.5339710702731965, gain_more_than_5_percent_share=0.015122398294981835), 2: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.494450094962446, gain_share=0.505549905037554, gain_less_than_5_percent_share=0.4987036905338977, gain_more_than_5_percent_share=0.006846214503656335), 3: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.02404055636315165, gain_share=0.9759594436368484, gain_less_than_5_percent_share=0.9651062221540542, gain_more_than_5_percent_share=0.010853221482794195), 4: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=8.272884193213454e-07, lose_share=8.272884193213454e-07, no_change_share=0.36369619644130957, gain_share=0.6363029762702711, gain_less_than_5_percent_share=0.5981897126055431, gain_more_than_5_percent_share=0.038113263664727975), 5: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.00024460254119754784, lose_share=0.00024460254119754784, no_change_share=0.16613074345434808, gain_share=0.8336246540044544, gain_less_than_5_percent_share=0.8172183492970724, gain_more_than_5_percent_share=0.01640630470738194), 6: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.025790631489697343, gain_share=0.9742093685103027, gain_less_than_5_percent_share=0.9603855562910443, gain_more_than_5_percent_share=0.013823812219258384), 7: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=4.163438722119544e-05, lose_share=4.163438722119544e-05, no_change_share=0.08407934672412146, gain_share=0.9158790188886573, gain_less_than_5_percent_share=0.8182000678180964, gain_more_than_5_percent_share=0.09767895107056095), 8: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.056524409525954916, gain_share=0.9434755904740451, gain_less_than_5_percent_share=0.880163733821962, gain_more_than_5_percent_share=0.06331185665208312), 9: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.008053685714292545, lose_share=0.008053685714292545, no_change_share=0.027806404912023186, gain_share=0.9641399093736843, gain_less_than_5_percent_share=0.9093577338323074, gain_more_than_5_percent_share=0.05478217554137677), 10: IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0, lose_share=0.0, no_change_share=0.06985295508301145, gain_share=0.9301470449169885, gain_less_than_5_percent_share=0.7369159251943521, gain_more_than_5_percent_share=0.1932311197226364)}, all=IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes(lose_more_than_5_percent_share=0.0, lose_less_than_5_percent_share=0.0008383266758003545, lose_share=0.0008383266758003545, no_change_share=0.16458777279036807, gain_share=0.8345739005338316, gain_less_than_5_percent_share=0.7829682328930914, gain_more_than_5_percent_share=0.051605667640740344)))), poverty=[PovertyRateMetricComparison(age_group='child', gender='male', racial_group='all', relative=True, poverty_rate='regular', baseline=0.0937829241156578, reform=0.09370723366737366, change=-7.569044828414917e-05, relative_change=-0.000807081342343345), PovertyRateMetricComparison(age_group='child', gender='male', racial_group='all', relative=True, poverty_rate='deep', baseline=0.006947669200599194, reform=0.0069471439346671104, change=-5.252659320831299e-07, relative_change=-7.560318675475064e-05), PovertyRateMetricComparison(age_group='child', gender='male', racial_group='all', relative=False, poverty_rate='regular', baseline=770371.125, reform=769749.375, change=-621.75, relative_change=-0.000807078536335328), PovertyRateMetricComparison(age_group='child', gender='male', racial_group='all', relative=False, poverty_rate='deep', baseline=57070.984375, reform=57066.66796875, change=-4.31640625, relative_change=-7.5632237594465e-05), PovertyRateMetricComparison(age_group='child', gender='female', racial_group='all', relative=True, poverty_rate='regular', baseline=0.08119998127222061, reform=0.0811329185962677, change=-6.706267595291138e-05, relative_change=-0.0008258952145331866), PovertyRateMetricComparison(age_group='child', gender='female', racial_group='all', relative=True, poverty_rate='deep', baseline=0.005070670507848263, reform=0.00507007073611021, change=-5.997717380523682e-07, relative_change=-0.00011828253031311259), PovertyRateMetricComparison(age_group='child', gender='female', racial_group='all', relative=False, poverty_rate='regular', baseline=866217.375, reform=865501.9375, change=-715.4375, relative_change=-0.0008259329824687481), PovertyRateMetricComparison(age_group='child', gender='female', racial_group='all', relative=False, poverty_rate='deep', baseline=54092.4140625, reform=54086.015625, change=-6.3984375, relative_change=-0.00011828715007259712), PovertyRateMetricComparison(age_group='child', gender='all', racial_group='all', relative=True, poverty_rate='regular', baseline=0.0866740345954895, reform=0.08660321682691574, change=-7.081776857376099e-05, relative_change=-0.0008170586370447596), PovertyRateMetricComparison(age_group='child', gender='all', racial_group='all', relative=True, poverty_rate='deep', baseline=0.005887233652174473, reform=0.005886665545403957, change=-5.681067705154419e-07, relative_change=-9.649808451302242e-05), PovertyRateMetricComparison(age_group='child', gender='all', racial_group='all', relative=False, poverty_rate='regular', baseline=1636588.5, reform=1635251.25, change=-1337.25, relative_change=-0.0008170960507176972), PovertyRateMetricComparison(age_group='child', gender='all', racial_group='all', relative=False, poverty_rate='deep', baseline=111163.3828125, reform=111152.65625, change=-10.7265625, relative_change=-9.649366750643566e-05), PovertyRateMetricComparison(age_group='working_age', gender='male', racial_group='all', relative=True, poverty_rate='regular', baseline=0.09058031439781189, reform=0.08946093916893005, change=-0.001119375228881836, relative_change=-0.012357820088432772), PovertyRateMetricComparison(age_group='working_age', gender='male', racial_group='all', relative=True, poverty_rate='deep', baseline=0.0320294052362442, reform=0.03202878311276436, change=-6.221234798431396e-07, relative_change=-1.9423510216766375e-05), PovertyRateMetricComparison(age_group='working_age', gender='male', racial_group='all', relative=False, poverty_rate='regular', baseline=2207394.25, reform=2180115.75, change=-27278.5, relative_change=-0.012357783390982377), PovertyRateMetricComparison(age_group='working_age', gender='male', racial_group='all', relative=False, poverty_rate='deep', baseline=780539.625, reform=780524.5, change=-15.125, relative_change=-1.9377619682024472e-05), PovertyRateMetricComparison(age_group='working_age', gender='female', racial_group='all', relative=True, poverty_rate='regular', baseline=0.06885619461536407, reform=0.06755512952804565, change=-0.0013010650873184204, relative_change=-0.018895396334146386), PovertyRateMetricComparison(age_group='working_age', gender='female', racial_group='all', relative=True, poverty_rate='deep', baseline=0.006544755306094885, reform=0.006544151809066534, change=-6.034970283508301e-07, relative_change=-9.221078560245269e-05), PovertyRateMetricComparison(age_group='working_age', gender='female', racial_group='all', relative=False, poverty_rate='regular', baseline=1406585.625, reform=1380007.625, change=-26578.0, relative_change=-0.01889540140864158), PovertyRateMetricComparison(age_group='working_age', gender='female', racial_group='all', relative=False, poverty_rate='deep', baseline=133695.4375, reform=133683.109375, change=-12.328125, relative_change=-9.221051391525608e-05), PovertyRateMetricComparison(age_group='working_age', gender='all', racial_group='all', relative=True, poverty_rate='regular', baseline=0.08067396283149719, reform=0.07947173714637756, change=-0.001202225685119629, relative_change=-0.014902276309776728), PovertyRateMetricComparison(age_group='working_age', gender='all', racial_group='all', relative=True, poverty_rate='deep', baseline=0.02040824294090271, reform=0.020407630130648613, change=-6.128102540969849e-07, relative_change=-3.0027585219929702e-05), PovertyRateMetricComparison(age_group='working_age', gender='all', racial_group='all', relative=False, poverty_rate='regular', baseline=3613979.5, reform=3560123.0, change=-53856.5, relative_change=-0.014902270474970874), PovertyRateMetricComparison(age_group='working_age', gender='all', racial_group='all', relative=False, poverty_rate='deep', baseline=914235.1875, reform=914207.75, change=-27.4375, relative_change=-3.001142416649764e-05), PovertyRateMetricComparison(age_group='senior', gender='male', racial_group='all', relative=True, poverty_rate='regular', baseline=0.019906071946024895, reform=0.01964147388935089, change=-0.0002645980566740036, relative_change=-0.013292328963316242), PovertyRateMetricComparison(age_group='senior', gender='male', racial_group='all', relative=True, poverty_rate='deep', baseline=0.0001492029696237296, reform=0.00014823427773080766, change=-9.686918929219246e-07, relative_change=-0.0064924437855683375), PovertyRateMetricComparison(age_group='senior', gender='male', racial_group='all', relative=False, poverty_rate='regular', baseline=120630.84375, reform=119027.3828125, change=-1603.4609375, relative_change=-0.013292296461285425), PovertyRateMetricComparison(age_group='senior', gender='male', racial_group='all', relative=False, poverty_rate='deep', baseline=904.1703491210938, reform=898.3001098632812, change=-5.8702392578125, relative_change=-0.006492404073545117), PovertyRateMetricComparison(age_group='senior', gender='female', racial_group='all', relative=True, poverty_rate='regular', baseline=0.04476610943675041, reform=0.04424646124243736, change=-0.0005196481943130493, relative_change=-0.011608071392651511), PovertyRateMetricComparison(age_group='senior', gender='female', racial_group='all', relative=True, poverty_rate='deep', baseline=0.0012297447538003325, reform=0.0012286300770938396, change=-1.1146767064929008e-06, relative_change=-0.0009064293244985742), PovertyRateMetricComparison(age_group='senior', gender='female', racial_group='all', relative=False, poverty_rate='regular', baseline=315600.8125, reform=311937.28125, change=-3663.53125, relative_change=-0.011608117295325404), PovertyRateMetricComparison(age_group='senior', gender='female', racial_group='all', relative=False, poverty_rate='deep', baseline=8669.693359375, reform=8661.8349609375, change=-7.8583984375, relative_change=-0.000906421728169001), PovertyRateMetricComparison(age_group='senior', gender='all', racial_group='all', relative=True, poverty_rate='regular', baseline=0.03327473625540733, reform=0.03287297859787941, change=-0.0004017576575279236, relative_change=-0.012073954679735011), PovertyRateMetricComparison(age_group='senior', gender='all', racial_group='all', relative=True, poverty_rate='deep', baseline=0.0007302720914594829, reform=0.0007292248192243278, change=-1.0472722351551056e-06, relative_change=-0.0014340849765490601), PovertyRateMetricComparison(age_group='senior', gender='all', racial_group='all', relative=False, poverty_rate='regular', baseline=436231.65625, reform=430964.59375, change=-5267.0625, relative_change=-0.01207400339828043), PovertyRateMetricComparison(age_group='senior', gender='all', racial_group='all', relative=False, poverty_rate='deep', baseline=9573.8642578125, reform=9560.134765625, change=-13.7294921875, relative_change=-0.0014340596250146758), PovertyRateMetricComparison(age_group='all', gender='male', racial_group='all', relative=True, poverty_rate='regular', baseline=0.08017819374799728, reform=0.0794147327542305, change=-0.0007634609937667847, relative_change=-0.009522052793635733), PovertyRateMetricComparison(age_group='all', gender='male', racial_group='all', relative=True, poverty_rate='deep', baseline=0.021698515862226486, reform=0.021697862073779106, change=-6.537884473800659e-07, relative_change=-3.013056061212938e-05), PovertyRateMetricComparison(age_group='all', gender='male', racial_group='all', relative=False, poverty_rate='regular', baseline=3098396.25, reform=3068893.0, change=-29503.25, relative_change=-0.009522103572130259), PovertyRateMetricComparison(age_group='all', gender='male', racial_group='all', relative=False, poverty_rate='deep', baseline=838514.75, reform=838489.5, change=-25.25, relative_change=-3.0112767843380216e-05), PovertyRateMetricComparison(age_group='all', gender='female', racial_group='all', relative=True, poverty_rate='regular', baseline=0.06785593926906586, reform=0.06704439222812653, change=-0.0008115470409393311, relative_change=-0.011959852736270336), PovertyRateMetricComparison(age_group='all', gender='female', racial_group='all', relative=True, poverty_rate='deep', baseline=0.005150204990059137, reform=0.005149507895112038, change=-6.970949470996857e-07, relative_change=-0.0001353528545844699), PovertyRateMetricComparison(age_group='all', gender='female', racial_group='all', relative=False, poverty_rate='regular', baseline=2588403.75, reform=2557447.0, change=-30956.75, relative_change=-0.011959784094734062), PovertyRateMetricComparison(age_group='all', gender='female', racial_group='all', relative=False, poverty_rate='deep', baseline=196457.53125, reform=196430.9375, change=-26.59375, relative_change=-0.000135366406320959), PovertyRateMetricComparison(age_group='all', gender='all', racial_group='all', relative=True, poverty_rate='regular', baseline=0.07405701279640198, reform=0.07326967269182205, change=-0.0007873401045799255, relative_change=-0.01063154014521874), PovertyRateMetricComparison(age_group='all', gender='all', racial_group='all', relative=True, poverty_rate='deep', baseline=0.013478054665029049, reform=0.013477379456162453, change=-6.752088665962219e-07, relative_change=-5.0096908150117427e-05), PovertyRateMetricComparison(age_group='all', gender='all', racial_group='all', relative=False, poverty_rate='regular', baseline=5686797.5, reform=5626338.5, change=-60459.0, relative_change=-0.010631467007573243), PovertyRateMetricComparison(age_group='all', gender='all', racial_group='all', relative=False, poverty_rate='deep', baseline=1034972.5, reform=1034920.625, change=-51.875, relative_change=-5.012210469360297e-05)], labor_supply=[])" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from policyengine import Simulation\n", + "\n", + "sim = Simulation({\n", + " \"scope\": \"macro\", # Required for this\n", + " \"country\": \"uk\", # or \"us\"\n", + " \"time_period\": 2025,\n", + " \"reform\": {\n", + " \"gov.hmrc.income_tax.allowances.personal_allowance.amount\": 15_000,\n", + " }\n", + "})\n", + "\n", + "sim.calculate()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Output schema\n", + "\n", + "`calculate_economy_comparison` or `calculate` (when `scope=household` and `reform is not None`) return the following schema." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'$defs': {'DecileImpacts': {'properties': {'income': {'$ref': '#/$defs/IncomeMeasureSpecificDecileImpacts'},\n", + " 'wealth': {'anyOf': [{'$ref': '#/$defs/IncomeMeasureSpecificDecileImpacts'},\n", + " {'type': 'null'}]}},\n", + " 'required': ['income', 'wealth'],\n", + " 'title': 'DecileImpacts',\n", + " 'type': 'object'},\n", + " 'FiscalComparison': {'properties': {'baseline': {'$ref': '#/$defs/FiscalSummary'},\n", + " 'reform': {'$ref': '#/$defs/FiscalSummary'},\n", + " 'change': {'$ref': '#/$defs/FiscalSummary'},\n", + " 'relative_change': {'$ref': '#/$defs/FiscalSummary'}},\n", + " 'required': ['baseline', 'reform', 'change', 'relative_change'],\n", + " 'title': 'FiscalComparison',\n", + " 'type': 'object'},\n", + " 'FiscalSummary': {'properties': {'tax_revenue': {'title': 'Tax Revenue',\n", + " 'type': 'number'},\n", + " 'federal_tax': {'title': 'Federal Tax', 'type': 'number'},\n", + " 'federal_balance': {'title': 'Federal Balance', 'type': 'number'},\n", + " 'state_tax': {'title': 'State Tax', 'type': 'number'},\n", + " 'government_spending': {'title': 'Government Spending', 'type': 'number'},\n", + " 'tax_benefit_programs': {'additionalProperties': {'type': 'number'},\n", + " 'title': 'Tax Benefit Programs',\n", + " 'type': 'object'},\n", + " 'household_net_income': {'title': 'Household Net Income',\n", + " 'type': 'number'}},\n", + " 'required': ['tax_revenue',\n", + " 'federal_tax',\n", + " 'federal_balance',\n", + " 'state_tax',\n", + " 'government_spending',\n", + " 'tax_benefit_programs',\n", + " 'household_net_income'],\n", + " 'title': 'FiscalSummary',\n", + " 'type': 'object'},\n", + " 'Headlines': {'properties': {'budgetary_impact': {'title': 'Budgetary Impact',\n", + " 'type': 'number'},\n", + " 'poverty_impact': {'title': 'Poverty Impact', 'type': 'number'},\n", + " 'winner_share': {'title': 'Winner Share', 'type': 'number'}},\n", + " 'required': ['budgetary_impact', 'poverty_impact', 'winner_share'],\n", + " 'title': 'Headlines',\n", + " 'type': 'object'},\n", + " 'IncomeMeasureSpecificDecileImpacts': {'properties': {'income_change': {'$ref': '#/$defs/IncomeMeasureSpecificDecileIncomeChange'},\n", + " 'winners_and_losers': {'$ref': '#/$defs/IncomeMeasureSpecificDecileWinnersLosers'}},\n", + " 'required': ['income_change', 'winners_and_losers'],\n", + " 'title': 'IncomeMeasureSpecificDecileImpacts',\n", + " 'type': 'object'},\n", + " 'IncomeMeasureSpecificDecileIncomeChange': {'properties': {'relative': {'additionalProperties': {'type': 'number'},\n", + " 'title': 'Relative',\n", + " 'type': 'object'},\n", + " 'average': {'additionalProperties': {'type': 'number'},\n", + " 'title': 'Average',\n", + " 'type': 'object'}},\n", + " 'required': ['relative', 'average'],\n", + " 'title': 'IncomeMeasureSpecificDecileIncomeChange',\n", + " 'type': 'object'},\n", + " 'IncomeMeasureSpecificDecileWinnersLosers': {'properties': {'deciles': {'additionalProperties': {'$ref': '#/$defs/IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes'},\n", + " 'title': 'Deciles',\n", + " 'type': 'object'},\n", + " 'all': {'$ref': '#/$defs/IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes'}},\n", + " 'required': ['deciles', 'all'],\n", + " 'title': 'IncomeMeasureSpecificDecileWinnersLosers',\n", + " 'type': 'object'},\n", + " 'IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes': {'properties': {'lose_more_than_5_percent_share': {'title': 'Lose More Than 5 Percent Share',\n", + " 'type': 'number'},\n", + " 'lose_less_than_5_percent_share': {'title': 'Lose Less Than 5 Percent Share',\n", + " 'type': 'number'},\n", + " 'lose_share': {'title': 'Lose Share', 'type': 'number'},\n", + " 'no_change_share': {'title': 'No Change Share', 'type': 'number'},\n", + " 'gain_share': {'title': 'Gain Share', 'type': 'number'},\n", + " 'gain_less_than_5_percent_share': {'title': 'Gain Less Than 5 Percent Share',\n", + " 'type': 'number'},\n", + " 'gain_more_than_5_percent_share': {'title': 'Gain More Than 5 Percent Share',\n", + " 'type': 'number'}},\n", + " 'required': ['lose_more_than_5_percent_share',\n", + " 'lose_less_than_5_percent_share',\n", + " 'lose_share',\n", + " 'no_change_share',\n", + " 'gain_share',\n", + " 'gain_less_than_5_percent_share',\n", + " 'gain_more_than_5_percent_share'],\n", + " 'title': 'IncomeMeasureSpecificDecileWinnersLosersGroupOutcomes',\n", + " 'type': 'object'},\n", + " 'InequalityComparison': {'properties': {'baseline': {'$ref': '#/$defs/InequalitySummary'},\n", + " 'reform': {'$ref': '#/$defs/InequalitySummary'},\n", + " 'change': {'$ref': '#/$defs/InequalitySummary'},\n", + " 'relative_change': {'$ref': '#/$defs/InequalitySummary'}},\n", + " 'required': ['baseline', 'reform', 'change', 'relative_change'],\n", + " 'title': 'InequalityComparison',\n", + " 'type': 'object'},\n", + " 'InequalitySummary': {'properties': {'gini': {'title': 'Gini',\n", + " 'type': 'number'},\n", + " 'top_10_share': {'title': 'Top 10 Share', 'type': 'number'},\n", + " 'top_1_share': {'title': 'Top 1 Share', 'type': 'number'}},\n", + " 'required': ['gini', 'top_10_share', 'top_1_share'],\n", + " 'title': 'InequalitySummary',\n", + " 'type': 'object'},\n", + " 'LaborSupplyMetricImpact': {'properties': {'elasticity': {'enum': ['income',\n", + " 'substitution',\n", + " 'all'],\n", + " 'title': 'Elasticity',\n", + " 'type': 'string'},\n", + " 'decile': {'enum': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'all'],\n", + " 'title': 'Decile'},\n", + " 'unit': {'enum': ['earnings', 'hours'], 'title': 'Unit', 'type': 'string'},\n", + " 'baseline': {'title': 'Baseline', 'type': 'number'},\n", + " 'reform': {'title': 'Reform', 'type': 'number'},\n", + " 'change': {'title': 'Change', 'type': 'number'},\n", + " 'relative_change': {'title': 'Relative Change', 'type': 'number'},\n", + " 'average_change': {'title': 'Average Change', 'type': 'number'}},\n", + " 'required': ['elasticity',\n", + " 'decile',\n", + " 'unit',\n", + " 'baseline',\n", + " 'reform',\n", + " 'change',\n", + " 'relative_change',\n", + " 'average_change'],\n", + " 'title': 'LaborSupplyMetricImpact',\n", + " 'type': 'object'},\n", + " 'PovertyRateMetricComparison': {'properties': {'age_group': {'enum': ['child',\n", + " 'working_age',\n", + " 'senior',\n", + " 'all'],\n", + " 'title': 'Age Group',\n", + " 'type': 'string'},\n", + " 'gender': {'enum': ['male', 'female', 'all'],\n", + " 'title': 'Gender',\n", + " 'type': 'string'},\n", + " 'racial_group': {'enum': ['white', 'black', 'hispanic', 'other', 'all'],\n", + " 'title': 'Racial Group',\n", + " 'type': 'string'},\n", + " 'relative': {'title': 'Relative', 'type': 'boolean'},\n", + " 'poverty_rate': {'enum': ['regular',\n", + " 'deep',\n", + " 'uk_hbai_bhc',\n", + " 'uk_hbai_bhc_half',\n", + " 'us_spm',\n", + " 'us_spm_half'],\n", + " 'title': 'Poverty Rate',\n", + " 'type': 'string'},\n", + " 'baseline': {'title': 'Baseline', 'type': 'number'},\n", + " 'reform': {'title': 'Reform', 'type': 'number'},\n", + " 'change': {'title': 'Change', 'type': 'number'},\n", + " 'relative_change': {'title': 'Relative Change', 'type': 'number'}},\n", + " 'required': ['age_group',\n", + " 'gender',\n", + " 'racial_group',\n", + " 'relative',\n", + " 'poverty_rate',\n", + " 'baseline',\n", + " 'reform',\n", + " 'change',\n", + " 'relative_change'],\n", + " 'title': 'PovertyRateMetricComparison',\n", + " 'type': 'object'}},\n", + " 'properties': {'headlines': {'$ref': '#/$defs/Headlines'},\n", + " 'fiscal': {'$ref': '#/$defs/FiscalComparison'},\n", + " 'inequality': {'$ref': '#/$defs/InequalityComparison'},\n", + " 'distributional': {'$ref': '#/$defs/DecileImpacts'},\n", + " 'poverty': {'items': {'$ref': '#/$defs/PovertyRateMetricComparison'},\n", + " 'title': 'Poverty',\n", + " 'type': 'array'},\n", + " 'labor_supply': {'items': {'$ref': '#/$defs/LaborSupplyMetricImpact'},\n", + " 'title': 'Labor Supply',\n", + " 'type': 'array'}},\n", + " 'required': ['headlines',\n", + " 'fiscal',\n", + " 'inequality',\n", + " 'distributional',\n", + " 'poverty',\n", + " 'labor_supply'],\n", + " 'title': 'EconomyComparison',\n", + " 'type': 'object'}" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from policyengine.outputs.macro.comparison.calculate_economy_comparison import EconomyComparison\n", + "\n", + "EconomyComparison.model_json_schema()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/reference/calculate_household_comparison.ipynb b/docs/reference/calculate_household_comparison.ipynb new file mode 100644 index 00000000..f86d3f12 --- /dev/null +++ b/docs/reference/calculate_household_comparison.ipynb @@ -0,0 +1,155 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compare outcomes for specific household scenarios\n", + "\n", + "Use `Simulation.calculate_household_comparison()` to use PolicyEngine's tax-benefit model to compare how taxes, benefits and other household properties change under a change in tax or benefit rules. This notebook demonstrates how to use this function to compare outcomes for specific households." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "HouseholdComparison(full_household_baseline={'people': {'person': {'age': {'2025': 30.0}, 'employment_income': {'2025': 30000.0}, 'employment_income_before_lsr': {'2025': 30000.0}, 'private_pension_income': {'2025': 0.0}, 'pension_income': {'2025': 0.0}, 'state_pension': {'2025': 0.0}, 'self_employment_income': {'2025': 0.0}, 'property_income': {'2025': 0.0}, 'savings_interest_income': {'2025': 0.0}, 'dividend_income': {'2025': 0.0}, 'sublet_income': {'2025': 0.0}, 'miscellaneous_income': {'2025': 0.0}, 'private_transfer_income': {'2025': 0.0}, 'lump_sum_income': {'2025': 0.0}, 'maintenance_income': {'2025': 0.0}, 'other_investment_income': {'2025': 0.0}, 'dla_sc_category': {'2025': 'NONE'}, 'dla_m_category': {'2025': 'NONE'}, 'pip_m_category': {'2025': 'NONE'}, 'pip_dl_category': {'2025': 'NONE'}, 'receives_carers_allowance': {'2025': False}, 'childcare_expenses': {'2025': 0.0}, 'employer_pension_contributions': {'2025': 0.0}, 'employee_pension_contributions': {'2025': 0.0}, 'personal_pension_contributions': {'2025': 0.0}, 'maintenance_expenses': {'2025': 0.0}, 'bi_individual_phaseout': {'2025': 0.0}, 'bi_household_phaseout': {'2025': 0.0}, 'bi_phaseout': {'2025': 0.0}, 'basic_income': {'2025': 0.0}, 'bi_maximum': {'2025': 0.0}, 'attends_private_school': {'2025': False}, 'employer_cost': {'2025': 32884.2}, 'baseline_employer_cost': {'2025': 32884.2}, 'adjusted_employer_cost': {'2025': 32884.2}, 'employer_ni_response_consumer_incidence': {'2025': 0.0}, 'employer_ni_response_capital_incidence': {'2025': 0.0}, 'employer_ni_fixed_employer_cost_change': {'2025': 0.0}, 'marginal_tax_rate': {'2025': 0.27999997}, 'cliff_evaluated': {'2025': True}, 'cliff_gap': {'2025': 0.0}, 'is_on_cliff': {'2025': False}, 'person_id': {'2025': 0.0}, 'people': {'2025': 1.0}, 'raw_person_weight': {'2025': 1.0}, 'person_weight': {'2025': 1.0}, 'adult_index': {'2025': 1.0}, 'birth_year': {'2025': 1995.0}, 'over_16': {'2025': True}, 'is_adult': {'2025': True}, 'is_child': {'2025': False}, 'child_index': {'2025': -1.0}, 'is_eldest_child': {'2025': True}, 'is_benunit_eldest_child': {'2025': False}, 'marital_status': {'2025': 'SINGLE'}, 'current_education': {'2025': 'NOT_IN_EDUCATION'}, 'highest_education': {'2025': 'UPPER_SECONDARY'}, 'in_FE': {'2025': False}, 'in_HE': {'2025': False}, 'gender': {'2025': 'MALE'}, 'is_male': {'2025': True}, 'is_female': {'2025': False}, 'is_household_head': {'2025': True}, 'is_benunit_head': {'2025': True}, 'in_social_housing': {'2025': False}, 'is_WA_adult': {'2025': True}, 'is_young_child': {'2025': False}, 'age_under_18': {'2025': False}, 'age_18_64': {'2025': True}, 'age_over_64': {'2025': False}, 'is_older_child': {'2025': False}, 'is_higher_earner': {'2025': True}, 'person_benunit_id': {'2025': 0.0}, 'person_household_id': {'2025': 0.0}, 'role': {'2025': ''}, 'person_benunit_role': {'2025': ''}, 'person_household_role': {'2025': ''}, 'is_disabled_for_benefits': {'2025': False}, 'is_enhanced_disabled_for_benefits': {'2025': False}, 'is_severely_disabled_for_benefits': {'2025': False}, 'person_state_id': {'2025': 0.0}, 'person_state_role': {'2025': ''}, 'is_blind': {'2025': False}, 'is_carer_for_benefits': {'2025': False}, 'personal_rent': {'2025': 0.0}, 'weekly_childcare_expenses': {'2025': 0.0}, 'earned_income': {'2025': 30000.0}, 'market_income': {'2025': 30000.0}, 'hours_worked': {'2025': 0.0}, 'in_work': {'2025': True}, 'weekly_hours': {'2025': 0.0}, 'employment_status': {'2025': 'UNEMPLOYED'}, 'capital_income': {'2025': 0.0}, 'base_net_income': {'2025': 0.0}, 'is_apprentice': {'2025': False}, 'minimum_wage_category': {'2025': 'OVER_24'}, 'minimum_wage': {'2025': 9.5}, 'income_decile': {'2025': 10.0}, 'household_statutory_maternity_pay': {'2025': 0.0}, 'household_statutory_paternity_pay': {'2025': 0.0}, 'household_statutory_sick_pay': {'2025': 0.0}, 'capital_gains': {'2025': 0.0}, 'is_QYP': {'2025': False}, 'is_child_or_QYP': {'2025': False}, 'employment_benefits': {'2025': 0.0}, 'relative_income_change': {'2025': 0.0}, 'relative_wage_change': {'2025': 0.0}, 'income_elasticity_lsr': {'2025': 0.0}, 'substitution_elasticity_lsr': {'2025': 0.0}, 'employment_income_behavioral_response': {'2025': 0.0}, 'income_support_reported': {'2025': 0.0}, 'attendance_allowance': {'2025': 0.0}, 'attendance_allowance_reported': {'2025': 0.0}, 'aa_category': {'2025': 'NONE'}, 'esa_income_reported': {'2025': 0.0}, 'iidb': {'2025': 0.0}, 'iidb_reported': {'2025': 0.0}, 'jsa_contrib': {'2025': 0.0}, 'jsa_contrib_reported': {'2025': 0.0}, 'maternity_allowance_reported': {'2025': 0.0}, 'maternity_allowance': {'2025': 0.0}, 'ssmg_reported': {'2025': 0.0}, 'ssmg': {'2025': 0.0}, 'council_tax_benefit_reported': {'2025': 0.0}, 'working_tax_credit_reported': {'2025': 0.0}, 'child_tax_credit_reported': {'2025': 0.0}, 'is_CTC_child_limit_exempt': {'2025': True}, 'is_child_for_CTC': {'2025': False}, 'jsa_income_reported': {'2025': 0.0}, 'bsp': {'2025': 0.0}, 'bsp_reported': {'2025': 0.0}, 'incapacity_benefit': {'2025': 0.0}, 'incapacity_benefit_reported': {'2025': 0.0}, 'sda': {'2025': 0.0}, 'sda_reported': {'2025': 0.0}, 'carers_allowance': {'2025': 0.0}, 'care_hours': {'2025': 0.0}, 'carers_allowance_reported': {'2025': 0.0}, 'armed_forces_independence_payment': {'2025': 0.0}, 'esa_contrib': {'2025': 0.0}, 'esa_contrib_reported': {'2025': 0.0}, 'esa': {'2025': 0.0}, 'afcs': {'2025': 0.0}, 'afcs_reported': {'2025': 0.0}, 'student_loans': {'2025': 0.0}, 'adult_ema': {'2025': 0.0}, 'child_ema': {'2025': 0.0}, 'access_fund': {'2025': 0.0}, 'education_grants': {'2025': 0.0}, 'student_payments': {'2025': 0.0}, 'state_pension_age': {'2025': 66.0}, 'is_SP_age': {'2025': False}, 'state_pension_type': {'2025': 'NONE'}, 'basic_state_pension': {'2025': 0.0}, 'additional_state_pension': {'2025': 0.0}, 'new_state_pension': {'2025': 0.0}, 'state_pension_reported': {'2025': 0.0}, 'winter_fuel_allowance_reported': {'2025': 0.0}, 'dla_m_reported': {'2025': 0.0}, 'dla_m': {'2025': 0.0}, 'dla_sc_reported': {'2025': 0.0}, 'dla_sc': {'2025': 0.0}, 'dla_sc_middle_plus': {'2025': False}, 'receives_highest_dla_sc': {'2025': False}, 'dla': {'2025': 0.0}, 'housing_benefit_reported': {'2025': 0.0}, 'household_benefits_individual_non_dep_deduction': {'2025': 6476.6}, 'housing_benefit_individual_non_dep_deduction_eligible': {'2025': True}, 'universal_credit_reported': {'2025': 0.0}, 'uc_is_child_born_before_child_limit': {'2025': False}, 'uc_individual_child_element': {'2025': 0.0}, 'uc_individual_disabled_child_element': {'2025': 0.0}, 'uc_individual_severely_disabled_child_element': {'2025': 0.0}, 'uc_is_in_startup_period': {'2025': False}, 'uc_minimum_income_floor': {'2025': 17290.0}, 'uc_mif_applies': {'2025': False}, 'uc_mif_capped_earned_income': {'2025': 30000.0}, 'uc_limited_capability_for_WRA': {'2025': False}, 'uc_individual_non_dep_deduction_eligible': {'2025': True}, 'uc_individual_non_dep_deduction': {'2025': 1125.3458}, 'uc_non_dep_deduction_exempt': {'2025': False}, 'pip_m_reported': {'2025': 0.0}, 'pip_m': {'2025': 0.0}, 'pip_dl_reported': {'2025': 0.0}, 'pip_dl': {'2025': 0.0}, 'receives_enhanced_pip_dl': {'2025': False}, 'pip': {'2025': 0.0}, 'pension_credit_reported': {'2025': 0.0}, 'tax': {'2025': 4880.4033}, 'tax_reported': {'2025': 0.0}, 'tax_modelling': {'2025': 4880.4033}, 'child_benefit_reported': {'2025': 0.0}, 'child_benefit_respective_amount': {'2025': 0.0}, 'relative_capital_gains_mtr_change': {'2025': 0.0}, 'capital_gains_elasticity': {'2025': 0.0}, 'capital_gains_behavioural_response': {'2025': 0.0}, 'capital_gains_before_response': {'2025': 0.0}, 'adult_index_cg': {'2025': 1.0}, 'marginal_tax_rate_on_capital_gains': {'2025': 0.0}, 'capital_gains_tax': {'2025': 0.0}, 'ni_employee': {'2025': 1394.4033}, 'national_insurance': {'2025': 1394.4033}, 'ni_employer': {'2025': 2884.2}, 'ni_self_employed': {'2025': 0.0}, 'total_national_insurance': {'2025': 4278.6035}, 'ni_class_4_maximum': {'2025': 917.73663}, 'ni_class_4': {'2025': 0.0}, 'ni_class_4_main': {'2025': 0.0}, 'ni_class_3': {'2025': 0.0}, 'ni_class_2': {'2025': 0.0}, 'ni_class_1_employee_primary': {'2025': 1394.4033}, 'ni_class_1_income': {'2025': 30000.0}, 'ni_class_1_employee': {'2025': 1394.4033}, 'ni_class_1_employee_additional': {'2025': 0.0}, 'ni_liable': {'2025': True}, 'ni_class_1_employer': {'2025': 2884.2}, 'other_tax_credits': {'2025': 0.0}, 'earned_income_tax': {'2025': 3486.0}, 'total_income': {'2025': 30000.0}, 'income_tax': {'2025': 3486.0}, 'taxed_income': {'2025': 17430.0}, 'adjusted_net_income': {'2025': 30000.0}, 'total_pension_income': {'2025': 0.0}, 'social_security_income': {'2025': 0.0}, 'income_tax_pre_charges': {'2025': 3486.0}, 'personal_allowance': {'2025': 12570.0}, 'blind_persons_allowance': {'2025': 0.0}, 'married_couples_allowance': {'2025': 0.0}, 'married_couples_allowance_deduction': {'2025': 0.0}, 'capped_mcad': {'2025': 0.0}, 'pension_annual_allowance': {'2025': 40000.0}, 'trading_allowance': {'2025': 1000.0}, 'trading_allowance_deduction': {'2025': 0.0}, 'property_allowance': {'2025': 1000.0}, 'property_allowance_deduction': {'2025': 0.0}, 'savings_allowance': {'2025': 1000.0}, 'dividend_allowance': {'2025': 500.0}, 'gift_aid': {'2025': 0.0}, 'covenanted_payments': {'2025': 0.0}, 'charitable_investment_gifts': {'2025': 0.0}, 'other_deductions': {'2025': 0.0}, 'allowances': {'2025': 12570.0}, 'unused_personal_allowance': {'2025': 0.0}, 'meets_marriage_allowance_income_conditions': {'2025': True}, 'partners_unused_personal_allowance': {'2025': 0.0}, 'marriage_allowance': {'2025': 0.0}, 'received_allowances': {'2025': 12570.0}, 'received_allowances_savings_income': {'2025': 0.0}, 'received_allowances_dividend_income': {'2025': 0.0}, 'received_allowances_earned_income': {'2025': 12570.0}, 'savings_income_tax': {'2025': 0.0}, 'dividend_income_tax': {'2025': 0.0}, 'loss_relief': {'2025': 0.0}, 'capital_allowances': {'2025': 0.0}, 'deficiency_relief': {'2025': 0.0}, 'employment_deductions': {'2025': 0.0}, 'employment_expenses': {'2025': 0.0}, 'CB_HITC': {'2025': 0.0}, 'higher_rate_earned_income': {'2025': 0.0}, 'add_rate_earned_income': {'2025': 0.0}, 'earned_taxable_income': {'2025': 17430.0}, 'basic_rate_earned_income': {'2025': 17430.0}, 'taxable_pension_income': {'2025': 0.0}, 'taxable_miscellaneous_income': {'2025': 0.0}, 'taxed_dividend_income': {'2025': 0.0}, 'taxable_dividend_income': {'2025': 0.0}, 'taxable_social_security_income': {'2025': 0.0}, 'taxable_employment_income': {'2025': 30000.0}, 'trading_loss': {'2025': 0.0}, 'taxable_self_employment_income': {'2025': 0.0}, 'taxable_property_income': {'2025': 0.0}, 'individual_savings_account_interest_income': {'2025': 0.0}, 'taxable_savings_interest_income': {'2025': 0.0}, 'tax_free_savings_income': {'2025': 0.0}, 'higher_rate_earned_income_tax': {'2025': 0.0}, 'add_rate_earned_income_tax': {'2025': 0.0}, 'tax_band': {'2025': 'BASIC'}, 'basic_rate_earned_income_tax': {'2025': 3486.0}, 'basic_rate_savings_income_pre_starter': {'2025': 0.0}, 'taxed_savings_income': {'2025': 0.0}, 'higher_rate_savings_income': {'2025': 0.0}, 'savings_starter_rate_income': {'2025': 0.0}, 'add_rate_savings_income': {'2025': 0.0}, 'basic_rate_savings_income': {'2025': 0.0}, 'personal_pension_contributions_tax': {'2025': 0.0}, 'pension_contributions_relief': {'2025': 0.0}, 'pension_contributions': {'2025': 0.0}, 'statutory_maternity_pay': {'2025': 0.0}, 'statutory_sick_pay': {'2025': 0.0}, 'pays_scottish_income_tax': {'2025': False}}}}, full_household_reform={'people': {'person': {'age': {'2025': 30.0}, 'employment_income': {'2025': 30000.0}, 'employment_income_before_lsr': {'2025': 30000.0}, 'private_pension_income': {'2025': 0.0}, 'pension_income': {'2025': 0.0}, 'state_pension': {'2025': 0.0}, 'self_employment_income': {'2025': 0.0}, 'property_income': {'2025': 0.0}, 'savings_interest_income': {'2025': 0.0}, 'dividend_income': {'2025': 0.0}, 'sublet_income': {'2025': 0.0}, 'miscellaneous_income': {'2025': 0.0}, 'private_transfer_income': {'2025': 0.0}, 'lump_sum_income': {'2025': 0.0}, 'maintenance_income': {'2025': 0.0}, 'other_investment_income': {'2025': 0.0}, 'dla_sc_category': {'2025': 'NONE'}, 'dla_m_category': {'2025': 'NONE'}, 'pip_m_category': {'2025': 'NONE'}, 'pip_dl_category': {'2025': 'NONE'}, 'receives_carers_allowance': {'2025': False}, 'childcare_expenses': {'2025': 0.0}, 'employer_pension_contributions': {'2025': 0.0}, 'employee_pension_contributions': {'2025': 0.0}, 'personal_pension_contributions': {'2025': 0.0}, 'maintenance_expenses': {'2025': 0.0}, 'bi_individual_phaseout': {'2025': 0.0}, 'bi_household_phaseout': {'2025': 0.0}, 'bi_phaseout': {'2025': 0.0}, 'basic_income': {'2025': 0.0}, 'bi_maximum': {'2025': 0.0}, 'attends_private_school': {'2025': False}, 'employer_cost': {'2025': 32884.2}, 'baseline_employer_cost': {'2025': 32884.2}, 'adjusted_employer_cost': {'2025': 32884.2}, 'employer_ni_response_consumer_incidence': {'2025': 0.0}, 'employer_ni_response_capital_incidence': {'2025': 0.0}, 'employer_ni_fixed_employer_cost_change': {'2025': 0.0}, 'marginal_tax_rate': {'2025': 0.27999997}, 'cliff_evaluated': {'2025': True}, 'cliff_gap': {'2025': 0.0}, 'is_on_cliff': {'2025': False}, 'person_id': {'2025': 0.0}, 'people': {'2025': 1.0}, 'raw_person_weight': {'2025': 1.0}, 'person_weight': {'2025': 1.0}, 'adult_index': {'2025': 1.0}, 'birth_year': {'2025': 1995.0}, 'over_16': {'2025': True}, 'is_adult': {'2025': True}, 'is_child': {'2025': False}, 'child_index': {'2025': -1.0}, 'is_eldest_child': {'2025': True}, 'is_benunit_eldest_child': {'2025': False}, 'marital_status': {'2025': 'SINGLE'}, 'current_education': {'2025': 'NOT_IN_EDUCATION'}, 'highest_education': {'2025': 'UPPER_SECONDARY'}, 'in_FE': {'2025': False}, 'in_HE': {'2025': False}, 'gender': {'2025': 'MALE'}, 'is_male': {'2025': True}, 'is_female': {'2025': False}, 'is_household_head': {'2025': True}, 'is_benunit_head': {'2025': True}, 'in_social_housing': {'2025': False}, 'is_WA_adult': {'2025': True}, 'is_young_child': {'2025': False}, 'age_under_18': {'2025': False}, 'age_18_64': {'2025': True}, 'age_over_64': {'2025': False}, 'is_older_child': {'2025': False}, 'is_higher_earner': {'2025': True}, 'person_benunit_id': {'2025': 0.0}, 'person_household_id': {'2025': 0.0}, 'role': {'2025': ''}, 'person_benunit_role': {'2025': ''}, 'person_household_role': {'2025': ''}, 'is_disabled_for_benefits': {'2025': False}, 'is_enhanced_disabled_for_benefits': {'2025': False}, 'is_severely_disabled_for_benefits': {'2025': False}, 'person_state_id': {'2025': 0.0}, 'person_state_role': {'2025': ''}, 'is_blind': {'2025': False}, 'is_carer_for_benefits': {'2025': False}, 'personal_rent': {'2025': 0.0}, 'weekly_childcare_expenses': {'2025': 0.0}, 'earned_income': {'2025': 30000.0}, 'market_income': {'2025': 30000.0}, 'hours_worked': {'2025': 0.0}, 'in_work': {'2025': True}, 'weekly_hours': {'2025': 0.0}, 'employment_status': {'2025': 'UNEMPLOYED'}, 'capital_income': {'2025': 0.0}, 'base_net_income': {'2025': 0.0}, 'is_apprentice': {'2025': False}, 'minimum_wage_category': {'2025': 'OVER_24'}, 'minimum_wage': {'2025': 9.5}, 'income_decile': {'2025': 10.0}, 'household_statutory_maternity_pay': {'2025': 0.0}, 'household_statutory_paternity_pay': {'2025': 0.0}, 'household_statutory_sick_pay': {'2025': 0.0}, 'capital_gains': {'2025': 0.0}, 'is_QYP': {'2025': False}, 'is_child_or_QYP': {'2025': False}, 'employment_benefits': {'2025': 0.0}, 'relative_income_change': {'2025': 0.019470373}, 'relative_wage_change': {'2025': 0.0}, 'income_elasticity_lsr': {'2025': 0.0}, 'substitution_elasticity_lsr': {'2025': 0.0}, 'employment_income_behavioral_response': {'2025': 0.0}, 'income_support_reported': {'2025': 0.0}, 'attendance_allowance': {'2025': 0.0}, 'attendance_allowance_reported': {'2025': 0.0}, 'aa_category': {'2025': 'NONE'}, 'esa_income_reported': {'2025': 0.0}, 'iidb': {'2025': 0.0}, 'iidb_reported': {'2025': 0.0}, 'jsa_contrib': {'2025': 0.0}, 'jsa_contrib_reported': {'2025': 0.0}, 'maternity_allowance_reported': {'2025': 0.0}, 'maternity_allowance': {'2025': 0.0}, 'ssmg_reported': {'2025': 0.0}, 'ssmg': {'2025': 0.0}, 'council_tax_benefit_reported': {'2025': 0.0}, 'working_tax_credit_reported': {'2025': 0.0}, 'child_tax_credit_reported': {'2025': 0.0}, 'is_CTC_child_limit_exempt': {'2025': True}, 'is_child_for_CTC': {'2025': False}, 'jsa_income_reported': {'2025': 0.0}, 'bsp': {'2025': 0.0}, 'bsp_reported': {'2025': 0.0}, 'incapacity_benefit': {'2025': 0.0}, 'incapacity_benefit_reported': {'2025': 0.0}, 'sda': {'2025': 0.0}, 'sda_reported': {'2025': 0.0}, 'carers_allowance': {'2025': 0.0}, 'care_hours': {'2025': 0.0}, 'carers_allowance_reported': {'2025': 0.0}, 'armed_forces_independence_payment': {'2025': 0.0}, 'esa_contrib': {'2025': 0.0}, 'esa_contrib_reported': {'2025': 0.0}, 'esa': {'2025': 0.0}, 'afcs': {'2025': 0.0}, 'afcs_reported': {'2025': 0.0}, 'student_loans': {'2025': 0.0}, 'adult_ema': {'2025': 0.0}, 'child_ema': {'2025': 0.0}, 'access_fund': {'2025': 0.0}, 'education_grants': {'2025': 0.0}, 'student_payments': {'2025': 0.0}, 'state_pension_age': {'2025': 66.0}, 'is_SP_age': {'2025': False}, 'state_pension_type': {'2025': 'NONE'}, 'basic_state_pension': {'2025': 0.0}, 'additional_state_pension': {'2025': 0.0}, 'new_state_pension': {'2025': 0.0}, 'state_pension_reported': {'2025': 0.0}, 'winter_fuel_allowance_reported': {'2025': 0.0}, 'dla_m_reported': {'2025': 0.0}, 'dla_m': {'2025': 0.0}, 'dla_sc_reported': {'2025': 0.0}, 'dla_sc': {'2025': 0.0}, 'dla_sc_middle_plus': {'2025': False}, 'receives_highest_dla_sc': {'2025': False}, 'dla': {'2025': 0.0}, 'housing_benefit_reported': {'2025': 0.0}, 'household_benefits_individual_non_dep_deduction': {'2025': 6476.6}, 'housing_benefit_individual_non_dep_deduction_eligible': {'2025': True}, 'universal_credit_reported': {'2025': 0.0}, 'uc_is_child_born_before_child_limit': {'2025': False}, 'uc_individual_child_element': {'2025': 0.0}, 'uc_individual_disabled_child_element': {'2025': 0.0}, 'uc_individual_severely_disabled_child_element': {'2025': 0.0}, 'uc_is_in_startup_period': {'2025': False}, 'uc_minimum_income_floor': {'2025': 17290.0}, 'uc_mif_applies': {'2025': False}, 'uc_mif_capped_earned_income': {'2025': 30000.0}, 'uc_limited_capability_for_WRA': {'2025': False}, 'uc_individual_non_dep_deduction_eligible': {'2025': True}, 'uc_individual_non_dep_deduction': {'2025': 1125.3458}, 'uc_non_dep_deduction_exempt': {'2025': False}, 'pip_m_reported': {'2025': 0.0}, 'pip_m': {'2025': 0.0}, 'pip_dl_reported': {'2025': 0.0}, 'pip_dl': {'2025': 0.0}, 'receives_enhanced_pip_dl': {'2025': False}, 'pip': {'2025': 0.0}, 'pension_credit_reported': {'2025': 0.0}, 'tax': {'2025': 4394.4033}, 'tax_reported': {'2025': 0.0}, 'tax_modelling': {'2025': 4394.4033}, 'child_benefit_reported': {'2025': 0.0}, 'child_benefit_respective_amount': {'2025': 0.0}, 'relative_capital_gains_mtr_change': {'2025': 0.0}, 'capital_gains_elasticity': {'2025': 0.0}, 'capital_gains_behavioural_response': {'2025': 0.0}, 'capital_gains_before_response': {'2025': 0.0}, 'adult_index_cg': {'2025': 1.0}, 'marginal_tax_rate_on_capital_gains': {'2025': 0.0}, 'capital_gains_tax': {'2025': 0.0}, 'ni_employee': {'2025': 1394.4033}, 'national_insurance': {'2025': 1394.4033}, 'ni_employer': {'2025': 2884.2}, 'ni_self_employed': {'2025': 0.0}, 'total_national_insurance': {'2025': 4278.6035}, 'ni_class_4_maximum': {'2025': 917.73663}, 'ni_class_4': {'2025': 0.0}, 'ni_class_4_main': {'2025': 0.0}, 'ni_class_3': {'2025': 0.0}, 'ni_class_2': {'2025': 0.0}, 'ni_class_1_employee_primary': {'2025': 1394.4033}, 'ni_class_1_income': {'2025': 30000.0}, 'ni_class_1_employee': {'2025': 1394.4033}, 'ni_class_1_employee_additional': {'2025': 0.0}, 'ni_liable': {'2025': True}, 'ni_class_1_employer': {'2025': 2884.2}, 'other_tax_credits': {'2025': 0.0}, 'earned_income_tax': {'2025': 3000.0}, 'total_income': {'2025': 30000.0}, 'income_tax': {'2025': 3000.0}, 'taxed_income': {'2025': 15000.0}, 'adjusted_net_income': {'2025': 30000.0}, 'total_pension_income': {'2025': 0.0}, 'social_security_income': {'2025': 0.0}, 'income_tax_pre_charges': {'2025': 3000.0}, 'personal_allowance': {'2025': 15000.0}, 'blind_persons_allowance': {'2025': 0.0}, 'married_couples_allowance': {'2025': 0.0}, 'married_couples_allowance_deduction': {'2025': 0.0}, 'capped_mcad': {'2025': 0.0}, 'pension_annual_allowance': {'2025': 40000.0}, 'trading_allowance': {'2025': 1000.0}, 'trading_allowance_deduction': {'2025': 0.0}, 'property_allowance': {'2025': 1000.0}, 'property_allowance_deduction': {'2025': 0.0}, 'savings_allowance': {'2025': 1000.0}, 'dividend_allowance': {'2025': 500.0}, 'gift_aid': {'2025': 0.0}, 'covenanted_payments': {'2025': 0.0}, 'charitable_investment_gifts': {'2025': 0.0}, 'other_deductions': {'2025': 0.0}, 'allowances': {'2025': 15000.0}, 'unused_personal_allowance': {'2025': 0.0}, 'meets_marriage_allowance_income_conditions': {'2025': True}, 'partners_unused_personal_allowance': {'2025': 0.0}, 'marriage_allowance': {'2025': 0.0}, 'received_allowances': {'2025': 15000.0}, 'received_allowances_savings_income': {'2025': 0.0}, 'received_allowances_dividend_income': {'2025': 0.0}, 'received_allowances_earned_income': {'2025': 15000.0}, 'savings_income_tax': {'2025': 0.0}, 'dividend_income_tax': {'2025': 0.0}, 'loss_relief': {'2025': 0.0}, 'capital_allowances': {'2025': 0.0}, 'deficiency_relief': {'2025': 0.0}, 'employment_deductions': {'2025': 0.0}, 'employment_expenses': {'2025': 0.0}, 'CB_HITC': {'2025': 0.0}, 'higher_rate_earned_income': {'2025': 0.0}, 'add_rate_earned_income': {'2025': 0.0}, 'earned_taxable_income': {'2025': 15000.0}, 'basic_rate_earned_income': {'2025': 15000.0}, 'taxable_pension_income': {'2025': 0.0}, 'taxable_miscellaneous_income': {'2025': 0.0}, 'taxed_dividend_income': {'2025': 0.0}, 'taxable_dividend_income': {'2025': 0.0}, 'taxable_social_security_income': {'2025': 0.0}, 'taxable_employment_income': {'2025': 30000.0}, 'trading_loss': {'2025': 0.0}, 'taxable_self_employment_income': {'2025': 0.0}, 'taxable_property_income': {'2025': 0.0}, 'individual_savings_account_interest_income': {'2025': 0.0}, 'taxable_savings_interest_income': {'2025': 0.0}, 'tax_free_savings_income': {'2025': 0.0}, 'higher_rate_earned_income_tax': {'2025': 0.0}, 'add_rate_earned_income_tax': {'2025': 0.0}, 'tax_band': {'2025': 'BASIC'}, 'basic_rate_earned_income_tax': {'2025': 3000.0}, 'basic_rate_savings_income_pre_starter': {'2025': 0.0}, 'taxed_savings_income': {'2025': 0.0}, 'higher_rate_savings_income': {'2025': 0.0}, 'savings_starter_rate_income': {'2025': 0.0}, 'add_rate_savings_income': {'2025': 0.0}, 'basic_rate_savings_income': {'2025': 0.0}, 'personal_pension_contributions_tax': {'2025': 0.0}, 'pension_contributions_relief': {'2025': 0.0}, 'pension_contributions': {'2025': 0.0}, 'statutory_maternity_pay': {'2025': 0.0}, 'statutory_sick_pay': {'2025': 0.0}, 'pays_scottish_income_tax': {'2025': False}}}}, change={'people': {'person': {'age': {'2025': 0.0}, 'employment_income': {'2025': 0.0}, 'employment_income_before_lsr': {'2025': 0.0}, 'private_pension_income': {'2025': 0.0}, 'pension_income': {'2025': 0.0}, 'state_pension': {'2025': 0.0}, 'self_employment_income': {'2025': 0.0}, 'property_income': {'2025': 0.0}, 'savings_interest_income': {'2025': 0.0}, 'dividend_income': {'2025': 0.0}, 'sublet_income': {'2025': 0.0}, 'miscellaneous_income': {'2025': 0.0}, 'private_transfer_income': {'2025': 0.0}, 'lump_sum_income': {'2025': 0.0}, 'maintenance_income': {'2025': 0.0}, 'other_investment_income': {'2025': 0.0}, 'dla_sc_category': {'2025': 0.0}, 'dla_m_category': {'2025': 0.0}, 'pip_m_category': {'2025': 0.0}, 'pip_dl_category': {'2025': 0.0}, 'receives_carers_allowance': {'2025': 0.0}, 'childcare_expenses': {'2025': 0.0}, 'employer_pension_contributions': {'2025': 0.0}, 'employee_pension_contributions': {'2025': 0.0}, 'personal_pension_contributions': {'2025': 0.0}, 'maintenance_expenses': {'2025': 0.0}, 'bi_individual_phaseout': {'2025': 0.0}, 'bi_household_phaseout': {'2025': 0.0}, 'bi_phaseout': {'2025': 0.0}, 'basic_income': {'2025': 0.0}, 'bi_maximum': {'2025': 0.0}, 'attends_private_school': {'2025': 0.0}, 'employer_cost': {'2025': 0.0}, 'baseline_employer_cost': {'2025': 0.0}, 'adjusted_employer_cost': {'2025': 0.0}, 'employer_ni_response_consumer_incidence': {'2025': 0.0}, 'employer_ni_response_capital_incidence': {'2025': 0.0}, 'employer_ni_fixed_employer_cost_change': {'2025': 0.0}, 'marginal_tax_rate': {'2025': 0.0}, 'cliff_evaluated': {'2025': 0.0}, 'cliff_gap': {'2025': 0.0}, 'is_on_cliff': {'2025': 0.0}, 'person_id': {'2025': 0.0}, 'people': {'2025': 0.0}, 'raw_person_weight': {'2025': 0.0}, 'person_weight': {'2025': 0.0}, 'adult_index': {'2025': 0.0}, 'birth_year': {'2025': 0.0}, 'over_16': {'2025': 0.0}, 'is_adult': {'2025': 0.0}, 'is_child': {'2025': 0.0}, 'child_index': {'2025': 0.0}, 'is_eldest_child': {'2025': 0.0}, 'is_benunit_eldest_child': {'2025': 0.0}, 'marital_status': {'2025': 0.0}, 'current_education': {'2025': 0.0}, 'highest_education': {'2025': 0.0}, 'in_FE': {'2025': 0.0}, 'in_HE': {'2025': 0.0}, 'gender': {'2025': 0.0}, 'is_male': {'2025': 0.0}, 'is_female': {'2025': 0.0}, 'is_household_head': {'2025': 0.0}, 'is_benunit_head': {'2025': 0.0}, 'in_social_housing': {'2025': 0.0}, 'is_WA_adult': {'2025': 0.0}, 'is_young_child': {'2025': 0.0}, 'age_under_18': {'2025': 0.0}, 'age_18_64': {'2025': 0.0}, 'age_over_64': {'2025': 0.0}, 'is_older_child': {'2025': 0.0}, 'is_higher_earner': {'2025': 0.0}, 'person_benunit_id': {'2025': 0.0}, 'person_household_id': {'2025': 0.0}, 'role': {'2025': 0.0}, 'person_benunit_role': {'2025': 0.0}, 'person_household_role': {'2025': 0.0}, 'is_disabled_for_benefits': {'2025': 0.0}, 'is_enhanced_disabled_for_benefits': {'2025': 0.0}, 'is_severely_disabled_for_benefits': {'2025': 0.0}, 'person_state_id': {'2025': 0.0}, 'person_state_role': {'2025': 0.0}, 'is_blind': {'2025': 0.0}, 'is_carer_for_benefits': {'2025': 0.0}, 'personal_rent': {'2025': 0.0}, 'weekly_childcare_expenses': {'2025': 0.0}, 'earned_income': {'2025': 0.0}, 'market_income': {'2025': 0.0}, 'hours_worked': {'2025': 0.0}, 'in_work': {'2025': 0.0}, 'weekly_hours': {'2025': 0.0}, 'employment_status': {'2025': 0.0}, 'capital_income': {'2025': 0.0}, 'base_net_income': {'2025': 0.0}, 'is_apprentice': {'2025': 0.0}, 'minimum_wage_category': {'2025': 0.0}, 'minimum_wage': {'2025': 0.0}, 'income_decile': {'2025': 0.0}, 'household_statutory_maternity_pay': {'2025': 0.0}, 'household_statutory_paternity_pay': {'2025': 0.0}, 'household_statutory_sick_pay': {'2025': 0.0}, 'capital_gains': {'2025': 0.0}, 'is_QYP': {'2025': 0.0}, 'is_child_or_QYP': {'2025': 0.0}, 'employment_benefits': {'2025': 0.0}, 'relative_income_change': {'2025': 0.019470373}, 'relative_wage_change': {'2025': 0.0}, 'income_elasticity_lsr': {'2025': 0.0}, 'substitution_elasticity_lsr': {'2025': 0.0}, 'employment_income_behavioral_response': {'2025': 0.0}, 'income_support_reported': {'2025': 0.0}, 'attendance_allowance': {'2025': 0.0}, 'attendance_allowance_reported': {'2025': 0.0}, 'aa_category': {'2025': 0.0}, 'esa_income_reported': {'2025': 0.0}, 'iidb': {'2025': 0.0}, 'iidb_reported': {'2025': 0.0}, 'jsa_contrib': {'2025': 0.0}, 'jsa_contrib_reported': {'2025': 0.0}, 'maternity_allowance_reported': {'2025': 0.0}, 'maternity_allowance': {'2025': 0.0}, 'ssmg_reported': {'2025': 0.0}, 'ssmg': {'2025': 0.0}, 'council_tax_benefit_reported': {'2025': 0.0}, 'working_tax_credit_reported': {'2025': 0.0}, 'child_tax_credit_reported': {'2025': 0.0}, 'is_CTC_child_limit_exempt': {'2025': 0.0}, 'is_child_for_CTC': {'2025': 0.0}, 'jsa_income_reported': {'2025': 0.0}, 'bsp': {'2025': 0.0}, 'bsp_reported': {'2025': 0.0}, 'incapacity_benefit': {'2025': 0.0}, 'incapacity_benefit_reported': {'2025': 0.0}, 'sda': {'2025': 0.0}, 'sda_reported': {'2025': 0.0}, 'carers_allowance': {'2025': 0.0}, 'care_hours': {'2025': 0.0}, 'carers_allowance_reported': {'2025': 0.0}, 'armed_forces_independence_payment': {'2025': 0.0}, 'esa_contrib': {'2025': 0.0}, 'esa_contrib_reported': {'2025': 0.0}, 'esa': {'2025': 0.0}, 'afcs': {'2025': 0.0}, 'afcs_reported': {'2025': 0.0}, 'student_loans': {'2025': 0.0}, 'adult_ema': {'2025': 0.0}, 'child_ema': {'2025': 0.0}, 'access_fund': {'2025': 0.0}, 'education_grants': {'2025': 0.0}, 'student_payments': {'2025': 0.0}, 'state_pension_age': {'2025': 0.0}, 'is_SP_age': {'2025': 0.0}, 'state_pension_type': {'2025': 0.0}, 'basic_state_pension': {'2025': 0.0}, 'additional_state_pension': {'2025': 0.0}, 'new_state_pension': {'2025': 0.0}, 'state_pension_reported': {'2025': 0.0}, 'winter_fuel_allowance_reported': {'2025': 0.0}, 'dla_m_reported': {'2025': 0.0}, 'dla_m': {'2025': 0.0}, 'dla_sc_reported': {'2025': 0.0}, 'dla_sc': {'2025': 0.0}, 'dla_sc_middle_plus': {'2025': 0.0}, 'receives_highest_dla_sc': {'2025': 0.0}, 'dla': {'2025': 0.0}, 'housing_benefit_reported': {'2025': 0.0}, 'household_benefits_individual_non_dep_deduction': {'2025': 0.0}, 'housing_benefit_individual_non_dep_deduction_eligible': {'2025': 0.0}, 'universal_credit_reported': {'2025': 0.0}, 'uc_is_child_born_before_child_limit': {'2025': 0.0}, 'uc_individual_child_element': {'2025': 0.0}, 'uc_individual_disabled_child_element': {'2025': 0.0}, 'uc_individual_severely_disabled_child_element': {'2025': 0.0}, 'uc_is_in_startup_period': {'2025': 0.0}, 'uc_minimum_income_floor': {'2025': 0.0}, 'uc_mif_applies': {'2025': 0.0}, 'uc_mif_capped_earned_income': {'2025': 0.0}, 'uc_limited_capability_for_WRA': {'2025': 0.0}, 'uc_individual_non_dep_deduction_eligible': {'2025': 0.0}, 'uc_individual_non_dep_deduction': {'2025': 0.0}, 'uc_non_dep_deduction_exempt': {'2025': 0.0}, 'pip_m_reported': {'2025': 0.0}, 'pip_m': {'2025': 0.0}, 'pip_dl_reported': {'2025': 0.0}, 'pip_dl': {'2025': 0.0}, 'receives_enhanced_pip_dl': {'2025': 0.0}, 'pip': {'2025': 0.0}, 'pension_credit_reported': {'2025': 0.0}, 'tax': {'2025': -486.0}, 'tax_reported': {'2025': 0.0}, 'tax_modelling': {'2025': -486.0}, 'child_benefit_reported': {'2025': 0.0}, 'child_benefit_respective_amount': {'2025': 0.0}, 'relative_capital_gains_mtr_change': {'2025': 0.0}, 'capital_gains_elasticity': {'2025': 0.0}, 'capital_gains_behavioural_response': {'2025': 0.0}, 'capital_gains_before_response': {'2025': 0.0}, 'adult_index_cg': {'2025': 0.0}, 'marginal_tax_rate_on_capital_gains': {'2025': 0.0}, 'capital_gains_tax': {'2025': 0.0}, 'ni_employee': {'2025': 0.0}, 'national_insurance': {'2025': 0.0}, 'ni_employer': {'2025': 0.0}, 'ni_self_employed': {'2025': 0.0}, 'total_national_insurance': {'2025': 0.0}, 'ni_class_4_maximum': {'2025': 0.0}, 'ni_class_4': {'2025': 0.0}, 'ni_class_4_main': {'2025': 0.0}, 'ni_class_3': {'2025': 0.0}, 'ni_class_2': {'2025': 0.0}, 'ni_class_1_employee_primary': {'2025': 0.0}, 'ni_class_1_income': {'2025': 0.0}, 'ni_class_1_employee': {'2025': 0.0}, 'ni_class_1_employee_additional': {'2025': 0.0}, 'ni_liable': {'2025': 0.0}, 'ni_class_1_employer': {'2025': 0.0}, 'other_tax_credits': {'2025': 0.0}, 'earned_income_tax': {'2025': -486.0}, 'total_income': {'2025': 0.0}, 'income_tax': {'2025': -486.0}, 'taxed_income': {'2025': -2430.0}, 'adjusted_net_income': {'2025': 0.0}, 'total_pension_income': {'2025': 0.0}, 'social_security_income': {'2025': 0.0}, 'income_tax_pre_charges': {'2025': -486.0}, 'personal_allowance': {'2025': 2430.0}, 'blind_persons_allowance': {'2025': 0.0}, 'married_couples_allowance': {'2025': 0.0}, 'married_couples_allowance_deduction': {'2025': 0.0}, 'capped_mcad': {'2025': 0.0}, 'pension_annual_allowance': {'2025': 0.0}, 'trading_allowance': {'2025': 0.0}, 'trading_allowance_deduction': {'2025': 0.0}, 'property_allowance': {'2025': 0.0}, 'property_allowance_deduction': {'2025': 0.0}, 'savings_allowance': {'2025': 0.0}, 'dividend_allowance': {'2025': 0.0}, 'gift_aid': {'2025': 0.0}, 'covenanted_payments': {'2025': 0.0}, 'charitable_investment_gifts': {'2025': 0.0}, 'other_deductions': {'2025': 0.0}, 'allowances': {'2025': 2430.0}, 'unused_personal_allowance': {'2025': 0.0}, 'meets_marriage_allowance_income_conditions': {'2025': 0.0}, 'partners_unused_personal_allowance': {'2025': 0.0}, 'marriage_allowance': {'2025': 0.0}, 'received_allowances': {'2025': 2430.0}, 'received_allowances_savings_income': {'2025': 0.0}, 'received_allowances_dividend_income': {'2025': 0.0}, 'received_allowances_earned_income': {'2025': 2430.0}, 'savings_income_tax': {'2025': 0.0}, 'dividend_income_tax': {'2025': 0.0}, 'loss_relief': {'2025': 0.0}, 'capital_allowances': {'2025': 0.0}, 'deficiency_relief': {'2025': 0.0}, 'employment_deductions': {'2025': 0.0}, 'employment_expenses': {'2025': 0.0}, 'CB_HITC': {'2025': 0.0}, 'higher_rate_earned_income': {'2025': 0.0}, 'add_rate_earned_income': {'2025': 0.0}, 'earned_taxable_income': {'2025': -2430.0}, 'basic_rate_earned_income': {'2025': -2430.0}, 'taxable_pension_income': {'2025': 0.0}, 'taxable_miscellaneous_income': {'2025': 0.0}, 'taxed_dividend_income': {'2025': 0.0}, 'taxable_dividend_income': {'2025': 0.0}, 'taxable_social_security_income': {'2025': 0.0}, 'taxable_employment_income': {'2025': 0.0}, 'trading_loss': {'2025': 0.0}, 'taxable_self_employment_income': {'2025': 0.0}, 'taxable_property_income': {'2025': 0.0}, 'individual_savings_account_interest_income': {'2025': 0.0}, 'taxable_savings_interest_income': {'2025': 0.0}, 'tax_free_savings_income': {'2025': 0.0}, 'higher_rate_earned_income_tax': {'2025': 0.0}, 'add_rate_earned_income_tax': {'2025': 0.0}, 'tax_band': {'2025': 0.0}, 'basic_rate_earned_income_tax': {'2025': -486.0}, 'basic_rate_savings_income_pre_starter': {'2025': 0.0}, 'taxed_savings_income': {'2025': 0.0}, 'higher_rate_savings_income': {'2025': 0.0}, 'savings_starter_rate_income': {'2025': 0.0}, 'add_rate_savings_income': {'2025': 0.0}, 'basic_rate_savings_income': {'2025': 0.0}, 'personal_pension_contributions_tax': {'2025': 0.0}, 'pension_contributions_relief': {'2025': 0.0}, 'pension_contributions': {'2025': 0.0}, 'statutory_maternity_pay': {'2025': 0.0}, 'statutory_sick_pay': {'2025': 0.0}, 'pays_scottish_income_tax': {'2025': 0.0}}}})" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from policyengine import Simulation\n", + "\n", + "sim = Simulation({\n", + " \"scope\": \"household\", # Required for this\n", + " \"country\": \"uk\", # or \"us\"\n", + " \"time_period\": 2025,\n", + " \"data\": { # Required for this\n", + " \"people\": {\n", + " \"person\": {\n", + " \"age\": {\n", + " \"2025\": 30,\n", + " },\n", + " \"employment_income\": {\n", + " \"2025\": 30_000,\n", + " },\n", + " }\n", + " }\n", + " },\n", + " \"reform\": {\n", + " \"gov.hmrc.income_tax.allowances.personal_allowance.amount\": 15_000,\n", + " }\n", + "})\n", + "\n", + "sim.calculate()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Output schema\n", + "\n", + "`calculate_household_comparison` or `calculate` (when `scope=household` and `reform is not None`) return the following schema." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'properties': {'full_household_baseline': {'additionalProperties': {'anyOf': [{'additionalProperties': {'additionalProperties': {'additionalProperties': {'anyOf': [{'type': 'number'},\n", + " {'type': 'string'},\n", + " {'type': 'boolean'},\n", + " {'items': {}, 'type': 'array'},\n", + " {'type': 'null'}]},\n", + " 'type': 'object'},\n", + " 'type': 'object'},\n", + " 'type': 'object'},\n", + " {'items': {'items': {'additionalProperties': {'anyOf': [{'type': 'string'},\n", + " {'type': 'integer'}]},\n", + " 'type': 'object'},\n", + " 'type': 'array'},\n", + " 'type': 'array'}]},\n", + " 'title': 'Full Household Baseline',\n", + " 'type': 'object'},\n", + " 'full_household_reform': {'additionalProperties': {'anyOf': [{'additionalProperties': {'additionalProperties': {'additionalProperties': {'anyOf': [{'type': 'number'},\n", + " {'type': 'string'},\n", + " {'type': 'boolean'},\n", + " {'items': {}, 'type': 'array'},\n", + " {'type': 'null'}]},\n", + " 'type': 'object'},\n", + " 'type': 'object'},\n", + " 'type': 'object'},\n", + " {'items': {'items': {'additionalProperties': {'anyOf': [{'type': 'string'},\n", + " {'type': 'integer'}]},\n", + " 'type': 'object'},\n", + " 'type': 'array'},\n", + " 'type': 'array'}]},\n", + " 'title': 'Full Household Reform',\n", + " 'type': 'object'},\n", + " 'change': {'additionalProperties': {'anyOf': [{'additionalProperties': {'additionalProperties': {'additionalProperties': {'anyOf': [{'type': 'number'},\n", + " {'type': 'string'},\n", + " {'type': 'boolean'},\n", + " {'items': {}, 'type': 'array'},\n", + " {'type': 'null'}]},\n", + " 'type': 'object'},\n", + " 'type': 'object'},\n", + " 'type': 'object'},\n", + " {'items': {'items': {'additionalProperties': {'anyOf': [{'type': 'string'},\n", + " {'type': 'integer'}]},\n", + " 'type': 'object'},\n", + " 'type': 'array'},\n", + " 'type': 'array'}]},\n", + " 'title': 'Change',\n", + " 'type': 'object'}},\n", + " 'required': ['full_household_baseline', 'full_household_reform', 'change'],\n", + " 'title': 'HouseholdComparison',\n", + " 'type': 'object'}" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from policyengine.outputs.household.comparison.calculate_household_comparison import HouseholdComparison\n", + "\n", + "HouseholdComparison.model_json_schema()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/reference/calculate_single_economy.ipynb b/docs/reference/calculate_single_economy.ipynb new file mode 100644 index 00000000..0966e8ee --- /dev/null +++ b/docs/reference/calculate_single_economy.ipynb @@ -0,0 +1,157 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Simulate outcomes for a large population\n", + "\n", + "Use `Simulation.calculate_single_economy()` to use PolicyEngine's tax-benefit model to compute taxes, benefits and other household properties for a large dataset (usually representing a country). This notebook demonstrates how to use this function." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "SingleEconomy(fiscal=FiscalSummary(tax_revenue=658911285719.5891, federal_tax=658911285719.5891, federal_balance=309089098855.4849, state_tax=0.0, government_spending=349822186864.1042, tax_benefit_programs={'income_tax': 333376287037.05945, 'national_insurance': 52985626776.773834, 'ni_employer': 126330649370.35953, 'vat': 211671832822.39133, 'council_tax': 49007055050.00724, 'fuel_duty': 26506672341.204205, 'tax_credits': -34929879.49872104, 'universal_credit': -73459549194.97665, 'child_benefit': -14311471487.935827, 'state_pension': -132795868621.44594, 'pension_credit': -6252358021.417119}, household_net_income=1566028514855.0789), inequality=InequalitySummary(gini=0.36255397405553097, top_10_share=0.3260927004295773, top_1_share=0.13145609415091833), poverty=[PovertyRateMetric(age_group='child', racial_group='all', gender='male', relative=True, poverty_rate='regular', value=0.0937829241156578), PovertyRateMetric(age_group='child', racial_group='all', gender='male', relative=True, poverty_rate='deep', value=0.006947669200599194), PovertyRateMetric(age_group='child', racial_group='all', gender='male', relative=False, poverty_rate='regular', value=770371.125), PovertyRateMetric(age_group='child', racial_group='all', gender='male', relative=False, poverty_rate='deep', value=57070.984375), PovertyRateMetric(age_group='child', racial_group='all', gender='female', relative=True, poverty_rate='regular', value=0.08119998127222061), PovertyRateMetric(age_group='child', racial_group='all', gender='female', relative=True, poverty_rate='deep', value=0.005070670507848263), PovertyRateMetric(age_group='child', racial_group='all', gender='female', relative=False, poverty_rate='regular', value=866217.375), PovertyRateMetric(age_group='child', racial_group='all', gender='female', relative=False, poverty_rate='deep', value=54092.4140625), PovertyRateMetric(age_group='child', racial_group='all', gender='all', relative=True, poverty_rate='regular', value=0.0866740345954895), PovertyRateMetric(age_group='child', racial_group='all', gender='all', relative=True, poverty_rate='deep', value=0.005887233652174473), PovertyRateMetric(age_group='child', racial_group='all', gender='all', relative=False, poverty_rate='regular', value=1636588.5), PovertyRateMetric(age_group='child', racial_group='all', gender='all', relative=False, poverty_rate='deep', value=111163.3828125), PovertyRateMetric(age_group='working_age', racial_group='all', gender='male', relative=True, poverty_rate='regular', value=0.09058031439781189), PovertyRateMetric(age_group='working_age', racial_group='all', gender='male', relative=True, poverty_rate='deep', value=0.0320294052362442), PovertyRateMetric(age_group='working_age', racial_group='all', gender='male', relative=False, poverty_rate='regular', value=2207394.25), PovertyRateMetric(age_group='working_age', racial_group='all', gender='male', relative=False, poverty_rate='deep', value=780539.625), PovertyRateMetric(age_group='working_age', racial_group='all', gender='female', relative=True, poverty_rate='regular', value=0.06885619461536407), PovertyRateMetric(age_group='working_age', racial_group='all', gender='female', relative=True, poverty_rate='deep', value=0.006544755306094885), PovertyRateMetric(age_group='working_age', racial_group='all', gender='female', relative=False, poverty_rate='regular', value=1406585.625), PovertyRateMetric(age_group='working_age', racial_group='all', gender='female', relative=False, poverty_rate='deep', value=133695.4375), PovertyRateMetric(age_group='working_age', racial_group='all', gender='all', relative=True, poverty_rate='regular', value=0.08067396283149719), PovertyRateMetric(age_group='working_age', racial_group='all', gender='all', relative=True, poverty_rate='deep', value=0.02040824294090271), PovertyRateMetric(age_group='working_age', racial_group='all', gender='all', relative=False, poverty_rate='regular', value=3613979.5), PovertyRateMetric(age_group='working_age', racial_group='all', gender='all', relative=False, poverty_rate='deep', value=914235.1875), PovertyRateMetric(age_group='senior', racial_group='all', gender='male', relative=True, poverty_rate='regular', value=0.019906071946024895), PovertyRateMetric(age_group='senior', racial_group='all', gender='male', relative=True, poverty_rate='deep', value=0.0001492029696237296), PovertyRateMetric(age_group='senior', racial_group='all', gender='male', relative=False, poverty_rate='regular', value=120630.84375), PovertyRateMetric(age_group='senior', racial_group='all', gender='male', relative=False, poverty_rate='deep', value=904.1703491210938), PovertyRateMetric(age_group='senior', racial_group='all', gender='female', relative=True, poverty_rate='regular', value=0.04476610943675041), PovertyRateMetric(age_group='senior', racial_group='all', gender='female', relative=True, poverty_rate='deep', value=0.0012297447538003325), PovertyRateMetric(age_group='senior', racial_group='all', gender='female', relative=False, poverty_rate='regular', value=315600.8125), PovertyRateMetric(age_group='senior', racial_group='all', gender='female', relative=False, poverty_rate='deep', value=8669.693359375), PovertyRateMetric(age_group='senior', racial_group='all', gender='all', relative=True, poverty_rate='regular', value=0.03327473625540733), PovertyRateMetric(age_group='senior', racial_group='all', gender='all', relative=True, poverty_rate='deep', value=0.0007302720914594829), PovertyRateMetric(age_group='senior', racial_group='all', gender='all', relative=False, poverty_rate='regular', value=436231.65625), PovertyRateMetric(age_group='senior', racial_group='all', gender='all', relative=False, poverty_rate='deep', value=9573.8642578125), PovertyRateMetric(age_group='all', racial_group='all', gender='male', relative=True, poverty_rate='regular', value=0.08017819374799728), PovertyRateMetric(age_group='all', racial_group='all', gender='male', relative=True, poverty_rate='deep', value=0.021698515862226486), PovertyRateMetric(age_group='all', racial_group='all', gender='male', relative=False, poverty_rate='regular', value=3098396.25), PovertyRateMetric(age_group='all', racial_group='all', gender='male', relative=False, poverty_rate='deep', value=838514.75), PovertyRateMetric(age_group='all', racial_group='all', gender='female', relative=True, poverty_rate='regular', value=0.06785593926906586), PovertyRateMetric(age_group='all', racial_group='all', gender='female', relative=True, poverty_rate='deep', value=0.005150204990059137), PovertyRateMetric(age_group='all', racial_group='all', gender='female', relative=False, poverty_rate='regular', value=2588403.75), PovertyRateMetric(age_group='all', racial_group='all', gender='female', relative=False, poverty_rate='deep', value=196457.53125), PovertyRateMetric(age_group='all', racial_group='all', gender='all', relative=True, poverty_rate='regular', value=0.07405701279640198), PovertyRateMetric(age_group='all', racial_group='all', gender='all', relative=True, poverty_rate='deep', value=0.013478054665029049), PovertyRateMetric(age_group='all', racial_group='all', gender='all', relative=False, poverty_rate='regular', value=5686797.5), PovertyRateMetric(age_group='all', racial_group='all', gender='all', relative=False, poverty_rate='deep', value=1034972.5)])" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from policyengine import Simulation\n", + "\n", + "sim = Simulation({\n", + " \"scope\": \"macro\", # Required for this\n", + " \"country\": \"uk\", # or \"us\"\n", + " \"time_period\": 2025,\n", + "})\n", + "\n", + "sim.calculate()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Output schema\n", + "\n", + "`calculate_single_economy` or `calculate` (when `scope=macro` and `reform=None`) return the following schema." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'$defs': {'FiscalSummary': {'properties': {'tax_revenue': {'title': 'Tax Revenue',\n", + " 'type': 'number'},\n", + " 'federal_tax': {'title': 'Federal Tax', 'type': 'number'},\n", + " 'federal_balance': {'title': 'Federal Balance', 'type': 'number'},\n", + " 'state_tax': {'title': 'State Tax', 'type': 'number'},\n", + " 'government_spending': {'title': 'Government Spending', 'type': 'number'},\n", + " 'tax_benefit_programs': {'additionalProperties': {'type': 'number'},\n", + " 'title': 'Tax Benefit Programs',\n", + " 'type': 'object'},\n", + " 'household_net_income': {'title': 'Household Net Income',\n", + " 'type': 'number'}},\n", + " 'required': ['tax_revenue',\n", + " 'federal_tax',\n", + " 'federal_balance',\n", + " 'state_tax',\n", + " 'government_spending',\n", + " 'tax_benefit_programs',\n", + " 'household_net_income'],\n", + " 'title': 'FiscalSummary',\n", + " 'type': 'object'},\n", + " 'InequalitySummary': {'properties': {'gini': {'title': 'Gini',\n", + " 'type': 'number'},\n", + " 'top_10_share': {'title': 'Top 10 Share', 'type': 'number'},\n", + " 'top_1_share': {'title': 'Top 1 Share', 'type': 'number'}},\n", + " 'required': ['gini', 'top_10_share', 'top_1_share'],\n", + " 'title': 'InequalitySummary',\n", + " 'type': 'object'},\n", + " 'PovertyRateMetric': {'properties': {'age_group': {'enum': ['child',\n", + " 'working_age',\n", + " 'senior',\n", + " 'all'],\n", + " 'title': 'Age Group',\n", + " 'type': 'string'},\n", + " 'racial_group': {'enum': ['white', 'black', 'hispanic', 'other', 'all'],\n", + " 'title': 'Racial Group',\n", + " 'type': 'string'},\n", + " 'gender': {'enum': ['male', 'female', 'all'],\n", + " 'title': 'Gender',\n", + " 'type': 'string'},\n", + " 'relative': {'title': 'Relative', 'type': 'boolean'},\n", + " 'poverty_rate': {'enum': ['regular',\n", + " 'deep',\n", + " 'uk_hbai_bhc',\n", + " 'uk_hbai_bhc_half',\n", + " 'us_spm',\n", + " 'us_spm_half'],\n", + " 'title': 'Poverty Rate',\n", + " 'type': 'string'},\n", + " 'value': {'title': 'Value', 'type': 'number'}},\n", + " 'required': ['age_group',\n", + " 'racial_group',\n", + " 'gender',\n", + " 'relative',\n", + " 'poverty_rate',\n", + " 'value'],\n", + " 'title': 'PovertyRateMetric',\n", + " 'type': 'object'}},\n", + " 'properties': {'fiscal': {'$ref': '#/$defs/FiscalSummary'},\n", + " 'inequality': {'$ref': '#/$defs/InequalitySummary'},\n", + " 'poverty': {'items': {'$ref': '#/$defs/PovertyRateMetric'},\n", + " 'title': 'Poverty',\n", + " 'type': 'array'}},\n", + " 'required': ['fiscal', 'inequality', 'poverty'],\n", + " 'title': 'SingleEconomy',\n", + " 'type': 'object'}" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from policyengine.outputs.macro.single.calculate_single_economy import SingleEconomy\n", + "\n", + "SingleEconomy.model_json_schema()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/reference/calculate_single_household.ipynb b/docs/reference/calculate_single_household.ipynb new file mode 100644 index 00000000..7801a627 --- /dev/null +++ b/docs/reference/calculate_single_household.ipynb @@ -0,0 +1,123 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Simulate outcomes for specific households\n", + "\n", + "Use `Simulation.calculate_single_household()` to use PolicyEngine's tax-benefit model to compute taxes, benefits and other downstream properties of individual households that you specify. This notebook demonstrates how to use this function to simulate outcomes for specific households." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "SingleHousehold(full_household={'people': {'person': {'age': {'2025': 30.0}, 'employment_income': {'2025': 30000.0}, 'employment_income_before_lsr': {'2025': 30000.0}, 'private_pension_income': {'2025': 0.0}, 'pension_income': {'2025': 0.0}, 'state_pension': {'2025': 0.0}, 'self_employment_income': {'2025': 0.0}, 'property_income': {'2025': 0.0}, 'savings_interest_income': {'2025': 0.0}, 'dividend_income': {'2025': 0.0}, 'sublet_income': {'2025': 0.0}, 'miscellaneous_income': {'2025': 0.0}, 'private_transfer_income': {'2025': 0.0}, 'lump_sum_income': {'2025': 0.0}, 'maintenance_income': {'2025': 0.0}, 'other_investment_income': {'2025': 0.0}, 'dla_sc_category': {'2025': 'NONE'}, 'dla_m_category': {'2025': 'NONE'}, 'pip_m_category': {'2025': 'NONE'}, 'pip_dl_category': {'2025': 'NONE'}, 'receives_carers_allowance': {'2025': False}, 'childcare_expenses': {'2025': 0.0}, 'employer_pension_contributions': {'2025': 0.0}, 'employee_pension_contributions': {'2025': 0.0}, 'personal_pension_contributions': {'2025': 0.0}, 'maintenance_expenses': {'2025': 0.0}, 'bi_individual_phaseout': {'2025': 0.0}, 'bi_household_phaseout': {'2025': 0.0}, 'bi_phaseout': {'2025': 0.0}, 'basic_income': {'2025': 0.0}, 'bi_maximum': {'2025': 0.0}, 'attends_private_school': {'2025': False}, 'employer_cost': {'2025': 32884.2}, 'baseline_employer_cost': {'2025': 32884.2}, 'adjusted_employer_cost': {'2025': 32884.2}, 'employer_ni_response_consumer_incidence': {'2025': 0.0}, 'employer_ni_response_capital_incidence': {'2025': 0.0}, 'employer_ni_fixed_employer_cost_change': {'2025': 0.0}, 'marginal_tax_rate': {'2025': 0.27999997}, 'cliff_evaluated': {'2025': True}, 'cliff_gap': {'2025': 0.0}, 'is_on_cliff': {'2025': False}, 'person_id': {'2025': 0.0}, 'people': {'2025': 1.0}, 'raw_person_weight': {'2025': 1.0}, 'person_weight': {'2025': 1.0}, 'adult_index': {'2025': 1.0}, 'birth_year': {'2025': 1995.0}, 'over_16': {'2025': True}, 'is_adult': {'2025': True}, 'is_child': {'2025': False}, 'child_index': {'2025': -1.0}, 'is_eldest_child': {'2025': True}, 'is_benunit_eldest_child': {'2025': False}, 'marital_status': {'2025': 'SINGLE'}, 'current_education': {'2025': 'NOT_IN_EDUCATION'}, 'highest_education': {'2025': 'UPPER_SECONDARY'}, 'in_FE': {'2025': False}, 'in_HE': {'2025': False}, 'gender': {'2025': 'MALE'}, 'is_male': {'2025': True}, 'is_female': {'2025': False}, 'is_household_head': {'2025': True}, 'is_benunit_head': {'2025': True}, 'in_social_housing': {'2025': False}, 'is_WA_adult': {'2025': True}, 'is_young_child': {'2025': False}, 'age_under_18': {'2025': False}, 'age_18_64': {'2025': True}, 'age_over_64': {'2025': False}, 'is_older_child': {'2025': False}, 'is_higher_earner': {'2025': True}, 'person_benunit_id': {'2025': 0.0}, 'person_household_id': {'2025': 0.0}, 'role': {'2025': ''}, 'person_benunit_role': {'2025': ''}, 'person_household_role': {'2025': ''}, 'is_disabled_for_benefits': {'2025': False}, 'is_enhanced_disabled_for_benefits': {'2025': False}, 'is_severely_disabled_for_benefits': {'2025': False}, 'person_state_id': {'2025': 0.0}, 'person_state_role': {'2025': ''}, 'is_blind': {'2025': False}, 'is_carer_for_benefits': {'2025': False}, 'personal_rent': {'2025': 0.0}, 'weekly_childcare_expenses': {'2025': 0.0}, 'earned_income': {'2025': 30000.0}, 'market_income': {'2025': 30000.0}, 'hours_worked': {'2025': 0.0}, 'in_work': {'2025': True}, 'weekly_hours': {'2025': 0.0}, 'employment_status': {'2025': 'UNEMPLOYED'}, 'capital_income': {'2025': 0.0}, 'base_net_income': {'2025': 0.0}, 'is_apprentice': {'2025': False}, 'minimum_wage_category': {'2025': 'OVER_24'}, 'minimum_wage': {'2025': 9.5}, 'income_decile': {'2025': 10.0}, 'household_statutory_maternity_pay': {'2025': 0.0}, 'household_statutory_paternity_pay': {'2025': 0.0}, 'household_statutory_sick_pay': {'2025': 0.0}, 'capital_gains': {'2025': 0.0}, 'is_QYP': {'2025': False}, 'is_child_or_QYP': {'2025': False}, 'employment_benefits': {'2025': 0.0}, 'relative_income_change': {'2025': 0.0}, 'relative_wage_change': {'2025': 0.0}, 'income_elasticity_lsr': {'2025': 0.0}, 'substitution_elasticity_lsr': {'2025': 0.0}, 'employment_income_behavioral_response': {'2025': 0.0}, 'income_support_reported': {'2025': 0.0}, 'attendance_allowance': {'2025': 0.0}, 'attendance_allowance_reported': {'2025': 0.0}, 'aa_category': {'2025': 'NONE'}, 'esa_income_reported': {'2025': 0.0}, 'iidb': {'2025': 0.0}, 'iidb_reported': {'2025': 0.0}, 'jsa_contrib': {'2025': 0.0}, 'jsa_contrib_reported': {'2025': 0.0}, 'maternity_allowance_reported': {'2025': 0.0}, 'maternity_allowance': {'2025': 0.0}, 'ssmg_reported': {'2025': 0.0}, 'ssmg': {'2025': 0.0}, 'council_tax_benefit_reported': {'2025': 0.0}, 'working_tax_credit_reported': {'2025': 0.0}, 'child_tax_credit_reported': {'2025': 0.0}, 'is_CTC_child_limit_exempt': {'2025': True}, 'is_child_for_CTC': {'2025': False}, 'jsa_income_reported': {'2025': 0.0}, 'bsp': {'2025': 0.0}, 'bsp_reported': {'2025': 0.0}, 'incapacity_benefit': {'2025': 0.0}, 'incapacity_benefit_reported': {'2025': 0.0}, 'sda': {'2025': 0.0}, 'sda_reported': {'2025': 0.0}, 'carers_allowance': {'2025': 0.0}, 'care_hours': {'2025': 0.0}, 'carers_allowance_reported': {'2025': 0.0}, 'armed_forces_independence_payment': {'2025': 0.0}, 'esa_contrib': {'2025': 0.0}, 'esa_contrib_reported': {'2025': 0.0}, 'esa': {'2025': 0.0}, 'afcs': {'2025': 0.0}, 'afcs_reported': {'2025': 0.0}, 'student_loans': {'2025': 0.0}, 'adult_ema': {'2025': 0.0}, 'child_ema': {'2025': 0.0}, 'access_fund': {'2025': 0.0}, 'education_grants': {'2025': 0.0}, 'student_payments': {'2025': 0.0}, 'state_pension_age': {'2025': 66.0}, 'is_SP_age': {'2025': False}, 'state_pension_type': {'2025': 'NONE'}, 'basic_state_pension': {'2025': 0.0}, 'additional_state_pension': {'2025': 0.0}, 'new_state_pension': {'2025': 0.0}, 'state_pension_reported': {'2025': 0.0}, 'winter_fuel_allowance_reported': {'2025': 0.0}, 'dla_m_reported': {'2025': 0.0}, 'dla_m': {'2025': 0.0}, 'dla_sc_reported': {'2025': 0.0}, 'dla_sc': {'2025': 0.0}, 'dla_sc_middle_plus': {'2025': False}, 'receives_highest_dla_sc': {'2025': False}, 'dla': {'2025': 0.0}, 'housing_benefit_reported': {'2025': 0.0}, 'household_benefits_individual_non_dep_deduction': {'2025': 6476.6}, 'housing_benefit_individual_non_dep_deduction_eligible': {'2025': True}, 'universal_credit_reported': {'2025': 0.0}, 'uc_is_child_born_before_child_limit': {'2025': False}, 'uc_individual_child_element': {'2025': 0.0}, 'uc_individual_disabled_child_element': {'2025': 0.0}, 'uc_individual_severely_disabled_child_element': {'2025': 0.0}, 'uc_is_in_startup_period': {'2025': False}, 'uc_minimum_income_floor': {'2025': 17290.0}, 'uc_mif_applies': {'2025': False}, 'uc_mif_capped_earned_income': {'2025': 30000.0}, 'uc_limited_capability_for_WRA': {'2025': False}, 'uc_individual_non_dep_deduction_eligible': {'2025': True}, 'uc_individual_non_dep_deduction': {'2025': 1125.3458}, 'uc_non_dep_deduction_exempt': {'2025': False}, 'pip_m_reported': {'2025': 0.0}, 'pip_m': {'2025': 0.0}, 'pip_dl_reported': {'2025': 0.0}, 'pip_dl': {'2025': 0.0}, 'receives_enhanced_pip_dl': {'2025': False}, 'pip': {'2025': 0.0}, 'pension_credit_reported': {'2025': 0.0}, 'tax': {'2025': 4880.4033}, 'tax_reported': {'2025': 0.0}, 'tax_modelling': {'2025': 4880.4033}, 'child_benefit_reported': {'2025': 0.0}, 'child_benefit_respective_amount': {'2025': 0.0}, 'relative_capital_gains_mtr_change': {'2025': 0.0}, 'capital_gains_elasticity': {'2025': 0.0}, 'capital_gains_behavioural_response': {'2025': 0.0}, 'capital_gains_before_response': {'2025': 0.0}, 'adult_index_cg': {'2025': 1.0}, 'marginal_tax_rate_on_capital_gains': {'2025': 0.0}, 'capital_gains_tax': {'2025': 0.0}, 'ni_employee': {'2025': 1394.4033}, 'national_insurance': {'2025': 1394.4033}, 'ni_employer': {'2025': 2884.2}, 'ni_self_employed': {'2025': 0.0}, 'total_national_insurance': {'2025': 4278.6035}, 'ni_class_4_maximum': {'2025': 917.73663}, 'ni_class_4': {'2025': 0.0}, 'ni_class_4_main': {'2025': 0.0}, 'ni_class_3': {'2025': 0.0}, 'ni_class_2': {'2025': 0.0}, 'ni_class_1_employee_primary': {'2025': 1394.4033}, 'ni_class_1_income': {'2025': 30000.0}, 'ni_class_1_employee': {'2025': 1394.4033}, 'ni_class_1_employee_additional': {'2025': 0.0}, 'ni_liable': {'2025': True}, 'ni_class_1_employer': {'2025': 2884.2}, 'other_tax_credits': {'2025': 0.0}, 'earned_income_tax': {'2025': 3486.0}, 'total_income': {'2025': 30000.0}, 'income_tax': {'2025': 3486.0}, 'taxed_income': {'2025': 17430.0}, 'adjusted_net_income': {'2025': 30000.0}, 'total_pension_income': {'2025': 0.0}, 'social_security_income': {'2025': 0.0}, 'income_tax_pre_charges': {'2025': 3486.0}, 'personal_allowance': {'2025': 12570.0}, 'blind_persons_allowance': {'2025': 0.0}, 'married_couples_allowance': {'2025': 0.0}, 'married_couples_allowance_deduction': {'2025': 0.0}, 'capped_mcad': {'2025': 0.0}, 'pension_annual_allowance': {'2025': 40000.0}, 'trading_allowance': {'2025': 1000.0}, 'trading_allowance_deduction': {'2025': 0.0}, 'property_allowance': {'2025': 1000.0}, 'property_allowance_deduction': {'2025': 0.0}, 'savings_allowance': {'2025': 1000.0}, 'dividend_allowance': {'2025': 500.0}, 'gift_aid': {'2025': 0.0}, 'covenanted_payments': {'2025': 0.0}, 'charitable_investment_gifts': {'2025': 0.0}, 'other_deductions': {'2025': 0.0}, 'allowances': {'2025': 12570.0}, 'unused_personal_allowance': {'2025': 0.0}, 'meets_marriage_allowance_income_conditions': {'2025': True}, 'partners_unused_personal_allowance': {'2025': 0.0}, 'marriage_allowance': {'2025': 0.0}, 'received_allowances': {'2025': 12570.0}, 'received_allowances_savings_income': {'2025': 0.0}, 'received_allowances_dividend_income': {'2025': 0.0}, 'received_allowances_earned_income': {'2025': 12570.0}, 'savings_income_tax': {'2025': 0.0}, 'dividend_income_tax': {'2025': 0.0}, 'loss_relief': {'2025': 0.0}, 'capital_allowances': {'2025': 0.0}, 'deficiency_relief': {'2025': 0.0}, 'employment_deductions': {'2025': 0.0}, 'employment_expenses': {'2025': 0.0}, 'CB_HITC': {'2025': 0.0}, 'higher_rate_earned_income': {'2025': 0.0}, 'add_rate_earned_income': {'2025': 0.0}, 'earned_taxable_income': {'2025': 17430.0}, 'basic_rate_earned_income': {'2025': 17430.0}, 'taxable_pension_income': {'2025': 0.0}, 'taxable_miscellaneous_income': {'2025': 0.0}, 'taxed_dividend_income': {'2025': 0.0}, 'taxable_dividend_income': {'2025': 0.0}, 'taxable_social_security_income': {'2025': 0.0}, 'taxable_employment_income': {'2025': 30000.0}, 'trading_loss': {'2025': 0.0}, 'taxable_self_employment_income': {'2025': 0.0}, 'taxable_property_income': {'2025': 0.0}, 'individual_savings_account_interest_income': {'2025': 0.0}, 'taxable_savings_interest_income': {'2025': 0.0}, 'tax_free_savings_income': {'2025': 0.0}, 'higher_rate_earned_income_tax': {'2025': 0.0}, 'add_rate_earned_income_tax': {'2025': 0.0}, 'tax_band': {'2025': 'BASIC'}, 'basic_rate_earned_income_tax': {'2025': 3486.0}, 'basic_rate_savings_income_pre_starter': {'2025': 0.0}, 'taxed_savings_income': {'2025': 0.0}, 'higher_rate_savings_income': {'2025': 0.0}, 'savings_starter_rate_income': {'2025': 0.0}, 'add_rate_savings_income': {'2025': 0.0}, 'basic_rate_savings_income': {'2025': 0.0}, 'personal_pension_contributions_tax': {'2025': 0.0}, 'pension_contributions_relief': {'2025': 0.0}, 'pension_contributions': {'2025': 0.0}, 'statutory_maternity_pay': {'2025': 0.0}, 'statutory_sick_pay': {'2025': 0.0}, 'pays_scottish_income_tax': {'2025': False}}}})" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from policyengine import Simulation\n", + "\n", + "sim = Simulation({\n", + " \"scope\": \"household\", # Required for this\n", + " \"country\": \"uk\", # or \"us\"\n", + " \"time_period\": 2025,\n", + " \"data\": { # Required for this\n", + " \"people\": {\n", + " \"person\": {\n", + " \"age\": {\n", + " \"2025\": 30,\n", + " },\n", + " \"employment_income\": {\n", + " \"2025\": 30_000,\n", + " },\n", + " }\n", + " }\n", + " }\n", + "})\n", + "\n", + "sim.calculate()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Output schema\n", + "\n", + "`calculate_single_household` or `calculate` (when `scope=household` and `reform=None`) return the following schema." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'description': 'Statistics for a single household scenario.',\n", + " 'properties': {'full_household': {'additionalProperties': {'anyOf': [{'additionalProperties': {'additionalProperties': {'additionalProperties': {'anyOf': [{'type': 'number'},\n", + " {'type': 'string'},\n", + " {'type': 'boolean'},\n", + " {'items': {}, 'type': 'array'},\n", + " {'type': 'null'}]},\n", + " 'type': 'object'},\n", + " 'type': 'object'},\n", + " 'type': 'object'},\n", + " {'items': {'items': {'additionalProperties': {'anyOf': [{'type': 'string'},\n", + " {'type': 'integer'}]},\n", + " 'type': 'object'},\n", + " 'type': 'array'},\n", + " 'type': 'array'}]},\n", + " 'title': 'Full Household',\n", + " 'type': 'object'}},\n", + " 'required': ['full_household'],\n", + " 'title': 'SingleHousehold',\n", + " 'type': 'object'}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from policyengine.outputs.household.single.calculate_single_household import SingleHousehold\n", + "\n", + "SingleHousehold.model_json_schema()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/reference/create_charts.ipynb b/docs/reference/create_charts.ipynb new file mode 100644 index 00000000..16c0c188 --- /dev/null +++ b/docs/reference/create_charts.ipynb @@ -0,0 +1,7175 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Create charts for an economic comparison\n", + "\n", + "This package also comes with utilities that allow you to create charts from the economy comparison operation. In this notebook, we'll walk through them." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " " + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# First, set up the simulation\n", + "\n", + "from policyengine import Simulation\n", + "from policyengine.outputs.macro.comparison.charts import *\n", + "\n", + "sim = Simulation({\n", + " \"country\": \"uk\",\n", + " \"scope\": \"macro\",\n", + " \"reform\": {\n", + " \"gov.hmrc.income_tax.allowances.personal_allowance.amount\": 10_000,\n", + " },\n", + " \"title\": \"Lowering the personal allowance to £10,000\" # Required for charts\n", + "})\n", + "\n", + "from policyengine.utils.charts import add_fonts\n", + "\n", + "add_fonts() # Load the right font (Roboto Serif) in this notebook" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Budget\n", + "\n", + "The budget chart shows high-level budget changes under the reform." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "decreasing": { + "marker": { + "color": "#616161" + } + }, + "increasing": { + "marker": { + "color": "#2C6496" + } + }, + "measure": [ + "relative", + "relative", + "total" + ], + "text": [ + "£24.2bn", + "£0.7bn", + "£23.5bn" + ], + "textposition": "inside", + "totals": { + "marker": { + "color": "#2C6496" + } + }, + "type": "waterfall", + "x": [ + "Tax revenues", + "Government spending", + "Public sector net worth" + ], + "y": [ + 24.18759785404004, + 0.7363357242798462, + 23.45126212976019 + ] + } + ], + "layout": { + "annotations": [ + { + "showarrow": false, + "text": "Source: PolicyEngine UK tax-benefit microsimulation model (version 2.18.0)", + "x": 0, + "xanchor": "left", + "xref": "paper", + "y": -0.2, + "yanchor": "bottom", + "yref": "paper" + } + ], + "font": { + "color": "black", + "family": "Roboto Serif" + }, + "height": 600, + "images": [ + { + "sizex": 0.15, + "sizey": 0.15, + "source": "https://raw.githubusercontent.com/PolicyEngine/policyengine-app/master/src/images/logos/policyengine/blue.png", + "x": 1.1, + "xanchor": "right", + "xref": "paper", + "y": -0.2, + "yanchor": "bottom", + "yref": "paper" + } + ], + "margin": { + "b": 120, + "l": 120, + "r": 120, + "t": 120 + }, + "modebar": { + "activecolor": "#F4F4F4", + "bgcolor": "#F4F4F4", + "color": "#F4F4F4" + }, + "paper_bgcolor": "#F4F4F4", + "plot_bgcolor": "#F4F4F4", + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "white", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "white", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "#C8D4E3", + "linecolor": "#C8D4E3", + "minorgridcolor": "#C8D4E3", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "#C8D4E3", + "linecolor": "#C8D4E3", + "minorgridcolor": "#C8D4E3", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "white", + "showlakes": true, + "showland": true, + "subunitcolor": "#C8D4E3" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "white", + "polar": { + "angularaxis": { + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "" + }, + "bgcolor": "white", + "radialaxis": { + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + }, + "yaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + }, + "zaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + }, + "baxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + }, + "bgcolor": "white", + "caxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#EBF0F8", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#EBF0F8", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Lowering the personal allowance to £10,000 would raise £23.5bn" + }, + "uniformtext": { + "minsize": 12, + "mode": "hide" + }, + "width": 800, + "xaxis": { + "gridcolor": "#F4F4F4", + "ticksuffix": "", + "title": { + "text": "" + }, + "zerolinecolor": "#F4F4F4" + }, + "yaxis": { + "gridcolor": "#F4F4F4", + "ticksuffix": "", + "title": { + "text": "Budgetary impact (£bn)" + }, + "zerolinecolor": "#616161" + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "create_budget_comparison_chart(sim)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There is also the budget by program chart, which splits out the budgetary impact by program." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "decreasing": { + "marker": { + "color": "#616161" + } + }, + "increasing": { + "marker": { + "color": "#2C6496" + } + }, + "measure": [ + "relative", + "relative", + "relative", + "relative", + "total" + ], + "text": [ + "£24.2bn", + "-£0.4bn", + "-£0.2bn", + "-£1.0bn", + "£23.0bn" + ], + "textposition": "inside", + "totals": { + "marker": { + "color": "#2C6496" + } + }, + "type": "waterfall", + "x": [ + "Income Tax", + "Universal Credit", + "Pension Credit", + "Other", + "Combined" + ], + "y": [ + 24.2, + -0.4, + -0.2, + -1, + 23 + ] + } + ], + "layout": { + "annotations": [ + { + "showarrow": false, + "text": "Source: PolicyEngine UK tax-benefit microsimulation model (version 2.18.0)", + "x": 0, + "xanchor": "left", + "xref": "paper", + "y": -0.2, + "yanchor": "bottom", + "yref": "paper" + } + ], + "font": { + "color": "black", + "family": "Roboto Serif" + }, + "height": 600, + "images": [ + { + "sizex": 0.15, + "sizey": 0.15, + "source": "https://raw.githubusercontent.com/PolicyEngine/policyengine-app/master/src/images/logos/policyengine/blue.png", + "x": 1.1, + "xanchor": "right", + "xref": "paper", + "y": -0.2, + "yanchor": "bottom", + "yref": "paper" + } + ], + "margin": { + "b": 120, + "l": 120, + "r": 120, + "t": 120 + }, + "modebar": { + "activecolor": "#F4F4F4", + "bgcolor": "#F4F4F4", + "color": "#F4F4F4" + }, + "paper_bgcolor": "#F4F4F4", + "plot_bgcolor": "#F4F4F4", + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "white", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "white", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "#C8D4E3", + "linecolor": "#C8D4E3", + "minorgridcolor": "#C8D4E3", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "#C8D4E3", + "linecolor": "#C8D4E3", + "minorgridcolor": "#C8D4E3", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "white", + "showlakes": true, + "showland": true, + "subunitcolor": "#C8D4E3" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "white", + "polar": { + "angularaxis": { + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "" + }, + "bgcolor": "white", + "radialaxis": { + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + }, + "yaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + }, + "zaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + }, + "baxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + }, + "bgcolor": "white", + "caxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#EBF0F8", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#EBF0F8", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Lowering the personal allowance to £10,000 would raise £23bn" + }, + "uniformtext": { + "minsize": 12, + "mode": "hide" + }, + "width": 800, + "xaxis": { + "gridcolor": "#F4F4F4", + "ticksuffix": "", + "title": { + "text": "" + }, + "zerolinecolor": "#F4F4F4" + }, + "yaxis": { + "gridcolor": "#F4F4F4", + "ticksuffix": "", + "title": { + "text": "Budgetary impact (bn)" + }, + "zerolinecolor": "#616161" + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "create_budget_program_comparison_chart(sim)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Decile\n", + "\n", + "The decile chart shows the impact of the reform on each decile of the income distribution. You can specify whether this is over income deciles, or wealth deciles, in the UK." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "marker": { + "color": [ + "#616161", + "#616161", + "#616161", + "#616161", + "#616161", + "#616161", + "#616161", + "#616161", + "#616161", + "#616161" + ] + }, + "text": [ + "-1.1%", + "-1.5%", + "-1.7%", + "-1.8%", + "-1.5%", + "-1.9%", + "-2.0%", + "-1.9%", + "-1.8%", + "-0.8%" + ], + "type": "bar", + "x": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "y": [ + -0.010774457133013601, + -0.01452619007920295, + -0.017437944033923014, + -0.018396321126487758, + -0.015306613953115554, + -0.019266000449108846, + -0.019665841659677847, + -0.018543594207703178, + -0.018167225868890278, + -0.007966273529744838 + ] + } + ], + "layout": { + "annotations": [ + { + "showarrow": false, + "text": "Source: PolicyEngine UK tax-benefit microsimulation model (version 2.18.0)", + "x": 0, + "xanchor": "left", + "xref": "paper", + "y": -0.2, + "yanchor": "bottom", + "yref": "paper" + } + ], + "font": { + "color": "black", + "family": "Roboto Serif" + }, + "height": 600, + "images": [ + { + "sizex": 0.15, + "sizey": 0.15, + "source": "https://raw.githubusercontent.com/PolicyEngine/policyengine-app/master/src/images/logos/policyengine/blue.png", + "x": 1.1, + "xanchor": "right", + "xref": "paper", + "y": -0.2, + "yanchor": "bottom", + "yref": "paper" + } + ], + "margin": { + "b": 120, + "l": 120, + "r": 120, + "t": 120 + }, + "modebar": { + "activecolor": "#F4F4F4", + "bgcolor": "#F4F4F4", + "color": "#F4F4F4" + }, + "paper_bgcolor": "#F4F4F4", + "plot_bgcolor": "#F4F4F4", + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "white", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "white", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "#C8D4E3", + "linecolor": "#C8D4E3", + "minorgridcolor": "#C8D4E3", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "#C8D4E3", + "linecolor": "#C8D4E3", + "minorgridcolor": "#C8D4E3", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "white", + "showlakes": true, + "showland": true, + "subunitcolor": "#C8D4E3" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "white", + "polar": { + "angularaxis": { + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "" + }, + "bgcolor": "white", + "radialaxis": { + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + }, + "yaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + }, + "zaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + }, + "baxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + }, + "bgcolor": "white", + "caxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#EBF0F8", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#EBF0F8", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Lowering the personal allowance to £10,000 would decrease the net income of