{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[Rendered Version](http://nbviewer.jupyter.org/github/andersonfrailey/Notebook-Uploads/blob/master/Training%20Doc.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is identical to the [normal training notebook](http://nbviewer.jupyter.org/github/andersonfrailey/Notebook-Uploads/blob/master/Training%20Doc.ipynb), but uses Ernie Tedeschi's weights instead. This approach can be used to use any other weight file." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from taxcalc import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example uses the packaged CPS file. If you were to use the PUF, you would create the records class using\n", "`Records()` or `Records('path to puf')` if the PUF is not in your current working directory." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Load Ernie Tedeschi's weights file.\n", "tedeschi_weights = pd.read_csv('cps_weights_2026.csv')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "You loaded data for 2014.\n", "Tax-Calculator startup automatically extrapolated your data to 2014.\n" ] } ], "source": [ "# Initiate baseline calculator\n", "recs = Records.cps_constructor()\n", "calc = Calculator(records=recs, policy=Policy())\n", "# Replace weights attribute of calc.\n", "calc.records.s006 = tedeschi_weights.s006\n", "# Advance and calculate.\n", "calc.advance_to_year(2018)\n", "calc.calc_all()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "You loaded data for 2014.\n", "Tax-Calculator startup automatically extrapolated your data to 2014.\n" ] } ], "source": [ "# Initiate calculator to apply reforms to\n", "recs_x = Records.cps_constructor()\n", "calc_x = Calculator(records=recs_x, policy=Policy())\n", "# Replace weights attribute of calc_x.\n", "calc_x.records.s006 = tedeschi_weights.s006" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can specify your reforms in a JSON file and, using the `read_json_param_objects` method, create a dictionary containing both policy reforms and behavioral assumptions\n", "\n", "The policy reform and any behavioral assumptions need to be in separate JSON files.\n", "\n", "Here is [more information](https://github.com/open-source-economics/Tax-Calculator/blob/master/taxcalc/reforms/REFORMS.md) on creating reform files." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "{'behavior': {2018: {u'_BE_inc': [-0.25]}},\n", " 'consumption': {2018: {u'_MPC_e19800': [0.2]}},\n", " 'growdiff_baseline': {},\n", " 'growdiff_response': {},\n", " 'policy': {2018: {u'_ID_RealEstate_hc': [0.25],\n", " u'_ID_StateLocalTax_hc': [0.25],\n", " u'_II_rt1': [0.12],\n", " u'_II_rt2': [0.12],\n", " u'_II_rt7': [0.35],\n", " u'_STD': [[12000, 24000, 12000, 18000, 24000]]},\n", " 2019: {u'_ID_RealEstate_hc': [0.5], u'_ID_StateLocalTax_hc': [0.5]},\n", " 2020: {u'_ID_RealEstate_hc': [0.75], u'_ID_StateLocalTax_hc': [0.75]},\n", " 2021: {u'_ID_RealEstate_hc': [1.0], u'_ID_StateLocalTax_hc': [1.0]}}}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "reforms = calc_x.read_json_param_objects('SampleReform.json', 'SampleBehavior.json')\n", "reforms" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternatively, you can specify a policy reform as a dictionary. The only drawback with doing this is you will not be able to use the `reform_documentation()` method to print out the reform description." ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "reform_dict = {\n", " 2018: {\n", " '__ID_RealEstate_hc': [0.25],\n", " '_ID_StateLocalTax_hc': [0.25],\n", " '_II_rt1': [0.12],\n", " '_II_rt2': [0.12],\n", " '_II_rt7': [0.35],\n", " '_STD': [[12000, 24000, 12000, 18000, 24000]]},\n", " 2019: {\n", " '_ID_RealEstate_hc': [0.5],\n", " '_ID_StateLocalTax_hc': [0.5]},\n", " 2020: {\n", " '_ID_RealEstate_hc': [0.75],\n", " '_ID_StateLocalTax_hc': [0.75]},\n", " 2021: {\n", " '_ID_RealEstate_hc': [1.],\n", " '_ID_StateLocalTax_hc': [1.]}\n", "}" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": true }, "outputs": [], "source": [ "calc_x.policy.implement_reform(reforms['policy'])\n", "calc_x.consumption.update_consumption(reforms['consumption'])\n", "calc_x.advance_to_year(2018)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Behavioral response\n", "\n", "A dictionary is also used to implement behavioral reforms. The only difference is you must then pass the baseline and reform calculators into the response method of the behavioral class. This method calculates the change in tax liabilities and then, using the specified elasticities, returns a new calculator object that accounts for any behavioral change." ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "calc_x.behavior.update_behavior(reforms['behavior'])\n", "calc_response = Behavior.response(calc, calc_x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Viewing the results" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from taxcalc.utils import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Analyzing Individual Variables\n", "\n", "Individual variables are attributes of the records class and can therefore be accessed using a simple dot notation" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Combined Liability - Baseline: 2521070511449.64\n", "Combined Liability - Reform: 2408891900213.91\n", "-----------------------------------------------\n", "Difference: -112178611235.73\n" ] } ], "source": [ "baseline = (calc.records.combined * calc.records.s006).sum() # combined is combined tax liability while s006 is weight\n", "reformed = (calc_response.records.combined * calc_response.records.s006).sum()\n", "diff = reformed - baseline\n", "print ('Combined Liability - Baseline: {:0.2f}'.format(baseline))\n", "print ('Combined Liability - Reform: {:>18.2f}'.format(reformed))\n", "print ('-' * 47)\n", "print ('Difference: {:35.2f}'.format(diff))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Diagnostic Table\n", "\n", "Diagnostic tables are the most straight forward methods of evaluation. They simply show aggregate values for a given calculator" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
2018
Returns (#m)169.9
AGI ($b)10,503.8
Itemizers (#m)68.0
Itemized Deduction ($b)1,500.9
Standard Deduction Filers (#m)83.9
Standard Deduction ($b)771.4
Personal Exemption ($b)1,222.6
Taxable Income ($b)7,421.9
Regular Tax ($b)1,369.7
AMT Income ($b)9,664.5
AMT Liability ($b)18.0
AMT Filers (#m)4.2
Tax before Credits ($b)1,387.7
Refundable Credits ($b)76.6
Nonrefundable Credits ($b)32.9
Reform Surtaxes ($b)0.0
Other Taxes ($b)9.3
Ind Income Tax ($b)1,287.5
Payroll Taxes ($b)1,233.6
Combined Liability ($b)2,521.1
With Income Tax <= 0 (#m)72.0
With Combined Tax <= 0 (#m)48.6
\n", "
" ], "text/plain": [ " 2018\n", "Returns (#m) 169.9\n", "AGI ($b) 10,503.8\n", "Itemizers (#m) 68.0\n", "Itemized Deduction ($b) 1,500.9\n", "Standard Deduction Filers (#m) 83.9\n", "Standard Deduction ($b) 771.4\n", "Personal Exemption ($b) 1,222.6\n", "Taxable Income ($b) 7,421.9\n", "Regular Tax ($b) 1,369.7\n", "AMT Income ($b) 9,664.5\n", "AMT Liability ($b) 18.0\n", "AMT Filers (#m) 4.2\n", "Tax before Credits ($b) 1,387.7\n", "Refundable Credits ($b) 76.6\n", "Nonrefundable Credits ($b) 32.9\n", "Reform Surtaxes ($b) 0.0\n", "Other Taxes ($b) 9.3\n", "Ind Income Tax ($b) 1,287.5\n", "Payroll Taxes ($b) 1,233.6\n", "Combined Liability ($b) 2,521.1\n", "With Income Tax <= 0 (#m) 72.0\n", "With Combined Tax <= 0 (#m) 48.6" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "create_diagnostic_table(calc)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
2018
Returns (#m)169.9
AGI ($b)10,477.2
Itemizers (#m)29.0
Itemized Deduction ($b)808.7
Standard Deduction Filers (#m)122.9
Standard Deduction ($b)2,117.1
Personal Exemption ($b)1,222.6
Taxable Income ($b)7,041.9
Regular Tax ($b)1,260.7
AMT Income ($b)9,980.7
AMT Liability ($b)18.3
AMT Filers (#m)5.5
Tax before Credits ($b)1,279.0
Refundable Credits ($b)81.0
Nonrefundable Credits ($b)28.7
Reform Surtaxes ($b)0.0
Other Taxes ($b)9.3
Ind Income Tax ($b)1,178.6
Payroll Taxes ($b)1,230.3
Combined Liability ($b)2,408.9
With Income Tax <= 0 (#m)79.1
With Combined Tax <= 0 (#m)49.7
\n", "
" ], "text/plain": [ " 2018\n", "Returns (#m) 169.9\n", "AGI ($b) 10,477.2\n", "Itemizers (#m) 29.0\n", "Itemized Deduction ($b) 808.7\n", "Standard Deduction Filers (#m) 122.9\n", "Standard Deduction ($b) 2,117.1\n", "Personal Exemption ($b) 1,222.6\n", "Taxable Income ($b) 7,041.9\n", "Regular Tax ($b) 1,260.7\n", "AMT Income ($b) 9,980.7\n", "AMT Liability ($b) 18.3\n", "AMT Filers (#m) 5.5\n", "Tax before Credits ($b) 1,279.0\n", "Refundable Credits ($b) 81.0\n", "Nonrefundable Credits ($b) 28.7\n", "Reform Surtaxes ($b) 0.0\n", "Other Taxes ($b) 9.3\n", "Ind Income Tax ($b) 1,178.6\n", "Payroll Taxes ($b) 1,230.3\n", "Combined Liability ($b) 2,408.9\n", "With Income Tax <= 0 (#m) 79.1\n", "With Combined Tax <= 0 (#m) 49.7" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "create_diagnostic_table(calc_response)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Distribution Table\n", "\n", "The distribution table shows the same information as the diagnostic table, but broken down by income bin or decile. You can view the results as either the weighted average or the weighted sum in each bin" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
s006c00100num_returns_StandardDedstandardnum_returns_ItemDedc04470c04600c04800taxbcc62100...c09600c05800c07100othertaxesrefundiitaxpayrolltaxcombinedexpanded_incomeaftertax_income
016,989,417-66216,587055,262241-664...010098-9717679-233-312
116,988,2865,11817,81402075,904190135,018...01330755-745663-829,8479,929
216,990,0049,11617,86001,0456,3191,6361538,514...11542901,020-8951,20931417,24516,931
316,989,65617,01817,63202,3357,1515,05753215,624...25349001,193-7502,3271,57725,26223,685
416,989,95526,26917,15703,9107,66710,8261,24423,898...41,24716809211583,6093,76834,40130,633
516,989,24137,91316,37505,9418,09019,2202,29834,325...52,30327904261,5985,1826,78045,96539,185
616,989,68654,72304,84219,6228,49932,3504,20648,877...34,2093940823,7337,41611,14961,85750,708
716,989,48578,65503,383113,9959,34352,1707,54470,468...47,5494960137,04010,75417,79485,68467,890
816,989,613114,89202,039119,74210,53082,67912,939103,702...612,9464490312,49415,86028,354124,25295,898
916,989,497275,2120990131,54410,053232,70151,691259,091...1,03652,72629549053,24625,41178,657290,513211,856
10169,894,84061,82505,46808,8357,88243,6858,06256,885...1068,168194554517,5787,26114,83969,48054,641
118,494,307275,5220832134,42810,319230,08252,892258,274...1,31154,20239421054,58425,80680,390291,849211,459
126,795,859227,30701,113128,42010,529187,26239,191212,227...43639,62721183039,78925,12364,912241,486176,575
131,699,332465,23501,281129,6186,821427,51495,675450,590...2,05797,73162,6490100,37524,584124,958479,898354,940
\n", "

14 rows × 21 columns

\n", "
" ], "text/plain": [ " s006 c00100 num_returns_StandardDed standard \\\n", "0 16,989,417 -662 1 6,587 \n", "1 16,988,286 5,118 1 7,814 \n", "2 16,990,004 9,116 1 7,860 \n", "3 16,989,656 17,018 1 7,632 \n", "4 16,989,955 26,269 1 7,157 \n", "5 16,989,241 37,913 1 6,375 \n", "6 16,989,686 54,723 0 4,842 \n", "7 16,989,485 78,655 0 3,383 \n", "8 16,989,613 114,892 0 2,039 \n", "9 16,989,497 275,212 0 990 \n", "10 169,894,840 61,825 0 5,468 \n", "11 8,494,307 275,522 0 832 \n", "12 6,795,859 227,307 0 1,113 \n", "13 1,699,332 465,235 0 1,281 \n", "\n", " num_returns_ItemDed c04470 c04600 c04800 taxbc c62100 \\\n", "0 0 5 5,262 24 1 -664 \n", "1 0 207 5,904 190 13 5,018 \n", "2 0 1,045 6,319 1,636 153 8,514 \n", "3 0 2,335 7,151 5,057 532 15,624 \n", "4 0 3,910 7,667 10,826 1,244 23,898 \n", "5 0 5,941 8,090 19,220 2,298 34,325 \n", "6 1 9,622 8,499 32,350 4,206 48,877 \n", "7 1 13,995 9,343 52,170 7,544 70,468 \n", "8 1 19,742 10,530 82,679 12,939 103,702 \n", "9 1 31,544 10,053 232,701 51,691 259,091 \n", "10 0 8,835 7,882 43,685 8,062 56,885 \n", "11 1 34,428 10,319 230,082 52,892 258,274 \n", "12 1 28,420 10,529 187,262 39,191 212,227 \n", "13 1 29,618 6,821 427,514 95,675 450,590 \n", "\n", " ... c09600 c05800 c07100 othertaxes refund iitax \\\n", "0 ... 0 1 0 0 98 -97 \n", "1 ... 0 13 3 0 755 -745 \n", "2 ... 1 154 29 0 1,020 -895 \n", "3 ... 2 534 90 0 1,193 -750 \n", "4 ... 4 1,247 168 0 921 158 \n", "5 ... 5 2,303 279 0 426 1,598 \n", "6 ... 3 4,209 394 0 82 3,733 \n", "7 ... 4 7,549 496 0 13 7,040 \n", "8 ... 6 12,946 449 0 3 12,494 \n", "9 ... 1,036 52,726 29 549 0 53,246 \n", "10 ... 106 8,168 194 55 451 7,578 \n", "11 ... 1,311 54,202 39 421 0 54,584 \n", "12 ... 436 39,627 21 183 0 39,789 \n", "13 ... 2,057 97,731 6 2,649 0 100,375 \n", "\n", " payrolltax combined expanded_income aftertax_income \n", "0 176 79 -233 -312 \n", "1 663 -82 9,847 9,929 \n", "2 1,209 314 17,245 16,931 \n", "3 2,327 1,577 25,262 23,685 \n", "4 3,609 3,768 34,401 30,633 \n", "5 5,182 6,780 45,965 39,185 \n", "6 7,416 11,149 61,857 50,708 \n", "7 10,754 17,794 85,684 67,890 \n", "8 15,860 28,354 124,252 95,898 \n", "9 25,411 78,657 290,513 211,856 \n", "10 7,261 14,839 69,480 54,641 \n", "11 25,806 80,390 291,849 211,459 \n", "12 25,123 64,912 241,486 176,575 \n", "13 24,584 124,958 479,898 354,940 \n", "\n", "[14 rows x 21 columns]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "create_distribution_table(calc.records, groupby='weighted_deciles',\n", " income_measure='expanded_income', result_type='weighted_avg')" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
s006c00100num_returns_StandardDedstandardnum_returns_ItemDedc04470c04600c04800taxbcc62100...c09600c05800c07100othertaxesrefundiitaxpayrolltaxcombinedexpanded_incomeaftertax_income
016,989,417-11,240,375,9349,514,456195,449,294,14511,00778,047,07089,401,300,451408,960,59214,266,689-11,276,018,050...014,266,6897,372,90701,657,208,090-1,650,314,3072,997,688,4061,347,374,099-3,954,094,409-5,301,468,508
116,989,09486,942,793,61111,743,649240,153,684,75614,673135,713,300100,269,230,5491,201,206,38138,077,77486,885,674,235...4,712,56842,790,34222,410,102012,832,180,654-12,811,800,41411,264,576,633-1,547,223,780167,252,301,579168,799,525,359
216,989,774154,899,070,04113,250,924253,626,171,467168,2433,168,282,200106,944,558,1405,579,806,223566,732,228152,868,950,679...15,360,182582,092,409110,053,030017,521,776,767-17,049,737,38820,553,723,1493,503,985,761292,470,862,332288,966,876,571
316,988,865288,334,364,83415,143,147269,445,368,496592,63510,883,507,435121,575,274,04147,176,872,7435,306,728,678281,295,598,040...38,174,9705,344,903,648838,128,862021,027,651,163-16,520,876,37739,451,196,24622,930,319,869428,221,707,216405,291,387,347
416,990,013444,704,994,44115,619,359278,594,009,858967,19117,828,474,222130,135,786,463123,629,712,95814,069,465,419433,109,364,110...79,229,50714,148,694,9261,821,035,652016,688,106,892-4,360,447,61761,132,682,38856,772,234,770582,666,670,640525,894,435,870
516,989,624643,435,399,90615,328,972280,060,128,8591,564,25732,581,640,674137,969,239,408247,348,392,31228,248,830,646622,300,542,104...103,822,90228,352,653,5483,302,265,34008,921,296,92416,129,091,28487,988,164,705104,117,255,989778,155,990,660674,038,734,671
616,989,348923,035,628,95014,321,210274,000,321,7762,649,18458,433,658,339144,180,090,735462,442,718,29255,181,760,294885,798,622,478...103,709,69055,285,469,9846,036,857,63402,009,988,08447,238,624,266124,991,931,166172,230,555,4321,046,775,342,352874,544,786,920
716,989,3751,331,578,390,47412,884,653267,245,637,5324,101,80197,598,641,939158,962,857,293811,437,972,310109,124,128,5821,270,123,094,836...175,072,373109,299,200,9558,417,666,6510251,138,665100,630,395,640182,074,955,587282,705,351,2271,450,900,603,1421,168,195,251,915
816,989,6631,945,710,099,59110,317,852229,069,417,8496,669,158178,031,534,165178,899,911,0391,360,972,085,218194,412,683,5011,832,439,223,410...259,401,412194,672,084,9137,696,744,670044,455,337186,930,884,907268,688,455,293455,619,340,1992,104,363,692,6601,648,744,352,461
916,989,6684,669,836,093,1994,760,374108,231,548,64712,228,958409,920,489,156170,736,582,9293,981,710,226,616853,744,329,8964,427,147,745,570...17,472,256,011871,216,585,907492,692,3459,298,398,3063,075,346880,019,216,522431,193,490,1261,311,212,706,6484,929,555,787,7043,618,343,081,056
10169,894,84010,477,236,459,112122,884,5972,395,875,583,38428,967,108808,659,988,5001,339,074,831,0497,041,907,953,6461,260,707,003,7089,980,692,797,412...18,251,739,6161,278,958,743,32328,745,227,1949,298,398,30680,956,877,9211,178,555,036,5141,230,336,863,7002,408,891,900,21411,776,408,863,8789,367,516,963,664
118,494,5492,338,096,734,6992,143,15949,073,255,7266,351,054226,640,121,33187,573,726,7231,975,470,830,260439,047,209,0482,206,705,386,996...10,112,553,208449,159,762,256333,856,4603,570,792,4313,075,346452,393,622,881218,971,323,591671,364,946,4722,476,699,590,1811,805,334,643,709
126,795,5481,542,122,641,6482,159,22749,253,624,5584,636,322144,636,633,23071,579,377,6271,276,754,561,042256,452,495,5141,453,825,299,057...3,682,467,624260,134,963,137148,593,7171,243,327,5140261,229,696,935170,477,790,694431,707,487,6281,638,328,864,4701,206,621,376,842
131,699,571789,616,716,851457,9899,904,668,3641,241,58238,643,734,59511,583,478,578729,484,835,314158,244,625,335766,617,059,518...3,677,235,179161,921,860,51410,242,1684,484,278,3610166,395,896,70641,744,375,842208,140,272,548814,527,333,053606,387,060,505
\n", "

14 rows × 21 columns

\n", "
" ], "text/plain": [ " s006 c00100 num_returns_StandardDed standard \\\n", "0 16,989,417 -11,240,375,934 9,514,456 195,449,294,145 \n", "1 16,989,094 86,942,793,611 11,743,649 240,153,684,756 \n", "2 16,989,774 154,899,070,041 13,250,924 253,626,171,467 \n", "3 16,988,865 288,334,364,834 15,143,147 269,445,368,496 \n", "4 16,990,013 444,704,994,441 15,619,359 278,594,009,858 \n", "5 16,989,624 643,435,399,906 15,328,972 280,060,128,859 \n", "6 16,989,348 923,035,628,950 14,321,210 274,000,321,776 \n", "7 16,989,375 1,331,578,390,474 12,884,653 267,245,637,532 \n", "8 16,989,663 1,945,710,099,591 10,317,852 229,069,417,849 \n", "9 16,989,668 4,669,836,093,199 4,760,374 108,231,548,647 \n", "10 169,894,840 10,477,236,459,112 122,884,597 2,395,875,583,384 \n", "11 8,494,549 2,338,096,734,699 2,143,159 49,073,255,726 \n", "12 6,795,548 1,542,122,641,648 2,159,227 49,253,624,558 \n", "13 1,699,571 789,616,716,851 457,989 9,904,668,364 \n", "\n", " num_returns_ItemDed c04470 c04600 c04800 \\\n", "0 11,007 78,047,070 89,401,300,451 408,960,592 \n", "1 14,673 135,713,300 100,269,230,549 1,201,206,381 \n", "2 168,243 3,168,282,200 106,944,558,140 5,579,806,223 \n", "3 592,635 10,883,507,435 121,575,274,041 47,176,872,743 \n", "4 967,191 17,828,474,222 130,135,786,463 123,629,712,958 \n", "5 1,564,257 32,581,640,674 137,969,239,408 247,348,392,312 \n", "6 2,649,184 58,433,658,339 144,180,090,735 462,442,718,292 \n", "7 4,101,801 97,598,641,939 158,962,857,293 811,437,972,310 \n", "8 6,669,158 178,031,534,165 178,899,911,039 1,360,972,085,218 \n", "9 12,228,958 409,920,489,156 170,736,582,929 3,981,710,226,616 \n", "10 28,967,108 808,659,988,500 1,339,074,831,049 7,041,907,953,646 \n", "11 6,351,054 226,640,121,331 87,573,726,723 1,975,470,830,260 \n", "12 4,636,322 144,636,633,230 71,579,377,627 1,276,754,561,042 \n", "13 1,241,582 38,643,734,595 11,583,478,578 729,484,835,314 \n", "\n", " taxbc c62100 ... c09600 \\\n", "0 14,266,689 -11,276,018,050 ... 0 \n", "1 38,077,774 86,885,674,235 ... 4,712,568 \n", "2 566,732,228 152,868,950,679 ... 15,360,182 \n", "3 5,306,728,678 281,295,598,040 ... 38,174,970 \n", "4 14,069,465,419 433,109,364,110 ... 79,229,507 \n", "5 28,248,830,646 622,300,542,104 ... 103,822,902 \n", "6 55,181,760,294 885,798,622,478 ... 103,709,690 \n", "7 109,124,128,582 1,270,123,094,836 ... 175,072,373 \n", "8 194,412,683,501 1,832,439,223,410 ... 259,401,412 \n", "9 853,744,329,896 4,427,147,745,570 ... 17,472,256,011 \n", "10 1,260,707,003,708 9,980,692,797,412 ... 18,251,739,616 \n", "11 439,047,209,048 2,206,705,386,996 ... 10,112,553,208 \n", "12 256,452,495,514 1,453,825,299,057 ... 3,682,467,624 \n", "13 158,244,625,335 766,617,059,518 ... 3,677,235,179 \n", "\n", " c05800 c07100 othertaxes refund \\\n", "0 14,266,689 7,372,907 0 1,657,208,090 \n", "1 42,790,342 22,410,102 0 12,832,180,654 \n", "2 582,092,409 110,053,030 0 17,521,776,767 \n", "3 5,344,903,648 838,128,862 0 21,027,651,163 \n", "4 14,148,694,926 1,821,035,652 0 16,688,106,892 \n", "5 28,352,653,548 3,302,265,340 0 8,921,296,924 \n", "6 55,285,469,984 6,036,857,634 0 2,009,988,084 \n", "7 109,299,200,955 8,417,666,651 0 251,138,665 \n", "8 194,672,084,913 7,696,744,670 0 44,455,337 \n", "9 871,216,585,907 492,692,345 9,298,398,306 3,075,346 \n", "10 1,278,958,743,323 28,745,227,194 9,298,398,306 80,956,877,921 \n", "11 449,159,762,256 333,856,460 3,570,792,431 3,075,346 \n", "12 260,134,963,137 148,593,717 1,243,327,514 0 \n", "13 161,921,860,514 10,242,168 4,484,278,361 0 \n", "\n", " iitax payrolltax combined expanded_income \\\n", "0 -1,650,314,307 2,997,688,406 1,347,374,099 -3,954,094,409 \n", "1 -12,811,800,414 11,264,576,633 -1,547,223,780 167,252,301,579 \n", "2 -17,049,737,388 20,553,723,149 3,503,985,761 292,470,862,332 \n", "3 -16,520,876,377 39,451,196,246 22,930,319,869 428,221,707,216 \n", "4 -4,360,447,617 61,132,682,388 56,772,234,770 582,666,670,640 \n", "5 16,129,091,284 87,988,164,705 104,117,255,989 778,155,990,660 \n", "6 47,238,624,266 124,991,931,166 172,230,555,432 1,046,775,342,352 \n", "7 100,630,395,640 182,074,955,587 282,705,351,227 1,450,900,603,142 \n", "8 186,930,884,907 268,688,455,293 455,619,340,199 2,104,363,692,660 \n", "9 880,019,216,522 431,193,490,126 1,311,212,706,648 4,929,555,787,704 \n", "10 1,178,555,036,514 1,230,336,863,700 2,408,891,900,214 11,776,408,863,878 \n", "11 452,393,622,881 218,971,323,591 671,364,946,472 2,476,699,590,181 \n", "12 261,229,696,935 170,477,790,694 431,707,487,628 1,638,328,864,470 \n", "13 166,395,896,706 41,744,375,842 208,140,272,548 814,527,333,053 \n", "\n", " aftertax_income \n", "0 -5,301,468,508 \n", "1 168,799,525,359 \n", "2 288,966,876,571 \n", "3 405,291,387,347 \n", "4 525,894,435,870 \n", "5 674,038,734,671 \n", "6 874,544,786,920 \n", "7 1,168,195,251,915 \n", "8 1,648,744,352,461 \n", "9 3,618,343,081,056 \n", "10 9,367,516,963,664 \n", "11 1,805,334,643,709 \n", "12 1,206,621,376,842 \n", "13 606,387,060,505 \n", "\n", "[14 rows x 21 columns]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "create_distribution_table(calc_response.records, groupby='weighted_deciles',\n", " income_measure='expanded_income', result_type='weighted_sum')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Differences Table\n", "\n", "The differences table displays the difference between your baseline and refoms. You can also group the results by decile or income bin." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
counttax_cutperc_cuttax_incperc_incmeantot_changeshare_of_changeperc_aftertaxpc_aftertaxinc
016,989,416.580.000.0077,865.940.460.071,193,396.44-0.000.00-0.00
116,988,285.701,403,423.048.2647,446.980.28-10.58-179,704,079.680.16-0.100.07
216,990,004.055,050,748.7929.7364,533.660.38-121.64-2,066,585,817.151.84-0.790.59
316,989,656.058,009,175.2947.14683,007.704.02-230.20-3,910,998,318.733.49-1.060.80
416,989,954.6610,878,167.4464.03983,313.735.79-433.38-7,363,181,927.976.56-1.511.14
516,989,240.8013,085,117.3277.021,090,948.116.42-664.91-11,296,355,312.2910.07-1.781.34
616,989,686.3814,605,299.4985.971,339,801.247.89-981.44-16,674,384,517.3014.86-2.011.51
716,989,484.5215,353,423.5590.371,400,588.708.24-1,141.77-19,398,072,372.3917.29-1.731.30
816,989,613.4416,093,942.2994.73797,506.374.69-1,541.99-26,197,883,909.7323.35-1.631.22
916,989,497.4811,790,903.2469.401,819,890.7810.71-1,476.95-25,092,638,376.9322.37-0.630.47
10169,894,839.6696,270,200.45nan8,304,903.21nannan-112,178,611,235.74100.00nannan
118,494,172.667,575,883.7689.19770,988.049.08-1,261.50-10,715,437,853.559.55-0.960.72
126,794,896.303,579,115.1552.67574,417.778.45-369.23-2,508,876,592.632.24-0.210.16
131,700,428.52635,904.3337.40474,484.9727.90-6,979.61-11,868,323,930.7510.58-0.640.49
\n", "
" ], "text/plain": [ " count tax_cut perc_cut tax_inc perc_inc mean \\\n", "0 16,989,416.58 0.00 0.00 77,865.94 0.46 0.07 \n", "1 16,988,285.70 1,403,423.04 8.26 47,446.98 0.28 -10.58 \n", "2 16,990,004.05 5,050,748.79 29.73 64,533.66 0.38 -121.64 \n", "3 16,989,656.05 8,009,175.29 47.14 683,007.70 4.02 -230.20 \n", "4 16,989,954.66 10,878,167.44 64.03 983,313.73 5.79 -433.38 \n", "5 16,989,240.80 13,085,117.32 77.02 1,090,948.11 6.42 -664.91 \n", "6 16,989,686.38 14,605,299.49 85.97 1,339,801.24 7.89 -981.44 \n", "7 16,989,484.52 15,353,423.55 90.37 1,400,588.70 8.24 -1,141.77 \n", "8 16,989,613.44 16,093,942.29 94.73 797,506.37 4.69 -1,541.99 \n", "9 16,989,497.48 11,790,903.24 69.40 1,819,890.78 10.71 -1,476.95 \n", "10 169,894,839.66 96,270,200.45 nan 8,304,903.21 nan nan \n", "11 8,494,172.66 7,575,883.76 89.19 770,988.04 9.08 -1,261.50 \n", "12 6,794,896.30 3,579,115.15 52.67 574,417.77 8.45 -369.23 \n", "13 1,700,428.52 635,904.33 37.40 474,484.97 27.90 -6,979.61 \n", "\n", " tot_change share_of_change perc_aftertax pc_aftertaxinc \n", "0 1,193,396.44 -0.00 0.00 -0.00 \n", "1 -179,704,079.68 0.16 -0.10 0.07 \n", "2 -2,066,585,817.15 1.84 -0.79 0.59 \n", "3 -3,910,998,318.73 3.49 -1.06 0.80 \n", "4 -7,363,181,927.97 6.56 -1.51 1.14 \n", "5 -11,296,355,312.29 10.07 -1.78 1.34 \n", "6 -16,674,384,517.30 14.86 -2.01 1.51 \n", "7 -19,398,072,372.39 17.29 -1.73 1.30 \n", "8 -26,197,883,909.73 23.35 -1.63 1.22 \n", "9 -25,092,638,376.93 22.37 -0.63 0.47 \n", "10 -112,178,611,235.74 100.00 nan nan \n", "11 -10,715,437,853.55 9.55 -0.96 0.72 \n", "12 -2,508,876,592.63 2.24 -0.21 0.16 \n", "13 -11,868,323,930.75 10.58 -0.64 0.49 " ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "create_difference_table(calc.records, calc_response.records, groupby='weighted_deciles',\n", " income_measure='expanded_income', tax_to_diff='combined')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Plotting\n", "\n", "You can use built in methods to get MTR and ATR plots. Each one is returned as a simple Bokeh figure that you can then add to as desired" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " Loading BokehJS ...\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(root) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = true;\n", "\n", " if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " root._bokeh_onload_callbacks = [];\n", " root._bokeh_is_loading = undefined;\n", " }\n", "\n", " var JS_MIME_TYPE = 'application/javascript';\n", " var HTML_MIME_TYPE = 'text/html';\n", " var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", " var CLASS_NAME = 'output_bokeh rendered_html';\n", "\n", " /**\n", " * Render data to the DOM node\n", " */\n", " function render(props, node) {\n", " var script = document.createElement(\"script\");\n", " node.appendChild(script);\n", " }\n", "\n", " /**\n", " * Handle when an output is cleared or removed\n", " */\n", " function handleClearOutput(event, handle) {\n", " var cell = handle.cell;\n", "\n", " var id = cell.output_area._bokeh_element_id;\n", " var server_id = cell.output_area._bokeh_server_id;\n", " // Clean up Bokeh references\n", " if (id !== undefined) {\n", " Bokeh.index[id].model.document.clear();\n", " delete Bokeh.index[id];\n", " }\n", "\n", " if (server_id !== undefined) {\n", " // Clean up Bokeh references\n", " var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", " cell.notebook.kernel.execute(cmd, {\n", " iopub: {\n", " output: function(msg) {\n", " var element_id = msg.content.text.trim();\n", " Bokeh.index[element_id].model.document.clear();\n", " delete Bokeh.index[element_id];\n", " }\n", " }\n", " });\n", " // Destroy server and session\n", " var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", " cell.notebook.kernel.execute(cmd);\n", " }\n", " }\n", "\n", " /**\n", " * Handle when a new output is added\n", " */\n", " function handleAddOutput(event, handle) {\n", " var output_area = handle.output_area;\n", " var output = handle.output;\n", "\n", " // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", " if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n", " return\n", " }\n", "\n", " var toinsert = output_area.element.find(`.${CLASS_NAME.split(' ')[0]}`);\n", "\n", " if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", " toinsert[0].firstChild.textContent = output.data[JS_MIME_TYPE];\n", " // store reference to embed id on output_area\n", " output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", " }\n", " if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", " var bk_div = document.createElement(\"div\");\n", " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", " var script_attrs = bk_div.children[0].attributes;\n", " for (var i = 0; i < script_attrs.length; i++) {\n", " toinsert[0].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", " }\n", " // store reference to server id on output_area\n", " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", " }\n", " }\n", "\n", " function register_renderer(events, OutputArea) {\n", "\n", " function append_mime(data, metadata, element) {\n", " // create a DOM node to render to\n", " var toinsert = this.create_output_subarea(\n", " metadata,\n", " CLASS_NAME,\n", " EXEC_MIME_TYPE\n", " );\n", " this.keyboard_manager.register_events(toinsert);\n", " // Render to node\n", " var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", " render(props, toinsert[0]);\n", " element.append(toinsert);\n", " return toinsert\n", " }\n", "\n", " /* Handle when an output is cleared or removed */\n", " events.on('clear_output.CodeCell', handleClearOutput);\n", " events.on('delete.Cell', handleClearOutput);\n", "\n", " /* Handle when a new output is added */\n", " events.on('output_added.OutputArea', handleAddOutput);\n", "\n", " /**\n", " * Register the mime type and append_mime function with output_area\n", " */\n", " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", " /* Is output safe? */\n", " safe: true,\n", " /* Index of renderer in `output_area.display_order` */\n", " index: 0\n", " });\n", " }\n", "\n", " // register the mime type if in Jupyter Notebook environment and previously unregistered\n", " if (root.Jupyter !== undefined) {\n", " var events = require('base/js/events');\n", " var OutputArea = require('notebook/js/outputarea').OutputArea;\n", "\n", " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", " register_renderer(events, OutputArea);\n", " }\n", " }\n", "\n", " \n", " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", " root._bokeh_timeout = Date.now() + 5000;\n", " root._bokeh_failed_load = false;\n", " }\n", "\n", " var NB_LOAD_WARNING = {'data': {'text/html':\n", " \"
\\n\"+\n", " \"

\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"

\\n\"+\n", " \"\\n\"+\n", " \"\\n\"+\n", " \"from bokeh.resources import INLINE\\n\"+\n", " \"output_notebook(resources=INLINE)\\n\"+\n", " \"\\n\"+\n", " \"
\"}};\n", "\n", " function display_loaded() {\n", " var el = document.getElementById(\"f22a1e23-2e69-463d-a14e-b6bb89f1664d\");\n", " if (el != null) {\n", " el.textContent = \"BokehJS is loading...\";\n", " }\n", " if (root.Bokeh !== undefined) {\n", " if (el != null) {\n", " el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n", " }\n", " } else if (Date.now() < root._bokeh_timeout) {\n", " setTimeout(display_loaded, 100)\n", " }\n", " }\n", "\n", "\n", " function run_callbacks() {\n", " try {\n", " root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " }\n", " finally {\n", " delete root._bokeh_onload_callbacks\n", " }\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(js_urls, callback) {\n", " root._bokeh_onload_callbacks.push(callback);\n", " if (root._bokeh_is_loading > 0) {\n", " console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", " return null;\n", " }\n", " if (js_urls == null || js_urls.length === 0) {\n", " run_callbacks();\n", " return null;\n", " }\n", " console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", " root._bokeh_is_loading = js_urls.length;\n", " for (var i = 0; i < js_urls.length; i++) {\n", " var url = js_urls[i];\n", " var s = document.createElement('script');\n", " s.src = url;\n", " s.async = false;\n", " s.onreadystatechange = s.onload = function() {\n", " root._bokeh_is_loading--;\n", " if (root._bokeh_is_loading === 0) {\n", " console.log(\"Bokeh: all BokehJS libraries loaded\");\n", " run_callbacks()\n", " }\n", " };\n", " s.onerror = function() {\n", " console.warn(\"failed to load library \" + url);\n", " };\n", " console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " document.getElementsByTagName(\"head\")[0].appendChild(s);\n", " }\n", " };var element = document.getElementById(\"f22a1e23-2e69-463d-a14e-b6bb89f1664d\");\n", " if (element == null) {\n", " console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'f22a1e23-2e69-463d-a14e-b6bb89f1664d' but no matching script tag was found. \")\n", " return false;\n", " }\n", "\n", " var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.10.min.js\"];\n", "\n", " var inline_js = [\n", " function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " \n", " function(Bokeh) {\n", " \n", " },\n", " function(Bokeh) {\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.css\");\n", " }\n", " ];\n", "\n", " function run_inline_js() {\n", " \n", " if ((root.Bokeh !== undefined) || (force === true)) {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i].call(root, root.Bokeh);\n", " }if (force === true) {\n", " display_loaded();\n", " }} else if (Date.now() < root._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!root._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " root._bokeh_failed_load = true;\n", " } else if (force !== true) {\n", " var cell = $(document.getElementById(\"f22a1e23-2e69-463d-a14e-b6bb89f1664d\")).parents('.cell').data().cell;\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " }\n", "\n", " }\n", "\n", " if (root._bokeh_is_loading === 0) {\n", " console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", " run_inline_js();\n", " } else {\n", " load_libs(js_urls, function() {\n", " console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n", " run_inline_js();\n", " });\n", " }\n", "}(window));" ], "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"f22a1e23-2e69-463d-a14e-b6bb89f1664d\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = js_urls.length;\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var s = document.createElement('script');\n s.src = url;\n s.async = false;\n s.onreadystatechange = s.onload = function() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: all BokehJS libraries loaded\");\n run_callbacks()\n }\n };\n s.onerror = function() {\n console.warn(\"failed to load library \" + url);\n };\n console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.getElementsByTagName(\"head\")[0].appendChild(s);\n }\n };var element = document.getElementById(\"f22a1e23-2e69-463d-a14e-b6bb89f1664d\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'f22a1e23-2e69-463d-a14e-b6bb89f1664d' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.10.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"f22a1e23-2e69-463d-a14e-b6bb89f1664d\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(js_urls, function() {\n console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from bokeh.io import show, output_notebook\n", "output_notebook()" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": true }, "outputs": [], "source": [ "mtr_plot_data = mtr_graph_data(calc, calc_response)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "
\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function embed_document(root) {\n", " var docs_json = {\"48fb4055-3ca5-456d-82fd-f91d12d0d18d\":{\"roots\":{\"references\":[{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"value\":0},\"y\":{\"value\":0}},\"id\":\"49d0e073-4480-4e18-9f16-b0952f1e7e23\",\"type\":\"Circle\"},{\"attributes\":{\"line_color\":{\"value\":\"blue\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"ff4815d5-b886-4759-9c68-f41b5a10782c\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"ef177f5d-b1df-442f-9fca-0466284549b9\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null,\"data\":{}},\"id\":\"fdfb6f31-9e98-4864-9e42-5c8d9628962a\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"2c84a336-6152-4196-ba60-9cb563e38962\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"2b1c9da3-3ec0-465f-9374-fdc4b2645d22\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"87961814-3f2b-42d3-873e-c51bee1bc29b\",\"type\":\"BasicTicker\"}},\"id\":\"acb6cccf-3a0e-44d7-bf22-7857f1ccc81d\",\"type\":\"Grid\"},{\"attributes\":{\"data_source\":{\"id\":\"fdfb6f31-9e98-4864-9e42-5c8d9628962a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1cc1edcf-e8e4-4b9a-958e-b2a0f73de413\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"49d0e073-4480-4e18-9f16-b0952f1e7e23\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"d5ba571c-d0b3-4274-a72a-da10ca0bf743\",\"type\":\"CDSView\"},\"visible\":false},\"id\":\"5c2c3a27-0223-49ff-882c-d5ef733274be\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data_source\":{\"id\":\"115afd25-09b4-4eb2-b515-bc4f0b8d3877\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"ff4815d5-b886-4759-9c68-f41b5a10782c\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"25bc86d3-7264-4a83-84cc-3423d6e6fc4c\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"f24ad962-78f0-41d2-a270-7f5a59e94add\",\"type\":\"CDSView\"}},\"id\":\"309d6682-5ac5-4b42-8b97-54eb47e9aa14\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"below\":[{\"id\":\"738c3fe5-91ec-4963-848a-567735097165\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"e0c6a92f-f0e2-4a2f-8177-91094d072189\",\"type\":\"LinearAxis\"}],\"plot_height\":500,\"plot_width\":850,\"renderers\":[{\"id\":\"738c3fe5-91ec-4963-848a-567735097165\",\"type\":\"LinearAxis\"},{\"id\":\"b3e1d60b-255c-4c0f-b5e0-d340b27e598c\",\"type\":\"Grid\"},{\"id\":\"e0c6a92f-f0e2-4a2f-8177-91094d072189\",\"type\":\"LinearAxis\"},{\"id\":\"acb6cccf-3a0e-44d7-bf22-7857f1ccc81d\",\"type\":\"Grid\"},{\"id\":\"6376636e-c96e-404d-a65b-9c29c0e85701\",\"type\":\"BoxAnnotation\"},{\"id\":\"2a0bffe0-0a06-4e2b-aad0-c5f0d0ed9351\",\"type\":\"Legend\"},{\"id\":\"309d6682-5ac5-4b42-8b97-54eb47e9aa14\",\"type\":\"GlyphRenderer\"},{\"id\":\"d9c39b02-f971-4c4f-90a1-e3b3115fd56b\",\"type\":\"GlyphRenderer\"},{\"id\":\"5c2c3a27-0223-49ff-882c-d5ef733274be\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"13ceee8b-2aff-4a0d-92e8-c7d680ec6ac6\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"fad9f024-d8e5-43a7-b2f5-a0ed599930ee\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"213e88ac-61cd-4a0f-aa98-41f9db843003\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"b42908b3-df6a-4088-9636-7195539679d5\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"6a52089c-f3cc-419e-b41d-d5c40613afd1\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"29fd2b20-4420-4506-83c5-40c7e0ea4ab3\",\"type\":\"LinearScale\"}},\"id\":\"2b1c9da3-3ec0-465f-9374-fdc4b2645d22\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"34b66265-430a-4583-98cf-fcc895490d34\",\"type\":\"HelpTool\"},{\"attributes\":{\"callback\":null},\"id\":\"213e88ac-61cd-4a0f-aa98-41f9db843003\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"87961814-3f2b-42d3-873e-c51bee1bc29b\",\"type\":\"BasicTicker\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"531c25ab-2b2a-44e4-aae7-ab3596f53846\",\"type\":\"PanTool\"},{\"id\":\"1bcede81-c469-4c51-8997-f882e03fc407\",\"type\":\"WheelZoomTool\"},{\"id\":\"a6d66567-e32e-44e4-9bd9-96be7642dd23\",\"type\":\"BoxZoomTool\"},{\"id\":\"36434eb2-48c2-4969-b6bc-31d4108e0c1c\",\"type\":\"SaveTool\"},{\"id\":\"e48f2cf7-ea9a-4def-9fe0-2053dda93a90\",\"type\":\"ResetTool\"},{\"id\":\"34b66265-430a-4583-98cf-fcc895490d34\",\"type\":\"HelpTool\"}]},\"id\":\"fad9f024-d8e5-43a7-b2f5-a0ed599930ee\",\"type\":\"Toolbar\"},{\"attributes\":{\"plot\":{\"id\":\"2b1c9da3-3ec0-465f-9374-fdc4b2645d22\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"bdfbe491-a44a-4d85-b593-fd069d64e570\",\"type\":\"BasicTicker\"}},\"id\":\"b3e1d60b-255c-4c0f-b5e0-d340b27e598c\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"36434eb2-48c2-4969-b6bc-31d4108e0c1c\",\"type\":\"SaveTool\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"value\":0},\"y\":{\"value\":0}},\"id\":\"1cc1edcf-e8e4-4b9a-958e-b2a0f73de413\",\"type\":\"Circle\"},{\"attributes\":{\"data_source\":{\"id\":\"375b1c30-931f-4d27-9312-9a7f68b72a6a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"3b228a97-cfaa-4094-96ad-ae98dee4766d\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"51ae4904-d581-4313-91e3-1dae724419f2\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"2e696536-b80d-4bd3-8b99-16f039277d48\",\"type\":\"CDSView\"}},\"id\":\"d9c39b02-f971-4c4f-90a1-e3b3115fd56b\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"531c25ab-2b2a-44e4-aae7-ab3596f53846\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"29fd2b20-4420-4506-83c5-40c7e0ea4ab3\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"e48f2cf7-ea9a-4def-9fe0-2053dda93a90\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"bdfbe491-a44a-4d85-b593-fd069d64e570\",\"type\":\"BasicTicker\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99],\"y\":{\"__ndarray__\":\"0kmodGIjoT+MWO+jBDd+P61549CD9Wo/bmHhdMEbhz+yytWMrny0P1fXLBhsYbs/ecc7D4SWuT8Ti3JnH4G6P+UC2h4nR5w/V/6korYUkL80s1at6GeDv5KuT0S0PHG/DdiFo47WlD+1KXszFHuZP+VQ1/XMOqY/GAfjer5Yqj8OBuzsFE2zP40lWPacdbo/Xb3n2RASvj8qnHk1Rqe9P8zWZxS/wrw/tQHkXkJHvj9jAfVIWhvAP4SQUDnoq8Q/7GxVw74xwz9fiE8QmMfDPzTIrCNE38Q/rHX5cFPzxD+GVKValXXHP5kgAYDFccc/kV/MlcAayT8/DLjDwhfMPy0cagqUwcs/eNdaLkkYzj/ZzSDZfTLOP+D8maJdVM0/xYuqrkHA0D8/gYiWvTnQP6hVaqUn6tA//kdvcLdf0T/Q14UDKuzQP5OY4b5qitE/KH9obLsJ0j8LoD01dFHSP6sS32pDTtI/gmqzlGxB0j8NFAWMy1bSPwI2z4CZp9I/h4WC8OTb0j9ZIrGGPenTPz8cutYrb9M/IMmWW54U0z8OSF6agt3TP4rA5MoAbNM/xf6nniOK0z/y32ZHyhvUPx3sg8yl6dM/y1Lntw3b0z9Ry2kKV0/TPwr46mq6RtM/bUTxuu7/0z94P+JWOKrUP3Vai7xN0tQ/LHZYsE431T8YysTYJOfUP+YKVpGNS9U//v+RfKyC1T94jW4ro7TVP4QyIJVDntU/5ZfC2sDj1T+u7PKNWOPVP2ik/rv75dU/VTdX7f/j1T/YtlXjlijWP1131tc7G9Y/xpY2xc741T9BlvrdF/nVPy9ZmC9I79U/LXVsfq+X1T9bAnZQ5d7VP5GwtlyxZ9U/VNdnSLzD1T9Dih24bU/WP+OjPu4zo9Y/UQlMH+eG2D+8hvG++0/ZP8z1bqSELdo/zC05Ocux2j9/zQPHug/aP2ZjmNmjQNk/HSm3SgYY2T+FuEixhH/YP3Sf+62/Ydg/2ljDwSXP1z9Io5cVxgDYPzuVSESobdg/K0szCiO/2D81TeXqkXXaP1/IG+m9/ts/po+/fXtq3T8=\",\"dtype\":\"float64\",\"shape\":[100]}}},\"id\":\"115afd25-09b4-4eb2-b515-bc4f0b8d3877\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis_label\":\"Income+Payroll-Tax MTR\",\"axis_label_text_font_size\":{\"value\":\"12pt\"},\"axis_label_text_font_style\":\"normal\",\"formatter\":{\"id\":\"ef177f5d-b1df-442f-9fca-0466284549b9\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"2b1c9da3-3ec0-465f-9374-fdc4b2645d22\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"87961814-3f2b-42d3-873e-c51bee1bc29b\",\"type\":\"BasicTicker\"}},\"id\":\"e0c6a92f-f0e2-4a2f-8177-91094d072189\",\"type\":\"LinearAxis\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"25bc86d3-7264-4a83-84cc-3423d6e6fc4c\",\"type\":\"Line\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"6376636e-c96e-404d-a65b-9c29c0e85701\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"axis_label\":\"Baseline Expanded-Income Percentile\",\"axis_label_text_font_size\":{\"value\":\"12pt\"},\"axis_label_text_font_style\":\"normal\",\"formatter\":{\"id\":\"2c84a336-6152-4196-ba60-9cb563e38962\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"2b1c9da3-3ec0-465f-9374-fdc4b2645d22\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"bdfbe491-a44a-4d85-b593-fd069d64e570\",\"type\":\"BasicTicker\"}},\"id\":\"738c3fe5-91ec-4963-848a-567735097165\",\"type\":\"LinearAxis\"},{\"attributes\":{\"plot\":null,\"text\":\"Mean Marginal Tax Rate for e00200p by Income Percentile for 2018\",\"text_font_size\":{\"value\":\"12pt\"}},\"id\":\"13ceee8b-2aff-4a0d-92e8-c7d680ec6ac6\",\"type\":\"Title\"},{\"attributes\":{\"source\":{\"id\":\"375b1c30-931f-4d27-9312-9a7f68b72a6a\",\"type\":\"ColumnDataSource\"}},\"id\":\"2e696536-b80d-4bd3-8b99-16f039277d48\",\"type\":\"CDSView\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"51ae4904-d581-4313-91e3-1dae724419f2\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null},\"id\":\"6a52089c-f3cc-419e-b41d-d5c40613afd1\",\"type\":\"DataRange1d\"},{\"attributes\":{\"line_color\":{\"value\":\"red\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"3b228a97-cfaa-4094-96ad-ae98dee4766d\",\"type\":\"Line\"},{\"attributes\":{\"source\":{\"id\":\"fdfb6f31-9e98-4864-9e42-5c8d9628962a\",\"type\":\"ColumnDataSource\"}},\"id\":\"d5ba571c-d0b3-4274-a72a-da10ca0bf743\",\"type\":\"CDSView\"},{\"attributes\":{\"label\":{\"value\":\"Baseline\"},\"renderers\":[{\"id\":\"309d6682-5ac5-4b42-8b97-54eb47e9aa14\",\"type\":\"GlyphRenderer\"}]},\"id\":\"06250603-b9dc-4db8-978a-2592536de9d6\",\"type\":\"LegendItem\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99],\"y\":{\"__ndarray__\":\"0kmodGIjoT+MWO+jBDd+P61549CD9Wo/bmHhdMEbhz+yytWMrny0PzBZtiQjaLs/f8+b9AqiuT/3jx8bboq6P0026jMPW5w/2/UCUJ8IkL9rA/mHzEmDv7tdS9PgzHS/KIKJMQkkkz8hActzTLaXP4gqR/p5KKU/9tr2/96AqT/M2WHjRaiyP40vKayddrQ/cOdvLmzuuD90BZHrVXu2Py2kkVyKDbg/o5L3/Pzitz9M1cjRsmq6P/2CdOmlosA/MIP5lcVavz8hFuBH703CP84TloJlncQ/lSBTSJCqxD96xWBEIBPHPwFkq/ld48Y/CnDPosZcyD/eieUtsrPKPyetNMKM7ck/L4Y0+XV+yz/2gznW9HnLP84GbdyDzMo/k4Qp+59Dzj/+EZAPJH/NP/v5d/ggxM4/98sw9yqjzz86jk2cWO3OP3vtIAmyyM8/fsl5b7JQ0D82dIG4tWzQP87nK2FObNA/Zgh0UDl10D9hgfpaKrbQP028uu+NFdE/pZ2KdvM20T/dZy567xfSPzeKxhEo6tE/6Z8FBMaP0T9TIiYbDTvSP+s1EncM2dE/xmlLdUD+0T94BNzQWHrSP0Ge1wbWXtI/c9GEWi9x0j8j+ceJkbLRPzq4OR5Ye9E/ugi2KMuW0T+ILkowHbfRPzy/BoaZd9E/5350m8qI0T8IdyUmC1DTP6xk5AQUrNM/Z6GKAewF1D9S7SKrtlrUP3Y5PcPyENQ/0Pgo4+Zq1D+9NhdqLE/UP6uqwMuDLNQ//gxqp1Yw1D/tw3KjW13UP1RlOThoS9Q/ULUDtghG1D8thLQciSbUP7f7YLxoLtQ/kd+z8mmi0z/bv2I49wjUP9LBSoUxYNM/LGLV6M6U0z8IVyY/fETTP3y6cKYj8dI/qWRxs4o71T8o+Lw/dinXP+pt7tX+u9g/x5ZeD7RE2T+kQ55feZfYP1YAa6dmjdc/VxKKZUhp1z+KoZW3hrTWP1MZwxH3etY/JCRhTfnt1T/NZW+jWP3VP2mKFS2rY9Y/PlgIQMf51T/TpI7S9//WPykPORxjztc/kDuHJTKp2D8=\",\"dtype\":\"float64\",\"shape\":[100]}}},\"id\":\"375b1c30-931f-4d27-9312-9a7f68b72a6a\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"b42908b3-df6a-4088-9636-7195539679d5\",\"type\":\"LinearScale\"},{\"attributes\":{\"overlay\":{\"id\":\"6376636e-c96e-404d-a65b-9c29c0e85701\",\"type\":\"BoxAnnotation\"}},\"id\":\"a6d66567-e32e-44e4-9bd9-96be7642dd23\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"source\":{\"id\":\"115afd25-09b4-4eb2-b515-bc4f0b8d3877\",\"type\":\"ColumnDataSource\"}},\"id\":\"f24ad962-78f0-41d2-a270-7f5a59e94add\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1bcede81-c469-4c51-8997-f882e03fc407\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"label\":{\"value\":\"Reform\"},\"renderers\":[{\"id\":\"d9c39b02-f971-4c4f-90a1-e3b3115fd56b\",\"type\":\"GlyphRenderer\"}]},\"id\":\"0a1946f8-800d-4935-b74a-c9b0e81fd866\",\"type\":\"LegendItem\"},{\"attributes\":{\"glyph_height\":14,\"glyph_width\":14,\"items\":[{\"id\":\"06250603-b9dc-4db8-978a-2592536de9d6\",\"type\":\"LegendItem\"},{\"id\":\"0a1946f8-800d-4935-b74a-c9b0e81fd866\",\"type\":\"LegendItem\"}],\"label_height\":2,\"label_standoff\":2,\"label_text_font\":\"times\",\"label_text_font_style\":\"italic\",\"label_width\":2,\"location\":\"bottom_right\",\"padding\":5,\"plot\":{\"id\":\"2b1c9da3-3ec0-465f-9374-fdc4b2645d22\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"spacing\":5},\"id\":\"2a0bffe0-0a06-4e2b-aad0-c5f0d0ed9351\",\"type\":\"Legend\"}],\"root_ids\":[\"2b1c9da3-3ec0-465f-9374-fdc4b2645d22\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.10\"}};\n", " var render_items = [{\"docid\":\"48fb4055-3ca5-456d-82fd-f91d12d0d18d\",\"elementid\":\"23d2a2e9-c3f9-4687-ae8c-9afef0b2b32c\",\"modelid\":\"2b1c9da3-3ec0-465f-9374-fdc4b2645d22\"}];\n", "\n", " root.Bokeh.embed.embed_items(docs_json, render_items);\n", " }\n", "\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " } else {\n", " var attempts = 0;\n", " var timer = setInterval(function(root) {\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " clearInterval(timer);\n", " }\n", " attempts++;\n", " if (attempts > 100) {\n", " console.log(\"Bokeh: ERROR: Unable to embed document because BokehJS library is missing\")\n", " clearInterval(timer);\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "2b1c9da3-3ec0-465f-9374-fdc4b2645d22" } }, "output_type": "display_data" } ], "source": [ "show(xtr_graph_plot(mtr_plot_data))" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": true }, "outputs": [], "source": [ "atr_plot_data = atr_graph_data(calc, calc_response)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "
\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function embed_document(root) {\n", " var docs_json = {\"4c797bc2-56fa-4814-bdc7-ccbbf6a2505c\":{\"roots\":{\"references\":[{\"attributes\":{\"glyph_height\":14,\"glyph_width\":14,\"items\":[{\"id\":\"224d9c3d-2ec4-482f-b792-aa12594d1314\",\"type\":\"LegendItem\"},{\"id\":\"52c360b1-a498-46a8-97ed-dd7905bcb951\",\"type\":\"LegendItem\"}],\"label_height\":2,\"label_standoff\":2,\"label_text_font\":\"times\",\"label_text_font_style\":\"italic\",\"label_width\":2,\"location\":\"bottom_right\",\"padding\":5,\"plot\":{\"id\":\"20e2876a-7f15-4e4b-9ebc-7d6a0b0366ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"spacing\":5},\"id\":\"21b958ff-b93b-422b-a5e3-9f02b2c1a7af\",\"type\":\"Legend\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"value\":0},\"y\":{\"value\":0}},\"id\":\"0e0a4c6e-60a4-457e-ae66-4d643e2153f9\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"a9b9c9c8-6339-4ad8-aeeb-4e2d74533622\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1a61ab57-54cf-446c-a10f-88bbae09e53a\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"line_color\":{\"value\":\"blue\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4a6cabc9-bc40-499f-805f-664030390845\",\"type\":\"Line\"},{\"attributes\":{\"source\":{\"id\":\"f89b4efd-2dc3-4560-b937-efde9e06ac25\",\"type\":\"ColumnDataSource\"}},\"id\":\"cc5917e3-1047-4874-b7ec-863acb6914e8\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"f5394845-1571-4c05-a8f6-710ceb591ffa\",\"type\":\"SaveTool\"},{\"attributes\":{\"below\":[{\"id\":\"b70c6df8-a5a9-484c-ba61-a37f3f9e7300\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"df566749-dcab-475e-9251-b4508bedc1db\",\"type\":\"LinearAxis\"}],\"plot_height\":500,\"plot_width\":850,\"renderers\":[{\"id\":\"b70c6df8-a5a9-484c-ba61-a37f3f9e7300\",\"type\":\"LinearAxis\"},{\"id\":\"4c8f144f-bb33-4fc6-8fcc-06324c6e7f13\",\"type\":\"Grid\"},{\"id\":\"df566749-dcab-475e-9251-b4508bedc1db\",\"type\":\"LinearAxis\"},{\"id\":\"3b8cfde3-2959-42f2-853f-8eb510b17a9f\",\"type\":\"Grid\"},{\"id\":\"36955a34-4636-425d-beab-77b250546d9b\",\"type\":\"BoxAnnotation\"},{\"id\":\"21b958ff-b93b-422b-a5e3-9f02b2c1a7af\",\"type\":\"Legend\"},{\"id\":\"5344563a-1463-4fbc-bfd6-cb1fae62c548\",\"type\":\"GlyphRenderer\"},{\"id\":\"197218ab-b7e3-427c-82fc-923d6ddbcbfb\",\"type\":\"GlyphRenderer\"},{\"id\":\"737f57c9-5d43-44bb-af03-7b58c6f59fde\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"802c243c-ad07-43d7-8b94-63bcfc7e46de\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"667a9698-c755-451f-a776-71f1fdf1d53e\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"771962d9-9bbe-49e4-b933-fd303db99589\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"8b9d99be-144c-4f45-882c-a3fad70d153c\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"3d60e293-bf0e-4ea4-80d1-1060f8ff1c7c\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"a9b9c9c8-6339-4ad8-aeeb-4e2d74533622\",\"type\":\"LinearScale\"}},\"id\":\"20e2876a-7f15-4e4b-9ebc-7d6a0b0366ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null,\"data\":{}},\"id\":\"63bc319a-48d9-4ccc-8892-13377bb36f49\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"callback\":null},\"id\":\"3d60e293-bf0e-4ea4-80d1-1060f8ff1c7c\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99],\"y\":{\"__ndarray__\":\"krokfhyDsj/ymGQJQJS0PwIKNJaBiqU/3fkpFVvQhL+QC2ZYtoeJvw2GGcJ3dou/K9YSoNQEi78qG+n9D0yNv+kyNVZ9nYK/eN3lQvk8eb9iPYWRBwuBv9d/t8iqdoq/lzR64Bz2az87esUQZ2Zzv18UFrE7c28/YehPojCeZT/WgH9DrdFzP9gF0e696IU/76c0hbMlkT/47VYlgWSRPxXLDKHRtpY/bCWezHbGnD/PdbKAaEuhPzcJjBZ9Jp4/Rx7QbPbuoT8DyFsIJ8KmP+VpKBTvw6g/Btb4AzOXrj9ARFJZ9YytP/TpK+f37q0/5q9nlD2usj+7aaSf07uyP4WmFFBnhrM/cOkyIHqZtT99hl5V8r22P9YwAhvSJbc/B6oJVXRXuD+lqsXHqVa6PyJ9NyJ9kbo/8EiMlXS6vD/R7xy7rxS9P8szoE4zRr4/1U1ZjkYNvz/b3Q/0gInBP4JXzEsHXsE/bD0sYqiCwD/0EGEvXQ7CPzmIfDvU5cE/EruCf5p6wj/9WwE2k03DPy6IDoO8FsM/oLxGZmxExD8PnnYuvffDP3sL25Mgz8Q/LZMFBNmgxD94titd7K7FP3j21kBo/8U/RyHulSEGxz+l00wf21bGP051YoMy6MY//N2SYESnxz8mRvTz5sHIPyL0ySWIvsc/35Z+6IznyD+KipVHhhjJP1s7JQHITck/0ypxBr7FyT/aahPZLV7KPyPFPrWDNco/8DEW/Zi3yj+mA9sQ/+LKP+bmQEgmUMs/QbkiS7E3yz84ai2U/RbMP9NXAkHVScs/A7BLtsNnzD8wRD6pDv7LP5Ubrrnp0cs/9RrdniryzD8agNT1E+rMP0a2MMc0Ec4/Lt9yrdy3zT/dojjOLKnOP92gye66684/SDfRXp6Mzz9V5WKZhrHPP3qCrZ+a5s8/YL/Ro5hA0D/5voPMbmLQP5JNcRa0f9A/OAhsKuTM0D9YQPe2C/TQP0vq63uxpNE/kf+N/Ab40j8=\",\"dtype\":\"float64\",\"shape\":[94]}}},\"id\":\"f89b4efd-2dc3-4560-b937-efde9e06ac25\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"overlay\":{\"id\":\"36955a34-4636-425d-beab-77b250546d9b\",\"type\":\"BoxAnnotation\"}},\"id\":\"77f4ab69-3a62-4950-9c94-369721087309\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"e8aeb5b2-714d-44b3-8300-2d13d25ac691\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"77b7392a-ba90-4763-adb8-77f8a2bd64e6\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"axis_label\":\"Income+Payroll-Tax Average Tax Rate\",\"axis_label_text_font_size\":{\"value\":\"12pt\"},\"axis_label_text_font_style\":\"normal\",\"formatter\":{\"id\":\"77b7392a-ba90-4763-adb8-77f8a2bd64e6\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"20e2876a-7f15-4e4b-9ebc-7d6a0b0366ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"62c35888-d43d-4dab-b152-7cfd1d238eb6\",\"type\":\"BasicTicker\"}},\"id\":\"df566749-dcab-475e-9251-b4508bedc1db\",\"type\":\"LinearAxis\"},{\"attributes\":{\"source\":{\"id\":\"c2b3f1ed-bdf0-4de3-b343-f90d648702a1\",\"type\":\"ColumnDataSource\"}},\"id\":\"065b4cc4-2b1c-43a6-8345-ff18be527f63\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"36955a34-4636-425d-beab-77b250546d9b\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"callback\":null},\"id\":\"771962d9-9bbe-49e4-b933-fd303db99589\",\"type\":\"DataRange1d\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"b79db028-56ba-422a-96fd-5ca3ac291a63\",\"type\":\"Line\"},{\"attributes\":{\"data_source\":{\"id\":\"c2b3f1ed-bdf0-4de3-b343-f90d648702a1\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"aeffe697-858c-4312-9fa4-c5599b0aa54b\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"b79db028-56ba-422a-96fd-5ca3ac291a63\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"065b4cc4-2b1c-43a6-8345-ff18be527f63\",\"type\":\"CDSView\"}},\"id\":\"197218ab-b7e3-427c-82fc-923d6ddbcbfb\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"20e2876a-7f15-4e4b-9ebc-7d6a0b0366ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"62c35888-d43d-4dab-b152-7cfd1d238eb6\",\"type\":\"BasicTicker\"}},\"id\":\"3b8cfde3-2959-42f2-853f-8eb510b17a9f\",\"type\":\"Grid\"},{\"attributes\":{\"plot\":null,\"text\":\"Average Tax Rate by Income Percentile for 2018\",\"text_font_size\":{\"value\":\"12pt\"}},\"id\":\"802c243c-ad07-43d7-8b94-63bcfc7e46de\",\"type\":\"Title\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"78e1e9b2-8c93-413f-9544-ba6e1309829a\",\"type\":\"PanTool\"},{\"id\":\"1a61ab57-54cf-446c-a10f-88bbae09e53a\",\"type\":\"WheelZoomTool\"},{\"id\":\"77f4ab69-3a62-4950-9c94-369721087309\",\"type\":\"BoxZoomTool\"},{\"id\":\"f5394845-1571-4c05-a8f6-710ceb591ffa\",\"type\":\"SaveTool\"},{\"id\":\"e8aeb5b2-714d-44b3-8300-2d13d25ac691\",\"type\":\"ResetTool\"},{\"id\":\"65dde561-21e0-42d6-9bad-cbb46738df0b\",\"type\":\"HelpTool\"}]},\"id\":\"667a9698-c755-451f-a776-71f1fdf1d53e\",\"type\":\"Toolbar\"},{\"attributes\":{\"data_source\":{\"id\":\"f89b4efd-2dc3-4560-b937-efde9e06ac25\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"4a6cabc9-bc40-499f-805f-664030390845\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"cebd83c1-d202-40e1-a5e1-0d07305f92a3\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"cc5917e3-1047-4874-b7ec-863acb6914e8\",\"type\":\"CDSView\"}},\"id\":\"5344563a-1463-4fbc-bfd6-cb1fae62c548\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"value\":0},\"y\":{\"value\":0}},\"id\":\"14b31cb2-c19f-44af-8902-5055c69079f5\",\"type\":\"Circle\"},{\"attributes\":{\"label\":{\"value\":\"Baseline\"},\"renderers\":[{\"id\":\"5344563a-1463-4fbc-bfd6-cb1fae62c548\",\"type\":\"GlyphRenderer\"}]},\"id\":\"224d9c3d-2ec4-482f-b792-aa12594d1314\",\"type\":\"LegendItem\"},{\"attributes\":{\"plot\":{\"id\":\"20e2876a-7f15-4e4b-9ebc-7d6a0b0366ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"d03b145e-07de-421d-ac39-19978ff4b8a3\",\"type\":\"BasicTicker\"}},\"id\":\"4c8f144f-bb33-4fc6-8fcc-06324c6e7f13\",\"type\":\"Grid\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"cebd83c1-d202-40e1-a5e1-0d07305f92a3\",\"type\":\"Line\"},{\"attributes\":{\"line_color\":{\"value\":\"red\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"aeffe697-858c-4312-9fa4-c5599b0aa54b\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"65dde561-21e0-42d6-9bad-cbb46738df0b\",\"type\":\"HelpTool\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99],\"y\":{\"__ndarray__\":\"bMrque6Fsj9Sw1xqjZm0P6CB0joak6U/E8CEGwvChL+yE07HbniJv5RUJCq9c4u/GMnQRbhVi78sCiEiH9eNvw+vw4rsa4O/2XcJgPXoer8twZKB+uCBv7WRLIv1yYy/2Rw0WdR2Vz8vFaArBLaBvy9G92xiKj4/jNbpsHPMZb/vn37EaySxvpBXEhyuw24/2QGNLoybgz9E7uJZNUGCP1h5EEi6JYs/FDIQmdpdlT/LcboSI22YP8ovr681C5c/gAs9cm/DnD+4hER3lreiP74Qaz3z5aQ/9wSWZr7DqT+vmcbW1ySpP3kxaHORv6k/KEKzvmrCrz8/elwb9k6wP/l31o2x8LA/6MbifCLMsj+bURIWlBC0P0diflaEaLQ/26iwD2ZYtT+b3iMaNSS3PwaUJyCkYbc/KNysXB1vuT+WyrlZXL+5P35cGXSV27o/SWVwWYTCuz+CmYhRITW/P1+gtw7S574/7l9xdQeYvT+bEFxa/y/AP2fx2iLBHsA/a/SoiM6swD/8nO6f0WDBP2U4oP4COcE/MOP61OZgwj9qa96IghzCP7xmHtLj7MI/izFwvwXKwj8Qb7taZbLDPxEv4mI6/sM/WrNntpHUxD9S1Pvb2jbEP2pwfmC8zcQ/fZ1BP+aWxT8mnNWBop/GPxQiO7iX3cU/5eGnE3Tuxj+vUGKgtTPHP8w/Bq5Kfcc/r+7X9Bjqxz/n2m3FRp7IP+huRdOGd8g/ykQekfUHyT+HOpnSqE3JP2ZHLLOrr8k/zhVkz3SmyT+Xl8SiPXXKP0u/5drftsk/ioiYR6PLyj9H81G8V2jKPzUld4KUKco//pB0kAklyz+bOeGdNjTLP51SsIpaV8w/Gvos0polzD8szgIsATXNP6c/4c+Fos0/QdCdyU5Zzj9UJcQ1yabOPy4PyL3JAM8/fbCnMHC7zz9J+sLdBhDQP5jd8DwOR9A/fgtIvwWx0D+F0t1uUefQP5mIQ415otE/RBHlyj930j8=\",\"dtype\":\"float64\",\"shape\":[94]}}},\"id\":\"c2b3f1ed-bdf0-4de3-b343-f90d648702a1\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis_label\":\"Baseline Expanded-Income Percentile\",\"axis_label_text_font_size\":{\"value\":\"12pt\"},\"axis_label_text_font_style\":\"normal\",\"formatter\":{\"id\":\"fd3399c7-8539-4f3a-996e-290ce93287c4\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"20e2876a-7f15-4e4b-9ebc-7d6a0b0366ff\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"d03b145e-07de-421d-ac39-19978ff4b8a3\",\"type\":\"BasicTicker\"}},\"id\":\"b70c6df8-a5a9-484c-ba61-a37f3f9e7300\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"78e1e9b2-8c93-413f-9544-ba6e1309829a\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"62c35888-d43d-4dab-b152-7cfd1d238eb6\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"d03b145e-07de-421d-ac39-19978ff4b8a3\",\"type\":\"BasicTicker\"},{\"attributes\":{\"source\":{\"id\":\"63bc319a-48d9-4ccc-8892-13377bb36f49\",\"type\":\"ColumnDataSource\"}},\"id\":\"800bc4f8-6eaa-43c6-9473-ab32eff070d9\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"63bc319a-48d9-4ccc-8892-13377bb36f49\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"0e0a4c6e-60a4-457e-ae66-4d643e2153f9\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"14b31cb2-c19f-44af-8902-5055c69079f5\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"800bc4f8-6eaa-43c6-9473-ab32eff070d9\",\"type\":\"CDSView\"},\"visible\":false},\"id\":\"737f57c9-5d43-44bb-af03-7b58c6f59fde\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"8b9d99be-144c-4f45-882c-a3fad70d153c\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"fd3399c7-8539-4f3a-996e-290ce93287c4\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"label\":{\"value\":\"Reform\"},\"renderers\":[{\"id\":\"197218ab-b7e3-427c-82fc-923d6ddbcbfb\",\"type\":\"GlyphRenderer\"}]},\"id\":\"52c360b1-a498-46a8-97ed-dd7905bcb951\",\"type\":\"LegendItem\"}],\"root_ids\":[\"20e2876a-7f15-4e4b-9ebc-7d6a0b0366ff\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.10\"}};\n", " var render_items = [{\"docid\":\"4c797bc2-56fa-4814-bdc7-ccbbf6a2505c\",\"elementid\":\"e29145cb-960e-4f82-aebf-90052b7c400d\",\"modelid\":\"20e2876a-7f15-4e4b-9ebc-7d6a0b0366ff\"}];\n", "\n", " root.Bokeh.embed.embed_items(docs_json, render_items);\n", " }\n", "\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " } else {\n", " var attempts = 0;\n", " var timer = setInterval(function(root) {\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " clearInterval(timer);\n", " }\n", " attempts++;\n", " if (attempts > 100) {\n", " console.log(\"Bokeh: ERROR: Unable to embed document because BokehJS library is missing\")\n", " clearInterval(timer);\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "20e2876a-7f15-4e4b-9ebc-7d6a0b0366ff" } }, "output_type": "display_data" } ], "source": [ "show(xtr_graph_plot(atr_plot_data))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Multiyear diagnostic tables\n", "\n", "You can also produce diagnostic tables up to 2026" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
201820192020202120222023202420252026
Returns (#m)169.9172.2174.5176.9179.3181.7184.1186.6189.1
AGI ($b)10,503.810,987.411,474.411,999.412,561.113,146.713,759.314,401.215,070.1
Itemizers (#m)68.069.671.272.774.275.977.579.180.8
Itemized Deduction ($b)1,500.91,585.91,672.21,765.41,863.51,967.02,075.82,189.32,312.4
Standard Deduction Filers (#m)83.984.384.885.486.086.587.187.788.3
Standard Deduction ($b)771.4791.5813.9838.1863.3887.9914.4940.9968.1
Personal Exemption ($b)1,222.61,266.21,312.41,361.21,412.51,464.91,519.71,576.11,634.7
Taxable Income ($b)7,421.97,768.68,113.28,485.38,886.39,305.29,742.710,203.310,678.8
Regular Tax ($b)1,369.71,442.91,514.01,590.91,672.51,756.71,843.91,935.72,029.1
AMT Income ($b)9,664.510,099.510,536.611,008.011,513.512,039.312,589.213,165.813,763.9
AMT Liability ($b)18.018.519.220.121.122.323.524.926.5
AMT Filers (#m)4.24.34.54.64.74.95.15.35.5
Tax before Credits ($b)1,387.71,461.51,533.21,611.01,693.61,779.01,867.41,960.72,055.6
Refundable Credits ($b)76.678.480.582.784.886.888.890.993.0
Nonrefundable Credits ($b)32.932.932.932.832.632.532.332.131.9
Reform Surtaxes ($b)0.00.00.00.00.00.00.00.00.0
Other Taxes ($b)9.310.010.611.211.912.513.214.014.8
Ind Income Tax ($b)1,287.51,360.11,430.41,506.81,588.11,672.31,759.61,851.71,945.6
Payroll Taxes ($b)1,233.61,290.31,344.71,402.71,465.81,533.01,603.61,677.71,755.3
Combined Liability ($b)2,521.12,650.52,775.12,909.43,053.93,205.33,363.23,529.43,700.9
With Income Tax <= 0 (#m)72.072.673.273.874.475.075.576.176.6
With Combined Tax <= 0 (#m)48.649.149.549.950.450.851.351.752.1
\n", "
" ], "text/plain": [ " 2018 2019 2020 2021 2022 \\\n", "Returns (#m) 169.9 172.2 174.5 176.9 179.3 \n", "AGI ($b) 10,503.8 10,987.4 11,474.4 11,999.4 12,561.1 \n", "Itemizers (#m) 68.0 69.6 71.2 72.7 74.2 \n", "Itemized Deduction ($b) 1,500.9 1,585.9 1,672.2 1,765.4 1,863.5 \n", "Standard Deduction Filers (#m) 83.9 84.3 84.8 85.4 86.0 \n", "Standard Deduction ($b) 771.4 791.5 813.9 838.1 863.3 \n", "Personal Exemption ($b) 1,222.6 1,266.2 1,312.4 1,361.2 1,412.5 \n", "Taxable Income ($b) 7,421.9 7,768.6 8,113.2 8,485.3 8,886.3 \n", "Regular Tax ($b) 1,369.7 1,442.9 1,514.0 1,590.9 1,672.5 \n", "AMT Income ($b) 9,664.5 10,099.5 10,536.6 11,008.0 11,513.5 \n", "AMT Liability ($b) 18.0 18.5 19.2 20.1 21.1 \n", "AMT Filers (#m) 4.2 4.3 4.5 4.6 4.7 \n", "Tax before Credits ($b) 1,387.7 1,461.5 1,533.2 1,611.0 1,693.6 \n", "Refundable Credits ($b) 76.6 78.4 80.5 82.7 84.8 \n", "Nonrefundable Credits ($b) 32.9 32.9 32.9 32.8 32.6 \n", "Reform Surtaxes ($b) 0.0 0.0 0.0 0.0 0.0 \n", "Other Taxes ($b) 9.3 10.0 10.6 11.2 11.9 \n", "Ind Income Tax ($b) 1,287.5 1,360.1 1,430.4 1,506.8 1,588.1 \n", "Payroll Taxes ($b) 1,233.6 1,290.3 1,344.7 1,402.7 1,465.8 \n", "Combined Liability ($b) 2,521.1 2,650.5 2,775.1 2,909.4 3,053.9 \n", "With Income Tax <= 0 (#m) 72.0 72.6 73.2 73.8 74.4 \n", "With Combined Tax <= 0 (#m) 48.6 49.1 49.5 49.9 50.4 \n", "\n", " 2023 2024 2025 2026 \n", "Returns (#m) 181.7 184.1 186.6 189.1 \n", "AGI ($b) 13,146.7 13,759.3 14,401.2 15,070.1 \n", "Itemizers (#m) 75.9 77.5 79.1 80.8 \n", "Itemized Deduction ($b) 1,967.0 2,075.8 2,189.3 2,312.4 \n", "Standard Deduction Filers (#m) 86.5 87.1 87.7 88.3 \n", "Standard Deduction ($b) 887.9 914.4 940.9 968.1 \n", "Personal Exemption ($b) 1,464.9 1,519.7 1,576.1 1,634.7 \n", "Taxable Income ($b) 9,305.2 9,742.7 10,203.3 10,678.8 \n", "Regular Tax ($b) 1,756.7 1,843.9 1,935.7 2,029.1 \n", "AMT Income ($b) 12,039.3 12,589.2 13,165.8 13,763.9 \n", "AMT Liability ($b) 22.3 23.5 24.9 26.5 \n", "AMT Filers (#m) 4.9 5.1 5.3 5.5 \n", "Tax before Credits ($b) 1,779.0 1,867.4 1,960.7 2,055.6 \n", "Refundable Credits ($b) 86.8 88.8 90.9 93.0 \n", "Nonrefundable Credits ($b) 32.5 32.3 32.1 31.9 \n", "Reform Surtaxes ($b) 0.0 0.0 0.0 0.0 \n", "Other Taxes ($b) 12.5 13.2 14.0 14.8 \n", "Ind Income Tax ($b) 1,672.3 1,759.6 1,851.7 1,945.6 \n", "Payroll Taxes ($b) 1,533.0 1,603.6 1,677.7 1,755.3 \n", "Combined Liability ($b) 3,205.3 3,363.2 3,529.4 3,700.9 \n", "With Income Tax <= 0 (#m) 75.0 75.5 76.1 76.6 \n", "With Combined Tax <= 0 (#m) 50.8 51.3 51.7 52.1 " ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "multiyear_diagnostic_table(calc, num_years=9)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
201820192020202120222023202420252026
Returns (#m)169.9172.2174.5176.9179.3181.7184.1186.6189.1
AGI ($b)10,477.210,959.611,445.211,968.712,528.813,112.813,723.814,364.115,031.2
Itemizers (#m)29.025.120.917.318.118.919.820.721.7
Itemized Deduction ($b)808.7678.4542.5423.0457.2493.1532.0573.8621.1
Standard Deduction Filers (#m)122.9128.8135.1140.8142.1143.5144.8146.2147.4
Standard Deduction ($b)2,117.12,280.02,459.22,638.72,726.22,815.12,907.43,001.23,096.2
Personal Exemption ($b)1,222.61,266.21,312.41,361.21,412.51,464.91,519.71,576.11,634.7
Taxable Income ($b)7,041.97,465.27,880.78,315.88,725.79,154.79,603.310,075.110,565.3
Regular Tax ($b)1,260.71,351.31,438.91,529.81,611.11,695.31,782.71,874.71,969.3
AMT Income ($b)9,980.710,491.511,019.711,594.812,124.412,676.213,252.313,855.014,479.6
AMT Liability ($b)18.313.210.710.711.111.511.912.513.0
AMT Filers (#m)5.54.94.54.84.84.94.95.05.1
Tax before Credits ($b)1,279.01,364.51,449.61,540.51,622.21,706.81,794.61,887.21,982.3
Refundable Credits ($b)81.082.784.987.089.191.293.395.497.5
Nonrefundable Credits ($b)28.728.828.728.628.528.328.127.927.6
Reform Surtaxes ($b)0.00.00.00.00.00.00.00.00.0
Other Taxes ($b)9.39.910.511.211.812.513.214.014.8
Ind Income Tax ($b)1,178.61,262.91,346.61,436.11,516.41,599.81,686.41,777.91,871.9
Payroll Taxes ($b)1,230.31,287.01,341.21,399.01,462.01,529.01,599.41,673.41,750.8
Combined Liability ($b)2,408.92,549.92,687.82,835.12,978.43,128.83,285.93,451.23,622.7
With Income Tax <= 0 (#m)79.179.680.280.781.381.982.483.083.5
With Combined Tax <= 0 (#m)49.750.150.651.051.551.952.352.853.2
\n", "
" ], "text/plain": [ " 2018 2019 2020 2021 2022 \\\n", "Returns (#m) 169.9 172.2 174.5 176.9 179.3 \n", "AGI ($b) 10,477.2 10,959.6 11,445.2 11,968.7 12,528.8 \n", "Itemizers (#m) 29.0 25.1 20.9 17.3 18.1 \n", "Itemized Deduction ($b) 808.7 678.4 542.5 423.0 457.2 \n", "Standard Deduction Filers (#m) 122.9 128.8 135.1 140.8 142.1 \n", "Standard Deduction ($b) 2,117.1 2,280.0 2,459.2 2,638.7 2,726.2 \n", "Personal Exemption ($b) 1,222.6 1,266.2 1,312.4 1,361.2 1,412.5 \n", "Taxable Income ($b) 7,041.9 7,465.2 7,880.7 8,315.8 8,725.7 \n", "Regular Tax ($b) 1,260.7 1,351.3 1,438.9 1,529.8 1,611.1 \n", "AMT Income ($b) 9,980.7 10,491.5 11,019.7 11,594.8 12,124.4 \n", "AMT Liability ($b) 18.3 13.2 10.7 10.7 11.1 \n", "AMT Filers (#m) 5.5 4.9 4.5 4.8 4.8 \n", "Tax before Credits ($b) 1,279.0 1,364.5 1,449.6 1,540.5 1,622.2 \n", "Refundable Credits ($b) 81.0 82.7 84.9 87.0 89.1 \n", "Nonrefundable Credits ($b) 28.7 28.8 28.7 28.6 28.5 \n", "Reform Surtaxes ($b) 0.0 0.0 0.0 0.0 0.0 \n", "Other Taxes ($b) 9.3 9.9 10.5 11.2 11.8 \n", "Ind Income Tax ($b) 1,178.6 1,262.9 1,346.6 1,436.1 1,516.4 \n", "Payroll Taxes ($b) 1,230.3 1,287.0 1,341.2 1,399.0 1,462.0 \n", "Combined Liability ($b) 2,408.9 2,549.9 2,687.8 2,835.1 2,978.4 \n", "With Income Tax <= 0 (#m) 79.1 79.6 80.2 80.7 81.3 \n", "With Combined Tax <= 0 (#m) 49.7 50.1 50.6 51.0 51.5 \n", "\n", " 2023 2024 2025 2026 \n", "Returns (#m) 181.7 184.1 186.6 189.1 \n", "AGI ($b) 13,112.8 13,723.8 14,364.1 15,031.2 \n", "Itemizers (#m) 18.9 19.8 20.7 21.7 \n", "Itemized Deduction ($b) 493.1 532.0 573.8 621.1 \n", "Standard Deduction Filers (#m) 143.5 144.8 146.2 147.4 \n", "Standard Deduction ($b) 2,815.1 2,907.4 3,001.2 3,096.2 \n", "Personal Exemption ($b) 1,464.9 1,519.7 1,576.1 1,634.7 \n", "Taxable Income ($b) 9,154.7 9,603.3 10,075.1 10,565.3 \n", "Regular Tax ($b) 1,695.3 1,782.7 1,874.7 1,969.3 \n", "AMT Income ($b) 12,676.2 13,252.3 13,855.0 14,479.6 \n", "AMT Liability ($b) 11.5 11.9 12.5 13.0 \n", "AMT Filers (#m) 4.9 4.9 5.0 5.1 \n", "Tax before Credits ($b) 1,706.8 1,794.6 1,887.2 1,982.3 \n", "Refundable Credits ($b) 91.2 93.3 95.4 97.5 \n", "Nonrefundable Credits ($b) 28.3 28.1 27.9 27.6 \n", "Reform Surtaxes ($b) 0.0 0.0 0.0 0.0 \n", "Other Taxes ($b) 12.5 13.2 14.0 14.8 \n", "Ind Income Tax ($b) 1,599.8 1,686.4 1,777.9 1,871.9 \n", "Payroll Taxes ($b) 1,529.0 1,599.4 1,673.4 1,750.8 \n", "Combined Liability ($b) 3,128.8 3,285.9 3,451.2 3,622.7 \n", "With Income Tax <= 0 (#m) 81.9 82.4 83.0 83.5 \n", "With Combined Tax <= 0 (#m) 51.9 52.3 52.8 53.2 " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "multiyear_diagnostic_table(calc_response, num_years=9)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Reporting your changes\n", "\n", "To display what reforms you included in a way that is easy for humans to read, you can use the `reform_documentation` method. It will print out all of the policy parameters you've specified with a short description and their default and current values\n", "\n", "\n", "_Note: this feature is not yet available in the taxcalc package. You must use the source code to access it. It will be available in the next taxcalc release._" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "REFORM DOCUMENTATION\n", "Baseline Growth-Difference Assumption Values by Year:\n", "none: using default baseline growth assumptions\n", "Policy Reform Parameter Values by Year:\n", "2018:\n", " _ID_RealEstate_hc : 0.25\n", " name: State, local, and foreign real estate taxes deduction haircut.\n", " desc: This decimal fraction reduces real estate taxes paid eligible to\n", " deduct in itemized deduction.\n", " baseline_value: 0.0\n", " _ID_StateLocalTax_hc : 0.25\n", " name: State and local income and sales taxes deduction haircut.\n", " desc: This decimal fraction reduces the state and local income and sales tax\n", " deduction.\n", " baseline_value: 0.0\n", " _II_rt1 : 0.12\n", " name: Personal income (regular/non-AMT/non-pass-through) tax rate 1\n", " desc: The lowest tax rate, applied to the portion of taxable income below\n", " tax bracket 1.\n", " baseline_value: 0.1\n", " _II_rt2 : 0.12\n", " name: Personal income (regular/non-AMT/non-pass-through) tax rate 2\n", " desc: The second lowest tax rate, applied to the portion of taxable income\n", " below tax bracket 2 and above tax bracket 1.\n", " baseline_value: 0.15\n", " _II_rt7 : 0.35\n", " name: Personal income (regular/non-AMT/non-pass-through) tax rate 7\n", " desc: The tax rate applied to the portion of taxable income below tax\n", " bracket 7 and above tax bracket 6.\n", " baseline_value: 0.396\n", " _STD : [12000, 24000, 12000, 18000, 24000]\n", " ['single', 'joint', 'separate', 'headhousehold', 'widow']\n", " name: Standard deduction amount\n", " desc: Amount filing unit can use as a standard deduction.\n", " baseline_value: [6492.88, 12985.75, 6492.88, 9560.38, 12985.75]\n", "2019:\n", " _ID_RealEstate_hc : 0.5\n", " name: State, local, and foreign real estate taxes deduction haircut.\n", " desc: This decimal fraction reduces real estate taxes paid eligible to\n", " deduct in itemized deduction.\n", " baseline_value: 0.0\n", " _ID_StateLocalTax_hc : 0.5\n", " name: State and local income and sales taxes deduction haircut.\n", " desc: This decimal fraction reduces the state and local income and sales tax\n", " deduction.\n", " baseline_value: 0.0\n", "2020:\n", " _ID_RealEstate_hc : 0.75\n", " name: State, local, and foreign real estate taxes deduction haircut.\n", " desc: This decimal fraction reduces real estate taxes paid eligible to\n", " deduct in itemized deduction.\n", " baseline_value: 0.0\n", " _ID_StateLocalTax_hc : 0.75\n", " name: State and local income and sales taxes deduction haircut.\n", " desc: This decimal fraction reduces the state and local income and sales tax\n", " deduction.\n", " baseline_value: 0.0\n", "2021:\n", " _ID_RealEstate_hc : 1.0\n", " name: State, local, and foreign real estate taxes deduction haircut.\n", " desc: This decimal fraction reduces real estate taxes paid eligible to\n", " deduct in itemized deduction.\n", " baseline_value: 0.0\n", " _ID_StateLocalTax_hc : 1.0\n", " name: State and local income and sales taxes deduction haircut.\n", " desc: This decimal fraction reduces the state and local income and sales tax\n", " deduction.\n", " baseline_value: 0.0\n", "\n" ] } ], "source": [ "print(calc_response.reform_documentation(reforms))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One thing I didn't cover is how to extract the marginal tax rates. All you need to do is call the `Calculator.mtr()` method. It will return MTR for individual income tax, payroll tax, and individaul income tax + payroll tax" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": true }, "outputs": [], "source": [ "mtr_payroll, mtr_income, mtr_combined = calc.mtr()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ 0.14212726, 0.14212726, 0.14212726, ..., 0.14212726,\n", " 0.14212726, 0.14212726])" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mtr_payroll" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ 0.13934046, 0. , 0. , ..., 0.23687877,\n", " 0.23687877, 0.23687877])" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mtr_income" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ 0.28146772, 0.14212726, 0.14212726, ..., 0.37900604,\n", " 0.37900604, 0.37900604])" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mtr_combined" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.14" } }, "nbformat": 4, "nbformat_minor": 2 }