diff --git a/docs/cruncher_demo.ipynb b/docs/cruncher_demo.ipynb new file mode 100644 index 0000000..fd32376 --- /dev/null +++ b/docs/cruncher_demo.ipynb @@ -0,0 +1,1556 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Batch analysis\n", + "\n", + "The `Batch:` class allows users to analyze the tax liabilities of a batch of filing units under current law and under a tax policy reform. \n", + "\n", + "## Inputs\n", + "\n", + "The class is initialized with a file path to CSV input -- each column contains data on a different tax information variable (e.g. year, marital status, wages, etc.) and each row represents a different filing unit. A detailed discussion of the inputs is [here](https://github.com/PSLmodels/Tax-Cruncher/blob/master/docs/INPUT_INSTRUCTIONS.md)." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# import the Batch class\n", + "from taxcrunch.multi_cruncher import Batch" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# path to input csv file\n", + "path = '../docs/example_input.csv'\n", + "\n", + "# initialize an object of the Batch class\n", + "b = Batch(path)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Outputs\n", + "\n", + "Now, we can create a few tables that will show us a detailed breakdown of each filing unit's tax liabilities.\n", + "\n", + "- The `create_table()` method returns a Pandas DataFrame in which each row is a filing unit and each column is an aspect of its tax burden under current law or policy reform. The `write_output_file()` method writes the table as a CSV file.\n", + "\n", + "- The `create_diff_table()` method returns a difference table, where each column shows the difference between liabilities under current law and under policy reform. The `write_diff_file()` method writes the difference table as a CSV file.\n", + "\n", + "To analyze a policy reform, specify the `reform_file` argument in any of the table-making methods. You may enter the file path to a json reform file, a dictionary, or the URL to a reform in the [Tax-Calculator repository](https://github.com/PSLmodels/Tax-Calculator/tree/master/taxcalc/reforms). Make sure that you reform adheres to Tax-Calculator [standards](https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/reforms/REFORMS.md). " + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "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", + "
IDIndividual Income TaxPayroll TaxWagesAGIUI in AGIOASDI in AGIItemized DeductionsTaxable IncRegular Tax...Child care creditEITCAMT Taxable IncomeAMT LiabilityNet Investment Income TaxIncome Tax Before CreditsFICAPayroll Tax MTRIncome Tax MTRCombined MTR
01.023397.14720021137.96192160000.0164500.00.00.00.0146096.827397.1472...0.00.000000164500.00.00.027397.147221137.961920.0290.24000.2690
12.0-5385.3960647267.5000047500.047800.00.00.00.023262.42365.9536...0.01751.34966447800.00.00.02365.95367267.500000.1530.33060.4836
23.010049.40880010710.0000070000.080000.00.00.00.067731.210049.4088...0.00.00000080000.00.00.010049.408810710.000000.1530.22000.3730
34.07538.81760018819.00000123000.0124200.00.00.00.099662.413538.8176...0.00.000000124200.00.00.013538.817618819.000000.1530.22000.3730
45.040659.74560023747.96192250000.0251200.00.00.00.0226662.442614.1456...0.00.000000251200.00.045.642614.145623747.961920.0380.24000.2780
56.0-530.6300001683.0000011000.011000.00.00.00.00.00.0000...0.0530.63000011000.00.00.00.00001683.000000.1530.00000.1530
67.0-3402.2893885967.0000039000.039250.00.00.00.020846.82193.5232...0.01595.81258839250.00.00.02193.52325967.000000.1530.33060.4836
\n", + "

7 rows × 22 columns

\n", + "
" + ], + "text/plain": [ + " ID Individual Income Tax Payroll Tax Wages AGI UI in AGI \\\n", + "0 1.0 23397.147200 21137.96192 160000.0 164500.0 0.0 \n", + "1 2.0 -5385.396064 7267.50000 47500.0 47800.0 0.0 \n", + "2 3.0 10049.408800 10710.00000 70000.0 80000.0 0.0 \n", + "3 4.0 7538.817600 18819.00000 123000.0 124200.0 0.0 \n", + "4 5.0 40659.745600 23747.96192 250000.0 251200.0 0.0 \n", + "5 6.0 -530.630000 1683.00000 11000.0 11000.0 0.0 \n", + "6 7.0 -3402.289388 5967.00000 39000.0 39250.0 0.0 \n", + "\n", + " OASDI in AGI Itemized Deductions Taxable Inc Regular Tax ... \\\n", + "0 0.0 0.0 146096.8 27397.1472 ... \n", + "1 0.0 0.0 23262.4 2365.9536 ... \n", + "2 0.0 0.0 67731.2 10049.4088 ... \n", + "3 0.0 0.0 99662.4 13538.8176 ... \n", + "4 0.0 0.0 226662.4 42614.1456 ... \n", + "5 0.0 0.0 0.0 0.0000 ... \n", + "6 0.0 0.0 20846.8 2193.5232 ... \n", + "\n", + " Child care credit EITC AMT Taxable Income AMT Liability \\\n", + "0 0.0 0.000000 164500.0 0.0 \n", + "1 0.0 1751.349664 47800.0 0.0 \n", + "2 0.0 0.000000 80000.0 0.0 \n", + "3 0.0 0.000000 124200.0 0.0 \n", + "4 0.0 0.000000 251200.0 0.0 \n", + "5 0.0 530.630000 11000.0 0.0 \n", + "6 0.0 1595.812588 39250.0 0.0 \n", + "\n", + " Net Investment Income Tax Income Tax Before Credits FICA \\\n", + "0 0.0 27397.1472 21137.96192 \n", + "1 0.0 2365.9536 7267.50000 \n", + "2 0.0 10049.4088 10710.00000 \n", + "3 0.0 13538.8176 18819.00000 \n", + "4 45.6 42614.1456 23747.96192 \n", + "5 0.0 0.0000 1683.00000 \n", + "6 0.0 2193.5232 5967.00000 \n", + "\n", + " Payroll Tax MTR Income Tax MTR Combined MTR \n", + "0 0.029 0.2400 0.2690 \n", + "1 0.153 0.3306 0.4836 \n", + "2 0.153 0.2200 0.3730 \n", + "3 0.153 0.2200 0.3730 \n", + "4 0.038 0.2400 0.2780 \n", + "5 0.153 0.0000 0.1530 \n", + "6 0.153 0.3306 0.4836 \n", + "\n", + "[7 rows x 22 columns]" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# outputs under current law (no reform)\n", + "b.create_table()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CTC_c was redefined in release 1.0.0\n", + "\n", + "CTC_c was redefined in release 1.0.0\n", + "\n" + ] + }, + { + "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", + "
IDIndividual Income TaxPayroll TaxWagesAGIUI in AGIOASDI in AGIItemized DeductionsTaxable IncRegular Tax...Child care creditEITCAMT Taxable IncomeAMT LiabilityNet Investment Income TaxIncome Tax Before CreditsFICAPayroll Tax MTRIncome Tax MTRCombined MTR
01.029979.88925021137.96192160000.0164500.00.00.00.0141997.5129039.2814...0.00.000000164500.0940.607850.029979.8892521137.961920.0290.32500.3540
12.0-3521.3995687267.5000047500.047800.00.00.00.013313.631301.3630...0.01822.76256847800.00.000000.01301.363007267.500000.1530.31060.4636
23.011818.82450010710.0000070000.080000.00.00.00.069115.0711818.8245...0.00.00000080000.00.000000.011818.8245010710.000000.1530.25000.4030
34.011098.52100018819.00000123000.0124200.00.00.00.089713.6313388.5210...0.00.000000124200.00.000000.013388.5210018819.000000.1530.30000.4530
45.049216.11840023747.96192250000.0251200.00.00.00.0225191.3149170.5184...0.00.000000251200.00.0000045.649170.5184023747.961920.0380.28000.3180
56.0-533.7800001683.0000011000.011000.00.00.00.00.000.0000...0.0533.78000011000.00.000000.00.000001683.000000.1530.00000.1530
67.0-1878.3081965967.0000039000.039250.00.00.00.016747.511776.0025...0.01654.31069639250.00.000000.01776.002505967.000000.1530.36060.5136
\n", + "

7 rows × 22 columns

\n", + "
" + ], + "text/plain": [ + " ID Individual Income Tax Payroll Tax Wages AGI UI in AGI \\\n", + "0 1.0 29979.889250 21137.96192 160000.0 164500.0 0.0 \n", + "1 2.0 -3521.399568 7267.50000 47500.0 47800.0 0.0 \n", + "2 3.0 11818.824500 10710.00000 70000.0 80000.0 0.0 \n", + "3 4.0 11098.521000 18819.00000 123000.0 124200.0 0.0 \n", + "4 5.0 49216.118400 23747.96192 250000.0 251200.0 0.0 \n", + "5 6.0 -533.780000 1683.00000 11000.0 11000.0 0.0 \n", + "6 7.0 -1878.308196 5967.00000 39000.0 39250.0 0.0 \n", + "\n", + " OASDI in AGI Itemized Deductions Taxable Inc Regular Tax ... \\\n", + "0 0.0 0.0 141997.51 29039.2814 ... \n", + "1 0.0 0.0 13313.63 1301.3630 ... \n", + "2 0.0 0.0 69115.07 11818.8245 ... \n", + "3 0.0 0.0 89713.63 13388.5210 ... \n", + "4 0.0 0.0 225191.31 49170.5184 ... \n", + "5 0.0 0.0 0.00 0.0000 ... \n", + "6 0.0 0.0 16747.51 1776.0025 ... \n", + "\n", + " Child care credit EITC AMT Taxable Income AMT Liability \\\n", + "0 0.0 0.000000 164500.0 940.60785 \n", + "1 0.0 1822.762568 47800.0 0.00000 \n", + "2 0.0 0.000000 80000.0 0.00000 \n", + "3 0.0 0.000000 124200.0 0.00000 \n", + "4 0.0 0.000000 251200.0 0.00000 \n", + "5 0.0 533.780000 11000.0 0.00000 \n", + "6 0.0 1654.310696 39250.0 0.00000 \n", + "\n", + " Net Investment Income Tax Income Tax Before Credits FICA \\\n", + "0 0.0 29979.88925 21137.96192 \n", + "1 0.0 1301.36300 7267.50000 \n", + "2 0.0 11818.82450 10710.00000 \n", + "3 0.0 13388.52100 18819.00000 \n", + "4 45.6 49170.51840 23747.96192 \n", + "5 0.0 0.00000 1683.00000 \n", + "6 0.0 1776.00250 5967.00000 \n", + "\n", + " Payroll Tax MTR Income Tax MTR Combined MTR \n", + "0 0.029 0.3250 0.3540 \n", + "1 0.153 0.3106 0.4636 \n", + "2 0.153 0.2500 0.4030 \n", + "3 0.153 0.3000 0.4530 \n", + "4 0.038 0.2800 0.3180 \n", + "5 0.153 0.0000 0.1530 \n", + "6 0.153 0.3606 0.5136 \n", + "\n", + "[7 rows x 22 columns]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# outputs under reform\n", + "b.create_table(reform_file='../taxcrunch/tests/test_reform.json')" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CTC_c was redefined in release 1.0.0\n", + "\n", + "CTC_c was redefined in release 1.0.0\n", + "\n" + ] + }, + { + "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", + "
IDIndividual Income Tax DiffPayroll Tax DiffWages DiffAGI DiffUI in AGI DiffOASDI in AGI DiffItemized Deductions DiffTaxable Inc DiffRegular Tax Diff...Child care credit DiffEITC DiffAMT Taxable Income DiffAMT Liability DiffNet Investment Income Tax DiffIncome Tax Before Credits DiffFICA DiffPayroll Tax MTR DiffIncome Tax MTR DiffCombined MTR Diff
01.06582.7420500.00.00.00.00.00.0-4099.291642.1342...0.00.0000000.0940.607850.02582.742050.00.00.0850.085
12.01863.9964960.00.00.00.00.00.0-9948.77-1064.5906...0.071.4129040.00.000000.0-1064.590600.00.0-0.020-0.020
23.01769.4157000.00.00.00.00.00.01383.871769.4157...0.00.0000000.00.000000.01769.415700.00.00.0300.030
34.03559.7034000.00.00.00.00.00.0-9948.77-150.2966...0.00.0000000.00.000000.0-150.296600.00.00.0800.080
45.08556.3728000.00.00.00.00.00.0-1471.096556.3728...0.00.0000000.00.000000.06556.372800.00.00.0400.040
56.0-3.1500000.00.00.00.00.00.00.000.0000...0.03.1500000.00.000000.00.000000.00.00.0000.000
67.01523.9811920.00.00.00.00.00.0-4099.29-417.5207...0.058.4981080.00.000000.0-417.520700.00.00.0300.030
\n", + "

7 rows × 22 columns

\n", + "
" + ], + "text/plain": [ + " ID Individual Income Tax Diff Payroll Tax Diff Wages Diff AGI Diff \\\n", + "0 1.0 6582.742050 0.0 0.0 0.0 \n", + "1 2.0 1863.996496 0.0 0.0 0.0 \n", + "2 3.0 1769.415700 0.0 0.0 0.0 \n", + "3 4.0 3559.703400 0.0 0.0 0.0 \n", + "4 5.0 8556.372800 0.0 0.0 0.0 \n", + "5 6.0 -3.150000 0.0 0.0 0.0 \n", + "6 7.0 1523.981192 0.0 0.0 0.0 \n", + "\n", + " UI in AGI Diff OASDI in AGI Diff Itemized Deductions Diff \\\n", + "0 0.0 0.0 0.0 \n", + "1 0.0 0.0 0.0 \n", + "2 0.0 0.0 0.0 \n", + "3 0.0 0.0 0.0 \n", + "4 0.0 0.0 0.0 \n", + "5 0.0 0.0 0.0 \n", + "6 0.0 0.0 0.0 \n", + "\n", + " Taxable Inc Diff Regular Tax Diff ... Child care credit Diff EITC Diff \\\n", + "0 -4099.29 1642.1342 ... 0.0 0.000000 \n", + "1 -9948.77 -1064.5906 ... 0.0 71.412904 \n", + "2 1383.87 1769.4157 ... 0.0 0.000000 \n", + "3 -9948.77 -150.2966 ... 0.0 0.000000 \n", + "4 -1471.09 6556.3728 ... 0.0 0.000000 \n", + "5 0.00 0.0000 ... 0.0 3.150000 \n", + "6 -4099.29 -417.5207 ... 0.0 58.498108 \n", + "\n", + " AMT Taxable Income Diff AMT Liability Diff \\\n", + "0 0.0 940.60785 \n", + "1 0.0 0.00000 \n", + "2 0.0 0.00000 \n", + "3 0.0 0.00000 \n", + "4 0.0 0.00000 \n", + "5 0.0 0.00000 \n", + "6 0.0 0.00000 \n", + "\n", + " Net Investment Income Tax Diff Income Tax Before Credits Diff FICA Diff \\\n", + "0 0.0 2582.74205 0.0 \n", + "1 0.0 -1064.59060 0.0 \n", + "2 0.0 1769.41570 0.0 \n", + "3 0.0 -150.29660 0.0 \n", + "4 0.0 6556.37280 0.0 \n", + "5 0.0 0.00000 0.0 \n", + "6 0.0 -417.52070 0.0 \n", + "\n", + " Payroll Tax MTR Diff Income Tax MTR Diff Combined MTR Diff \n", + "0 0.0 0.085 0.085 \n", + "1 0.0 -0.020 -0.020 \n", + "2 0.0 0.030 0.030 \n", + "3 0.0 0.080 0.080 \n", + "4 0.0 0.040 0.040 \n", + "5 0.0 0.000 0.000 \n", + "6 0.0 0.030 0.030 \n", + "\n", + "[7 rows x 22 columns]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b.create_diff_table(reform_file='../taxcrunch/tests/test_reform.json')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Behavioral Responses\n", + "\n", + "Finally, the `Batch` class gives users the option to estimate behavioral responses to a tax policy reform. The three optional arguments for behavioral response analysis are:\n", + "\n", + "- `be_sub`: substitution elasticity of taxable income\n", + "- `be_inc`: income elasticity of taxable income\n", + "- `be_cg`: semi-elasticity of long-term capital gains\n", + "\n", + "The implementation of these elasticities is carried out by the [Behavioral-Responses](https://github.com/PSLmodels/Behavioral-Responses) project. Further discussion on the definition of the elasticities can be found [here](https://github.com/PSLmodels/Behavioral-Responses/blob/master/behresp/behavior.py)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CTC_c was redefined in release 1.0.0\n", + "\n", + "CTC_c was redefined in release 1.0.0\n", + "\n" + ] + }, + { + "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", + "
IDIndividual Income TaxPayroll TaxWagesAGIUI in AGIOASDI in AGIItemized DeductionsTaxable IncRegular Tax...Child care creditEITCAMT Taxable IncomeAMT LiabilityNet Investment Income TaxIncome Tax Before CreditsFICAPayroll Tax MTRIncome Tax MTRCombined MTR
01.028626.46063821020.498113155949.523912160335.6042720.00.00.0137833.11427227992.784568...0.00.000000160335.604272633.676070.028626.46063821020.4981130.0290.32500.3540
12.0-3460.4676967297.32635747694.94351147996.1747330.00.00.013509.8047331320.980473...0.01781.44816947996.1747330.000000.01320.9804737297.3263570.1530.31060.4636
23.011638.30424610613.33140469368.17911379277.9189860.00.00.068392.98898611638.304246...0.00.00000079277.9189860.000000.011638.30424610613.3314040.1530.25000.4030
34.010248.52185818389.688839120194.044702121366.6695280.00.00.086880.29952812680.188382...0.00.000000121366.6695280.000000.012680.18838218389.6888390.1530.30000.4530
45.048308.80117123659.138986246937.140197248122.4384700.00.00.0222113.74847048308.801171...0.00.000000248122.4384700.000000.048308.80117123659.1389860.0380.28000.3180
56.0-533.7800001683.00000011000.00000011000.0000000.00.00.00.0000000.000000...0.0533.78000011000.0000000.000000.00.0000001683.0000000.1530.00000.1530
67.0-1973.4004055926.91004338737.97413838986.2944850.00.00.016483.8044851736.446673...0.01709.84707738986.2944850.000000.01736.4466735926.9100430.1530.36060.5136
\n", + "

7 rows × 22 columns

\n", + "
" + ], + "text/plain": [ + " ID Individual Income Tax Payroll Tax Wages AGI \\\n", + "0 1.0 28626.460638 21020.498113 155949.523912 160335.604272 \n", + "1 2.0 -3460.467696 7297.326357 47694.943511 47996.174733 \n", + "2 3.0 11638.304246 10613.331404 69368.179113 79277.918986 \n", + "3 4.0 10248.521858 18389.688839 120194.044702 121366.669528 \n", + "4 5.0 48308.801171 23659.138986 246937.140197 248122.438470 \n", + "5 6.0 -533.780000 1683.000000 11000.000000 11000.000000 \n", + "6 7.0 -1973.400405 5926.910043 38737.974138 38986.294485 \n", + "\n", + " UI in AGI OASDI in AGI Itemized Deductions Taxable Inc Regular Tax \\\n", + "0 0.0 0.0 0.0 137833.114272 27992.784568 \n", + "1 0.0 0.0 0.0 13509.804733 1320.980473 \n", + "2 0.0 0.0 0.0 68392.988986 11638.304246 \n", + "3 0.0 0.0 0.0 86880.299528 12680.188382 \n", + "4 0.0 0.0 0.0 222113.748470 48308.801171 \n", + "5 0.0 0.0 0.0 0.000000 0.000000 \n", + "6 0.0 0.0 0.0 16483.804485 1736.446673 \n", + "\n", + " ... Child care credit EITC AMT Taxable Income AMT Liability \\\n", + "0 ... 0.0 0.000000 160335.604272 633.67607 \n", + "1 ... 0.0 1781.448169 47996.174733 0.00000 \n", + "2 ... 0.0 0.000000 79277.918986 0.00000 \n", + "3 ... 0.0 0.000000 121366.669528 0.00000 \n", + "4 ... 0.0 0.000000 248122.438470 0.00000 \n", + "5 ... 0.0 533.780000 11000.000000 0.00000 \n", + "6 ... 0.0 1709.847077 38986.294485 0.00000 \n", + "\n", + " Net Investment Income Tax Income Tax Before Credits FICA \\\n", + "0 0.0 28626.460638 21020.498113 \n", + "1 0.0 1320.980473 7297.326357 \n", + "2 0.0 11638.304246 10613.331404 \n", + "3 0.0 12680.188382 18389.688839 \n", + "4 0.0 48308.801171 23659.138986 \n", + "5 0.0 0.000000 1683.000000 \n", + "6 0.0 1736.446673 5926.910043 \n", + "\n", + " Payroll Tax MTR Income Tax MTR Combined MTR \n", + "0 0.029 0.3250 0.3540 \n", + "1 0.153 0.3106 0.4636 \n", + "2 0.153 0.2500 0.4030 \n", + "3 0.153 0.3000 0.4530 \n", + "4 0.038 0.2800 0.3180 \n", + "5 0.153 0.0000 0.1530 \n", + "6 0.153 0.3606 0.5136 \n", + "\n", + "[7 rows x 22 columns]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b.create_table(reform_file='../taxcrunch/tests/test_reform.json', be_sub=0.25)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CTC_c was redefined in release 1.0.0\n", + "\n", + "CTC_c was redefined in release 1.0.0\n", + "\n" + ] + }, + { + "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", + "
IDIndividual Income Tax DiffPayroll Tax DiffWages DiffAGI DiffUI in AGI DiffOASDI in AGI DiffItemized Deductions DiffTaxable Inc DiffRegular Tax Diff...Child care credit DiffEITC DiffAMT Taxable Income DiffAMT Liability DiffNet Investment Income Tax DiffIncome Tax Before Credits DiffFICA DiffPayroll Tax MTR DiffIncome Tax MTR DiffCombined MTR Diff
01.05229.313438-117.463807-4050.476088-4164.3957280.00.00.0-8263.685728595.637368...0.00.000000-4164.395728633.676070.01229.313438-117.4638070.00.0850.085
12.01924.92836829.826357194.943511196.1747330.00.00.0-9752.595267-1044.973127...0.030.098505196.1747330.000000.0-1044.97312729.8263570.0-0.020-0.020
23.01588.895446-96.668596-631.820887-722.0810140.00.00.0661.7889861588.895446...0.00.000000-722.0810140.000000.01588.895446-96.6685960.00.0300.030
34.02709.704258-429.311161-2805.955298-2833.3304720.00.00.0-12782.100472-858.629218...0.00.000000-2833.3304720.000000.0-858.629218-429.3111610.00.0800.080
45.07649.055571-88.822934-3062.859803-3077.5615300.00.00.0-4548.6515305694.655571...0.00.000000-3077.5615300.00000-45.65694.655571-88.8229340.00.0400.040
56.0-3.1500000.0000000.0000000.0000000.00.00.00.0000000.000000...0.03.1500000.0000000.000000.00.0000000.0000000.00.0000.000
67.01428.888983-40.089957-262.025862-263.7055150.00.00.0-4362.995515-457.076527...0.0114.034489-263.7055150.000000.0-457.076527-40.0899570.00.0300.030
\n", + "

7 rows × 22 columns

\n", + "
" + ], + "text/plain": [ + " ID Individual Income Tax Diff Payroll Tax Diff Wages Diff \\\n", + "0 1.0 5229.313438 -117.463807 -4050.476088 \n", + "1 2.0 1924.928368 29.826357 194.943511 \n", + "2 3.0 1588.895446 -96.668596 -631.820887 \n", + "3 4.0 2709.704258 -429.311161 -2805.955298 \n", + "4 5.0 7649.055571 -88.822934 -3062.859803 \n", + "5 6.0 -3.150000 0.000000 0.000000 \n", + "6 7.0 1428.888983 -40.089957 -262.025862 \n", + "\n", + " AGI Diff UI in AGI Diff OASDI in AGI Diff Itemized Deductions Diff \\\n", + "0 -4164.395728 0.0 0.0 0.0 \n", + "1 196.174733 0.0 0.0 0.0 \n", + "2 -722.081014 0.0 0.0 0.0 \n", + "3 -2833.330472 0.0 0.0 0.0 \n", + "4 -3077.561530 0.0 0.0 0.0 \n", + "5 0.000000 0.0 0.0 0.0 \n", + "6 -263.705515 0.0 0.0 0.0 \n", + "\n", + " Taxable Inc Diff Regular Tax Diff ... Child care credit Diff \\\n", + "0 -8263.685728 595.637368 ... 0.0 \n", + "1 -9752.595267 -1044.973127 ... 0.0 \n", + "2 661.788986 1588.895446 ... 0.0 \n", + "3 -12782.100472 -858.629218 ... 0.0 \n", + "4 -4548.651530 5694.655571 ... 0.0 \n", + "5 0.000000 0.000000 ... 0.0 \n", + "6 -4362.995515 -457.076527 ... 0.0 \n", + "\n", + " EITC Diff AMT Taxable Income Diff AMT Liability Diff \\\n", + "0 0.000000 -4164.395728 633.67607 \n", + "1 30.098505 196.174733 0.00000 \n", + "2 0.000000 -722.081014 0.00000 \n", + "3 0.000000 -2833.330472 0.00000 \n", + "4 0.000000 -3077.561530 0.00000 \n", + "5 3.150000 0.000000 0.00000 \n", + "6 114.034489 -263.705515 0.00000 \n", + "\n", + " Net Investment Income Tax Diff Income Tax Before Credits Diff FICA Diff \\\n", + "0 0.0 1229.313438 -117.463807 \n", + "1 0.0 -1044.973127 29.826357 \n", + "2 0.0 1588.895446 -96.668596 \n", + "3 0.0 -858.629218 -429.311161 \n", + "4 -45.6 5694.655571 -88.822934 \n", + "5 0.0 0.000000 0.000000 \n", + "6 0.0 -457.076527 -40.089957 \n", + "\n", + " Payroll Tax MTR Diff Income Tax MTR Diff Combined MTR Diff \n", + "0 0.0 0.085 0.085 \n", + "1 0.0 -0.020 -0.020 \n", + "2 0.0 0.030 0.030 \n", + "3 0.0 0.080 0.080 \n", + "4 0.0 0.040 0.040 \n", + "5 0.0 0.000 0.000 \n", + "6 0.0 0.030 0.030 \n", + "\n", + "[7 rows x 22 columns]" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b.create_diff_table(reform_file='../taxcrunch/tests/test_reform.json', be_sub=0.25)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/example_adjustment.json b/docs/example_adjustment.json deleted file mode 100644 index 8df4faa..0000000 --- a/docs/example_adjustment.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "mstat": [ - {"value": "Joint"} - ], - "page": [ - {"value": 60} - ], - "sage": [ - {"value": 55} - ], - "depx": [ - {"value": 2} - ], - "dep13": [ - {"value": 0} - ], - "dep17": [ - {"value": 2} - ], - "dep18": [ - {"value": 2} - ], - "pwages": [ - {"value": 40000} - ], - "swages": [ - {"value": 30000} - ], - "stcg": [ - {"value": 1000} - ], - "pensions": [ - {"value": 10000} - ], - "reform_options": [ - {"value": "2017_law.json"} - ] -} \ No newline at end of file diff --git a/docs/example_multi.ipynb b/docs/example_multi.ipynb deleted file mode 100644 index 58d8f76..0000000 --- a/docs/example_multi.ipynb +++ /dev/null @@ -1,1194 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from taxcrunch.multi_cruncher import Batch" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "#specify path to input csv file\n", - "path = 'example_input.csv'\n", - "#initiate Batch class\n", - "b = Batch(path)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "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", - "
IDIndividual Income TaxPayroll TaxWagesAGIUI in AGIOASDI in AGIItemized DeductionsTaxable IncRegular Tax...Child care creditEITCAMT Taxable IncomeAMT LiabilityNet Investment Income TaxIncome Tax Before CreditsFICAPayroll Tax MTRIncome Tax MTRCombined MTR
01.023397.14720021137.96192160000.0164500.00.00.00.0146096.827397.1472...0.00.000000164500.00.00.027397.147221137.961920.0290.24000.2690
12.0-5385.3960647267.5000047500.047800.00.00.00.023262.42365.9536...0.01751.34966447800.00.00.02365.95367267.500000.1530.33060.4836
23.010049.40880010710.0000070000.080000.00.00.00.067731.210049.4088...0.00.00000080000.00.00.010049.408810710.000000.1530.22000.3730
34.06538.81760018819.00000123000.0124200.00.00.00.099662.413538.8176...0.00.000000124200.00.00.013538.817618819.000000.1530.22000.3730
45.040659.74560023747.96192250000.0251200.00.00.00.0226662.442614.1456...0.00.000000251200.00.045.642614.145623747.961920.0380.24000.2780
56.0-530.6300001683.0000011000.011000.00.00.00.00.00.0000...0.0530.63000011000.00.00.00.00001683.000000.1530.00000.1530
67.0-3402.2893885967.0000039000.039250.00.00.00.020846.82193.5232...0.01595.81258839250.00.00.02193.52325967.000000.1530.33060.4836
\n", - "

7 rows × 22 columns

\n", - "
" - ], - "text/plain": [ - " ID Individual Income Tax Payroll Tax Wages AGI UI in AGI \\\n", - "0 1.0 23397.147200 21137.96192 160000.0 164500.0 0.0 \n", - "1 2.0 -5385.396064 7267.50000 47500.0 47800.0 0.0 \n", - "2 3.0 10049.408800 10710.00000 70000.0 80000.0 0.0 \n", - "3 4.0 6538.817600 18819.00000 123000.0 124200.0 0.0 \n", - "4 5.0 40659.745600 23747.96192 250000.0 251200.0 0.0 \n", - "5 6.0 -530.630000 1683.00000 11000.0 11000.0 0.0 \n", - "6 7.0 -3402.289388 5967.00000 39000.0 39250.0 0.0 \n", - "\n", - " OASDI in AGI Itemized Deductions Taxable Inc Regular Tax ... \\\n", - "0 0.0 0.0 146096.8 27397.1472 ... \n", - "1 0.0 0.0 23262.4 2365.9536 ... \n", - "2 0.0 0.0 67731.2 10049.4088 ... \n", - "3 0.0 0.0 99662.4 13538.8176 ... \n", - "4 0.0 0.0 226662.4 42614.1456 ... \n", - "5 0.0 0.0 0.0 0.0000 ... \n", - "6 0.0 0.0 20846.8 2193.5232 ... \n", - "\n", - " Child care credit EITC AMT Taxable Income AMT Liability \\\n", - "0 0.0 0.000000 164500.0 0.0 \n", - "1 0.0 1751.349664 47800.0 0.0 \n", - "2 0.0 0.000000 80000.0 0.0 \n", - "3 0.0 0.000000 124200.0 0.0 \n", - "4 0.0 0.000000 251200.0 0.0 \n", - "5 0.0 530.630000 11000.0 0.0 \n", - "6 0.0 1595.812588 39250.0 0.0 \n", - "\n", - " Net Investment Income Tax Income Tax Before Credits FICA \\\n", - "0 0.0 27397.1472 21137.96192 \n", - "1 0.0 2365.9536 7267.50000 \n", - "2 0.0 10049.4088 10710.00000 \n", - "3 0.0 13538.8176 18819.00000 \n", - "4 45.6 42614.1456 23747.96192 \n", - "5 0.0 0.0000 1683.00000 \n", - "6 0.0 2193.5232 5967.00000 \n", - "\n", - " Payroll Tax MTR Income Tax MTR Combined MTR \n", - "0 0.029 0.2400 0.2690 \n", - "1 0.153 0.3306 0.4836 \n", - "2 0.153 0.2200 0.3730 \n", - "3 0.153 0.2200 0.3730 \n", - "4 0.038 0.2400 0.2780 \n", - "5 0.153 0.0000 0.1530 \n", - "6 0.153 0.3306 0.4836 \n", - "\n", - "[7 rows x 22 columns]" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# outputs under current law (no reform)\n", - "b.create_table()" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CTC_c was redefined in release 1.0.0\n", - "\n" - ] - }, - { - "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", - "
IDIndividual Income TaxPayroll TaxWagesAGIUI in AGIOASDI in AGIItemized DeductionsTaxable IncRegular Tax...Child care creditEITCAMT Taxable IncomeAMT LiabilityNet Investment Income TaxIncome Tax Before CreditsFICAPayroll Tax MTRIncome Tax MTRCombined MTR
01.029979.88925021137.96192160000.0164500.00.00.00.0141997.5129039.2814...0.00.000000164500.0940.607850.029979.8892521137.961920.0290.32500.3540
12.0-3521.3995687267.5000047500.047800.00.00.00.013313.631301.3630...0.01822.76256847800.00.000000.01301.363007267.500000.1530.31060.4636
23.011818.82450010710.0000070000.080000.00.00.00.069115.0711818.8245...0.00.00000080000.00.000000.011818.8245010710.000000.1530.25000.4030
34.08979.10100018819.00000123000.0124200.00.00.00.081235.9511269.1010...0.00.000000124200.00.000000.011269.1010018819.000000.1530.30000.4530
45.049216.11840023747.96192250000.0251200.00.00.00.0225191.3149170.5184...0.00.000000251200.00.0000045.649170.5184023747.961920.0380.28000.3180
56.0-533.7800001683.0000011000.011000.00.00.00.00.000.0000...0.0533.78000011000.00.000000.00.000001683.000000.1530.00000.1530
67.0-1878.3081965967.0000039000.039250.00.00.00.016747.511776.0025...0.01654.31069639250.00.000000.01776.002505967.000000.1530.36060.5136
\n", - "

7 rows × 22 columns

\n", - "
" - ], - "text/plain": [ - " ID Individual Income Tax Payroll Tax Wages AGI UI in AGI \\\n", - "0 1.0 29979.889250 21137.96192 160000.0 164500.0 0.0 \n", - "1 2.0 -3521.399568 7267.50000 47500.0 47800.0 0.0 \n", - "2 3.0 11818.824500 10710.00000 70000.0 80000.0 0.0 \n", - "3 4.0 8979.101000 18819.00000 123000.0 124200.0 0.0 \n", - "4 5.0 49216.118400 23747.96192 250000.0 251200.0 0.0 \n", - "5 6.0 -533.780000 1683.00000 11000.0 11000.0 0.0 \n", - "6 7.0 -1878.308196 5967.00000 39000.0 39250.0 0.0 \n", - "\n", - " OASDI in AGI Itemized Deductions Taxable Inc Regular Tax ... \\\n", - "0 0.0 0.0 141997.51 29039.2814 ... \n", - "1 0.0 0.0 13313.63 1301.3630 ... \n", - "2 0.0 0.0 69115.07 11818.8245 ... \n", - "3 0.0 0.0 81235.95 11269.1010 ... \n", - "4 0.0 0.0 225191.31 49170.5184 ... \n", - "5 0.0 0.0 0.00 0.0000 ... \n", - "6 0.0 0.0 16747.51 1776.0025 ... \n", - "\n", - " Child care credit EITC AMT Taxable Income AMT Liability \\\n", - "0 0.0 0.000000 164500.0 940.60785 \n", - "1 0.0 1822.762568 47800.0 0.00000 \n", - "2 0.0 0.000000 80000.0 0.00000 \n", - "3 0.0 0.000000 124200.0 0.00000 \n", - "4 0.0 0.000000 251200.0 0.00000 \n", - "5 0.0 533.780000 11000.0 0.00000 \n", - "6 0.0 1654.310696 39250.0 0.00000 \n", - "\n", - " Net Investment Income Tax Income Tax Before Credits FICA \\\n", - "0 0.0 29979.88925 21137.96192 \n", - "1 0.0 1301.36300 7267.50000 \n", - "2 0.0 11818.82450 10710.00000 \n", - "3 0.0 11269.10100 18819.00000 \n", - "4 45.6 49170.51840 23747.96192 \n", - "5 0.0 0.00000 1683.00000 \n", - "6 0.0 1776.00250 5967.00000 \n", - "\n", - " Payroll Tax MTR Income Tax MTR Combined MTR \n", - "0 0.029 0.3250 0.3540 \n", - "1 0.153 0.3106 0.4636 \n", - "2 0.153 0.2500 0.4030 \n", - "3 0.153 0.3000 0.4530 \n", - "4 0.038 0.2800 0.3180 \n", - "5 0.153 0.0000 0.1530 \n", - "6 0.153 0.3606 0.5136 \n", - "\n", - "[7 rows x 22 columns]" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# outputs under local reform\n", - "b.create_table('../taxcrunch/tests/test_reform.json')" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CTC_c was redefined in release 1.0.0\n", - "\n" - ] - }, - { - "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", - "
IDIndividual Income TaxPayroll TaxWagesAGIUI in AGIOASDI in AGIItemized DeductionsTaxable IncRegular Tax...CTC RefundableChild care creditEITCAMTNet Investment Income TaxIncome Tax Before CreditsFICAPayroll Tax MTRIncome Tax MTRCombined MTR
01.023797.14720021137.96192160000.0164500.00.00.00.0146096.827802.1472...0.00000.00.0000000.00.027397.147221137.961920.0290.24000.2690
12.0-4785.3960647267.5000047500.047800.00.00.00.023262.42401.9536...3034.04640.01751.3496640.00.02365.95367267.500000.1530.33060.4836
23.010049.40880010710.0000070000.080000.00.00.00.067731.210749.4088...0.00000.00.0000000.00.010049.408810710.000000.1530.22000.3730
34.07138.81760018819.00000123000.0124200.00.00.00.099662.413622.8176...0.00000.00.0000000.00.013538.817618819.000000.1530.22000.3730
45.040859.74560023747.96192250000.0251200.00.00.00.0226662.442722.1456...0.00000.00.0000000.045.642614.145623747.961920.0380.24000.2780
56.0-530.6300001683.0000011000.011000.00.00.00.00.00.0000...0.00000.0530.6300000.00.00.00001683.000000.1530.00000.1530
67.0-3002.2893885967.0000039000.039250.00.00.00.020846.82223.5232...1406.47680.01595.8125880.00.02193.52325967.000000.1530.33060.4836
\n", - "

7 rows × 21 columns

\n", - "
" - ], - "text/plain": [ - " ID Individual Income Tax Payroll Tax Wages AGI UI in AGI \\\n", - "0 1.0 23797.147200 21137.96192 160000.0 164500.0 0.0 \n", - "1 2.0 -4785.396064 7267.50000 47500.0 47800.0 0.0 \n", - "2 3.0 10049.408800 10710.00000 70000.0 80000.0 0.0 \n", - "3 4.0 7138.817600 18819.00000 123000.0 124200.0 0.0 \n", - "4 5.0 40859.745600 23747.96192 250000.0 251200.0 0.0 \n", - "5 6.0 -530.630000 1683.00000 11000.0 11000.0 0.0 \n", - "6 7.0 -3002.289388 5967.00000 39000.0 39250.0 0.0 \n", - "\n", - " OASDI in AGI Itemized Deductions Taxable Inc Regular Tax ... \\\n", - "0 0.0 0.0 146096.8 27802.1472 ... \n", - "1 0.0 0.0 23262.4 2401.9536 ... \n", - "2 0.0 0.0 67731.2 10749.4088 ... \n", - "3 0.0 0.0 99662.4 13622.8176 ... \n", - "4 0.0 0.0 226662.4 42722.1456 ... \n", - "5 0.0 0.0 0.0 0.0000 ... \n", - "6 0.0 0.0 20846.8 2223.5232 ... \n", - "\n", - " CTC Refundable Child care credit EITC AMT \\\n", - "0 0.0000 0.0 0.000000 0.0 \n", - "1 3034.0464 0.0 1751.349664 0.0 \n", - "2 0.0000 0.0 0.000000 0.0 \n", - "3 0.0000 0.0 0.000000 0.0 \n", - "4 0.0000 0.0 0.000000 0.0 \n", - "5 0.0000 0.0 530.630000 0.0 \n", - "6 1406.4768 0.0 1595.812588 0.0 \n", - "\n", - " Net Investment Income Tax Income Tax Before Credits FICA \\\n", - "0 0.0 27397.1472 21137.96192 \n", - "1 0.0 2365.9536 7267.50000 \n", - "2 0.0 10049.4088 10710.00000 \n", - "3 0.0 13538.8176 18819.00000 \n", - "4 45.6 42614.1456 23747.96192 \n", - "5 0.0 0.0000 1683.00000 \n", - "6 0.0 2193.5232 5967.00000 \n", - "\n", - " Payroll Tax MTR Income Tax MTR Combined MTR \n", - "0 0.029 0.2400 0.2690 \n", - "1 0.153 0.3306 0.4836 \n", - "2 0.153 0.2200 0.3730 \n", - "3 0.153 0.2200 0.3730 \n", - "4 0.038 0.2400 0.2780 \n", - "5 0.153 0.0000 0.1530 \n", - "6 0.153 0.3306 0.4836 \n", - "\n", - "[7 rows x 21 columns]" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# outputs under dictionary reform\n", - "reform_dict = {\n", - " \"CTC_c\": {2013: 1300, 2018: 1800}\n", - " }\n", - "\n", - "b.create_table(reform_dict)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "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", - "
IDIndividual Income TaxPayroll TaxWagesAGIUI in AGIOASDI in AGIItemized DeductionsTaxable IncRegular Tax...CTC RefundableChild care creditEITCAMTNet Investment Income TaxIncome Tax Before CreditsFICAPayroll Tax MTRIncome Tax MTRCombined MTR
01.021502.22150021137.96192160000.0164500.00.00.00.0133254.4525502.2215...0.000.00.0000000.00.025502.221521137.961920.0290.25000.2790
12.0-8588.5296647267.5000047500.047800.00.00.00.00.000.0000...4200.000.04388.5296640.00.00.00007267.500000.1530.21060.3636
23.06981.01650010710.0000070000.080000.00.00.00.059169.636981.0165...0.000.00.0000000.00.06981.016510710.000000.1530.25000.4030
34.0-1349.87000018819.00000123000.0124200.00.00.00.056501.305650.1300...1349.870.00.0000000.00.05650.130018819.000000.1530.10000.2530
45.033505.73150023747.96192250000.0251200.00.00.00.0204331.6635460.1315...0.000.00.0000000.045.635460.131523747.961920.0380.25000.2880
56.0-841.5000001683.0000011000.011000.00.00.00.00.000.0000...0.000.0841.5000000.00.00.00001683.000000.153-0.07650.0765
67.0-6740.1925885967.0000039000.039250.00.00.00.08004.45800.4450...2800.000.03940.1925880.00.0800.44505967.000000.1530.21060.3636
\n", - "

7 rows × 21 columns

\n", - "
" - ], - "text/plain": [ - " ID Individual Income Tax Payroll Tax Wages AGI UI in AGI \\\n", - "0 1.0 21502.221500 21137.96192 160000.0 164500.0 0.0 \n", - "1 2.0 -8588.529664 7267.50000 47500.0 47800.0 0.0 \n", - "2 3.0 6981.016500 10710.00000 70000.0 80000.0 0.0 \n", - "3 4.0 -1349.870000 18819.00000 123000.0 124200.0 0.0 \n", - "4 5.0 33505.731500 23747.96192 250000.0 251200.0 0.0 \n", - "5 6.0 -841.500000 1683.00000 11000.0 11000.0 0.0 \n", - "6 7.0 -6740.192588 5967.00000 39000.0 39250.0 0.0 \n", - "\n", - " OASDI in AGI Itemized Deductions Taxable Inc Regular Tax ... \\\n", - "0 0.0 0.0 133254.45 25502.2215 ... \n", - "1 0.0 0.0 0.00 0.0000 ... \n", - "2 0.0 0.0 59169.63 6981.0165 ... \n", - "3 0.0 0.0 56501.30 5650.1300 ... \n", - "4 0.0 0.0 204331.66 35460.1315 ... \n", - "5 0.0 0.0 0.00 0.0000 ... \n", - "6 0.0 0.0 8004.45 800.4450 ... \n", - "\n", - " CTC Refundable Child care credit EITC AMT \\\n", - "0 0.00 0.0 0.000000 0.0 \n", - "1 4200.00 0.0 4388.529664 0.0 \n", - "2 0.00 0.0 0.000000 0.0 \n", - "3 1349.87 0.0 0.000000 0.0 \n", - "4 0.00 0.0 0.000000 0.0 \n", - "5 0.00 0.0 841.500000 0.0 \n", - "6 2800.00 0.0 3940.192588 0.0 \n", - "\n", - " Net Investment Income Tax Income Tax Before Credits FICA \\\n", - "0 0.0 25502.2215 21137.96192 \n", - "1 0.0 0.0000 7267.50000 \n", - "2 0.0 6981.0165 10710.00000 \n", - "3 0.0 5650.1300 18819.00000 \n", - "4 45.6 35460.1315 23747.96192 \n", - "5 0.0 0.0000 1683.00000 \n", - "6 0.0 800.4450 5967.00000 \n", - "\n", - " Payroll Tax MTR Income Tax MTR Combined MTR \n", - "0 0.029 0.2500 0.2790 \n", - "1 0.153 0.2106 0.3636 \n", - "2 0.153 0.2500 0.4030 \n", - "3 0.153 0.1000 0.2530 \n", - "4 0.038 0.2500 0.2880 \n", - "5 0.153 -0.0765 0.0765 \n", - "6 0.153 0.2106 0.3636 \n", - "\n", - "[7 rows x 21 columns]" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# outputs under preset reform (from https://github.com/PSLmodels/Tax-Calculator/tree/master/taxcalc/reforms)\n", - "b.create_table('Renacci.json')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "taxcrunch-env", - "language": "python", - "name": "taxcrunch-env" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/example_single.ipynb b/docs/example_single.ipynb deleted file mode 100644 index e79eecc..0000000 --- a/docs/example_single.ipynb +++ /dev/null @@ -1,491 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from taxcrunch.cruncher import Cruncher" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CTC_c was redefined in release 1.0.0\n", - "\n" - ] - } - ], - "source": [ - "path = '../docs/example_adjustment.json'\n", - "c = Cruncher(path)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "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", - "
BaseReformChange
Individual Income Tax2385.954636.892250.94
Income Tax MTR0.110.140.03
Payroll Tax10710.0010710.000.00
Payroll Tax MTR0.140.140.00
\n", - "
" - ], - "text/plain": [ - " Base Reform Change\n", - "Individual Income Tax 2385.95 4636.89 2250.94\n", - "Income Tax MTR 0.11 0.14 0.03\n", - "Payroll Tax 10710.00 10710.00 0.00\n", - "Payroll Tax MTR 0.14 0.14 0.00" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# basic outputs\n", - "c.basic_table()" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "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", - "
BaseReformChange
Income Tax MTR0.1110.1390.028
Payroll Tax MTR0.1420.1420.000
\n", - "
" - ], - "text/plain": [ - " Base Reform Change\n", - "Income Tax MTR 0.111 0.139 0.028\n", - "Payroll Tax MTR 0.142 0.142 0.000" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# marginal tax rates\n", - "c.mtr_table()" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "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", - "
BaseReform+ $1
AGI81000.0081000.0081001.00
UI in AGI0.000.000.00
OASDI in AGI0.000.000.00
Itemized Deductions0.000.000.00
Taxable Inc56462.4050752.4750753.47
Regular Tax6385.956636.896637.04
CTC4000.002000.002000.00
CTC Refundable0.000.000.00
Child care credit0.000.000.00
EITC0.000.000.00
AMT Taxable Income81000.0081000.0081001.00
AMT Liability0.000.000.00
Net Investment Income Tax0.000.000.00
Income Tax Before Credits6385.956636.896637.04
\n", - "
" - ], - "text/plain": [ - " Base Reform + $1\n", - "AGI 81000.00 81000.00 81001.00\n", - "UI in AGI 0.00 0.00 0.00\n", - "OASDI in AGI 0.00 0.00 0.00\n", - "Itemized Deductions 0.00 0.00 0.00\n", - "Taxable Inc 56462.40 50752.47 50753.47\n", - "Regular Tax 6385.95 6636.89 6637.04\n", - "CTC 4000.00 2000.00 2000.00\n", - "CTC Refundable 0.00 0.00 0.00\n", - "Child care credit 0.00 0.00 0.00\n", - "EITC 0.00 0.00 0.00\n", - "AMT Taxable Income 81000.00 81000.00 81001.00\n", - "AMT Liability 0.00 0.00 0.00\n", - "Net Investment Income Tax 0.00 0.00 0.00\n", - "Income Tax Before Credits 6385.95 6636.89 6637.04" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# detailed outputs with marginal tax rate analysis\n", - "c.calc_table()" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "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", - "
BaseReformChange
AGI81000.0081000.000.00
UI in AGI0.000.000.00
OASDI in AGI0.000.000.00
Itemized Deductions0.000.000.00
Taxable Inc56462.4050752.47-5709.93
Regular Tax6385.956636.89250.94
CTC4000.002000.00-2000.00
CTC Refundable0.000.000.00
Child care credit0.000.000.00
EITC0.000.000.00
AMT Taxable Income81000.0081000.000.00
AMT Liability0.000.000.00
Net Investment Income Tax0.000.000.00
Income Tax Before Credits6385.956636.89250.94
\n", - "
" - ], - "text/plain": [ - " Base Reform Change\n", - "AGI 81000.00 81000.00 0.00\n", - "UI in AGI 0.00 0.00 0.00\n", - "OASDI in AGI 0.00 0.00 0.00\n", - "Itemized Deductions 0.00 0.00 0.00\n", - "Taxable Inc 56462.40 50752.47 -5709.93\n", - "Regular Tax 6385.95 6636.89 250.94\n", - "CTC 4000.00 2000.00 -2000.00\n", - "CTC Refundable 0.00 0.00 0.00\n", - "Child care credit 0.00 0.00 0.00\n", - "EITC 0.00 0.00 0.00\n", - "AMT Taxable Income 81000.00 81000.00 0.00\n", - "AMT Liability 0.00 0.00 0.00\n", - "Net Investment Income Tax 0.00 0.00 0.00\n", - "Income Tax Before Credits 6385.95 6636.89 250.94" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#detailed outputs with difference between reform and baseline\n", - "c.calc_diff_table()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.8" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/taxcrunch/multi_cruncher.py b/taxcrunch/multi_cruncher.py index 1063101..5c56ff8 100644 --- a/taxcrunch/multi_cruncher.py +++ b/taxcrunch/multi_cruncher.py @@ -3,6 +3,7 @@ import numpy as np import pandas as pd import taxcalc as tc +import behresp as br from paramtools import Parameters from taxcrunch import cruncher as cr from datetime import date @@ -10,6 +11,8 @@ CURRENT_PATH = os.path.abspath(os.path.dirname(__file__)) +FINITE_DIFF = 0.01 + class BatchParams(Parameters): @@ -42,7 +45,8 @@ class instance: Batch def __init__(self, path): self.path = path - self.invar, self.rows = self.read_input() + self.invar, self.invar_marg, self.rows = self.read_input() + self.mtr = self.calc_mtr(reform_file=None) self.tc_vars = [ "RECID", @@ -120,61 +124,90 @@ def read_input(self): 'value'][0]['value']], axis=0) params_df = pd.DataFrame(array).transpose() + params_marg = params_df.copy() + params_marg.loc[:, 9] = params_marg.loc[:, 9] + FINITE_DIFF + # translate INPUT variables into OUTPUT variables c = cr.Cruncher() self.invar = c.translate(params_df) + self.invar_marg = c.translate(params_marg) self.rows = len(self.invar.index) - return self.invar, self.rows + return self.invar, self.invar_marg, self.rows - def create_table(self, reform_file=None): + def create_table(self, reform_file=None, be_sub=0, be_inc=0, be_cg=0): """ - Creates table of liabilities. Default is current law, but user may specify - a policy reform which is read and implemented below in get_pol() + Creates table of liabilities. Default is current law with no behavioral response + (i.e. static analysis). User may specify a policy reform which is read and + implemented below in get_pol() and/or or may specify elasticities for partial- + equilibrium behavioral responses. + + reform_file: name of a reform file in the Tax-Calculator reforms folder, + a file path to a custom JSON reform file, or a dictionary with a policy reform. + + be_sub: Substitution elasticity of taxable income. Defined as proportional change + in taxable income divided by proportional change in marginal net-of-tax rate + (1-MTR) on taxpayer earnings caused by the reform. Must be zero or positive. - The reform_file argument can be the name of a reform file in the - Tax-Calculator reforms folder, a file path to a custom JSON - reform file, or a dictionary with a policy reform. + be_inc: Income elasticity of taxable income. Defined as dollar change in taxable + income divided by dollar change in after-tax income caused by the reform. + Must be zero or negative. + + be_cg: Semi-elasticity of long-term capital gains. Defined as change in logarithm + of long-term capital gains divided by change in marginal tax rate (MTR) on + long-term capital gains caused by the reform. Must be zero or negative. Returns: df_res: a Pandas dataframe. Each observation is a separate tax filer """ - pol = self.get_pol(reform_file) year = self.invar['FLPDYR'][0] year = int(year.item()) recs = tc.Records(data=self.invar, start_year=year) - calc = tc.Calculator(policy=pol, records=recs) - calc.advance_to_year(year) - calc.calc_all() - calcs = calc.dataframe(self.tc_vars) - mtr = calc.mtr(wrt_full_compensation=False) + + if reform_file == None: + pol = tc.Policy() + assert be_sub == be_inc == be_cg == 0 + calc = tc.Calculator(policy=pol, records=recs) + calc.advance_to_year(year) + calc.calc_all() + calcs = calc.dataframe(self.tc_vars) + else: + pol = self.get_pol(reform_file) + calc = tc.Calculator(policy=pol, records=recs) + pol_base = tc.Policy() + calc_base = tc.Calculator(policy=pol_base, records=recs) + response_elasticities = {'sub': be_sub, 'inc': be_inc, 'cg': be_cg} + _, df2br = br.response( + calc_base, calc, response_elasticities, dump=True) + calcs = df2br[self.tc_vars] + + mtr = self.calc_mtr(reform_file) mtr_df = pd.DataFrame(data=mtr).transpose() df_res = pd.concat([calcs, mtr_df], axis=1) df_res.columns = self.labels df_res.index = range(self.rows) return df_res - def create_diff_table(self, reform_file, baseline=None): + def create_diff_table(self, reform_file, baseline=None, be_sub=0, be_inc=0, be_cg=0): """ - Creates a table that displays differences between baseline and reform. + Creates a table that displays differences between baseline and reform. See the above + docstring for a discussion on the method's arguments. - Baseline default is current law. + NOTE: if a policy other than current law is selected as the baseline policy, behavioral + responses must remain 0. - The reform_file argument can be the name of a reform file in the - Tax-Calculator reforms folder, a file path to a custom JSON - reform file, or a dictionary with a policy reform. - - Returns: - df_diff_id: a Pandas dataframe. """ if baseline is None: t_base = self.create_table() else: + # a behavioral response can only be simulated if the baseline is + # current law + assert be_sub == be_inc == be_cg == 0 t_base = self.create_table(baseline) - t_reform = self.create_table(reform_file) + t_reform = self.create_table(reform_file, be_sub, be_inc, be_cg) df_all = pd.merge(t_reform, t_base, on='ID') df_ids = df_all['ID'] cols = len(t_base.columns) - df_diff = df_all.diff(periods= -(cols - 1), + df_diff = df_all.diff(periods=-(cols - 1), axis=1).iloc[:, 1:cols] df_diff_id = pd.concat([df_ids, df_diff], axis=1) # new column labels that have "Diff" at the end @@ -187,10 +220,10 @@ def create_diff_table(self, reform_file, baseline=None): df_diff_id.columns = diff_labels return df_diff_id - def write_output_file(self, output_filename=None, reform_file=None): + def write_output_file(self, output_filename=None, reform_file=None, be_sub=0, be_inc=0, be_cg=0): """ Writes an output table as a csv. Like the create_table() method, default is current - law and optional reform_file argument is a file path to or dictionary of a reform. + law and optional reform_file argument is a file path to json file or dictionary of a reform. Default output filename is "cruncher-mm-dd-YYYY.csv" but user can change output filename with output_filename argument. @@ -199,16 +232,17 @@ def write_output_file(self, output_filename=None, reform_file=None): today = date.today() today_str = today.strftime("%m-%d-%Y") output_filename = "cruncher-" + today_str + ".csv" - df_res = self.create_table(reform_file) + df_res = self.create_table(reform_file, be_sub, be_inc, be_cg) assert isinstance(df_res, pd.DataFrame) df_res.to_csv(output_filename, index=False, float_format='%.2f') - def write_diff_file(self, reform_file, baseline=None, output_filename=None): + def write_diff_file(self, reform_file, baseline=None, output_filename=None, be_sub=0, be_inc=0, be_cg=0): if output_filename is None: today = date.today() today_str = today.strftime("%m-%d-%Y") output_filename = "cruncher-diff-" + today_str + ".csv" - df_res = self.create_diff_table(reform_file=reform_file, baseline=baseline) + df_res = self.create_diff_table( + reform_file, baseline, be_sub, be_inc, be_cg) assert isinstance(df_res, pd.DataFrame) df_res.to_csv(output_filename, index=False, float_format='%.2f') @@ -222,26 +256,61 @@ def get_pol(self, reform_file): "PSLmodels/Tax-Calculator/master/taxcalc/reforms/" ) CURRENT_PATH = os.path.abspath(os.path.dirname(__file__)) - if reform_file == None: + + # check to see if file path to reform_file exists + if isinstance(reform_file, str) and os.path.isfile(os.path.join(CURRENT_PATH, reform_file)): + reform_path = os.path.join(CURRENT_PATH, reform_file) + pol = tc.Policy() + pol.implement_reform(tc.Policy.read_json_reform(reform_path)) + # try reform_file as dictionary + elif isinstance(reform_file, dict): + reform = reform_file pol = tc.Policy() + pol.implement_reform(reform) + # if file path does not exist, check Tax-Calculator reforms file else: - # check to see if file path to reform_file exists - if isinstance(reform_file, str) and os.path.isfile(os.path.join(CURRENT_PATH, reform_file)): - reform_path = os.path.join(CURRENT_PATH, reform_file) + try: + reform_url = REFORMS_URL + reform_file pol = tc.Policy() - pol.implement_reform(tc.Policy.read_json_reform(reform_path)) - # try reform_file as dictionary - elif isinstance(reform_file, dict): - reform = reform_file - pol = tc.Policy() - pol.implement_reform(reform) - # if file path does not exist, check Tax-Calculator reforms file - else: - try: - reform_url = REFORMS_URL + reform_file - pol = tc.Policy() - pol.implement_reform( - tc.Policy.read_json_reform(reform_url)) - except: - raise 'Reform file does not exist' + pol.implement_reform( + tc.Policy.read_json_reform(reform_url)) + except: + raise 'Reform file does not exist' return pol + + def calc_mtr(self, reform_file): + """ + Calculates income tax, payroll tax, and combined marginal rates + """ + year = self.invar['FLPDYR'][0] + year = int(year.item()) + recs_base = tc.Records(data=self.invar, start_year=year) + if reform_file == None: + pol = tc.Policy() + else: + pol = self.get_pol(reform_file) + + calc_base = tc.Calculator(policy=pol, records=recs_base) + calc_base.advance_to_year(year) + calc_base.calc_all() + payrolltax_base = calc_base.array('payrolltax') + incometax_base = calc_base.array('iitax') + combined_taxes_base = incometax_base + payrolltax_base + + recs_marg = tc.Records(data=self.invar_marg, start_year=year) + calc_marg = tc.Calculator(policy=pol, records=recs_marg) + calc_marg.advance_to_year(year) + calc_marg.calc_all() + payrolltax_marg = calc_marg.array('payrolltax') + incometax_marg = calc_marg.array('iitax') + combined_taxes_marg = incometax_marg + payrolltax_marg + + payrolltax_diff = payrolltax_marg - payrolltax_base + incometax_diff = incometax_marg - incometax_base + combined_diff = combined_taxes_marg - combined_taxes_base + + mtr_payrolltax = payrolltax_diff / FINITE_DIFF + mtr_incometax = incometax_diff / FINITE_DIFF + mtr_combined = combined_diff / FINITE_DIFF + + return (mtr_payrolltax, mtr_incometax, mtr_combined) diff --git a/taxcrunch/tests/test_multi_cruncher.py b/taxcrunch/tests/test_multi_cruncher.py index 9e70427..7c0eb7d 100644 --- a/taxcrunch/tests/test_multi_cruncher.py +++ b/taxcrunch/tests/test_multi_cruncher.py @@ -7,38 +7,42 @@ import taxcrunch.cruncher as cr import taxcrunch.multi_cruncher as mcr -def test_get_pol_no_reform(): - b = mcr.Batch(path="tests/example_test_input.csv") - assert isinstance(b, mcr.Batch) - m = b.get_pol(reform_file=None) - assert isinstance(m,tc.Policy) - -def test_get_pol_directory_file(): - b = mcr.Batch(path="tests/example_test_input.csv") - # use the full file pathname for testing purposes - local_reform = "tests/test_reform.json" - n = b.get_pol(reform_file=local_reform) - assert n._CTC_c[2018-2013] == 1000 +b = mcr.Batch(path="tests/example_test_input.csv") reform_dict = { "CTC_c": {2013: 1300, 2018: 1800} } -def test_get_pol_dict(): - b = mcr.Batch(path="tests/example_test_input.csv") +def test_read_input(crunch=b): + + invar, invar_marg, rows = b.read_input() + assert isinstance(invar, pd.DataFrame) + assert isinstance(rows, int) + + # check that number of input rows matches output rows + assert rows == len(b.create_table().index) + +def test_get_pol_directory_file(crunch=b): + + local_reform = "tests/test_reform.json" + n = b.get_pol(reform_file=local_reform) + assert n._CTC_c[2018-2013] == 1000 + +def test_get_pol_dict(crunch=b): + m = b.get_pol(reform_file=reform_dict) assert m._CTC_c[2018-2013] == 1800 -def test_get_pol_link(): - b = mcr.Batch(path="tests/example_test_input.csv") +def test_get_pol_link(crunch=b): + reform_preset = "Trump2016.json" m = b.get_pol(reform_file=reform_preset) assert m._II_rt1[2017-2013] == 0.12 CURR_PATH = os.path.abspath(os.path.dirname(__file__)) -def test_calc_table(): - b = mcr.Batch(path="tests/example_test_input.csv") +def test_calc_table(crunch=b): + table = b.create_table() assert isinstance(table, pd.DataFrame) # table.to_csv("expected_multi_table.csv") @@ -46,4 +50,30 @@ def test_calc_table(): os.path.join(CURR_PATH, "expected_multi_table.csv"), index_col=0 ) for col in table.columns: - assert np.allclose(table[col], expected_table[col]) \ No newline at end of file + assert np.allclose(table[col], expected_table[col]) + +def test_create_table_behresp_args(crunch=b): + + table = b.create_table(reform_file=reform_dict, be_sub=0.25) + assert isinstance(table, pd.DataFrame) + + # be_sub must be positive + with pytest.raises(AssertionError): + b.create_table(reform_file=reform_dict, be_sub=-0.25) + + # can only specify response if there is a reform + with pytest.raises(AssertionError): + b.create_table(be_sub=0.25) + +def test_diff_tables(crunch=b): + + table = b.create_diff_table(reform_file=reform_dict) + assert isinstance(table,pd.DataFrame) + + # can only specify response if there is a reform + with pytest.raises(AssertionError): + b.create_diff_table(reform_file=None, be_sub=0.25) + + # baseline must be current law if response + with pytest.raises(AssertionError): + b.create_diff_table(reform_file="Trump2016.json", baseline=reform_dict, be_sub=0.25)