Skip to content

Commit cef5321

Browse files
committed
Adjust plots for trump-clinton ETI and add utilitarian ETI plot
1 parent a3e521e commit cef5321

File tree

1 file changed

+170
-40
lines changed

1 file changed

+170
-40
lines changed

examples/Simulate_all_policies.ipynb

Lines changed: 170 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": null,
13+
"execution_count": 1,
1414
"metadata": {},
1515
"outputs": [],
1616
"source": [
@@ -71,9 +71,33 @@
7171
},
7272
{
7373
"cell_type": "code",
74-
"execution_count": null,
74+
"execution_count": 3,
7575
"metadata": {},
76-
"outputs": [],
76+
"outputs": [
77+
{
78+
"name": "stdout",
79+
"output_type": "stream",
80+
"text": [
81+
"https://raw.githubusercontent.com/jdebacker/examples/pres_proposals/psl_examples/taxcalc/Obama2015.json\n",
82+
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
83+
"https://raw.githubusercontent.com/jdebacker/examples/pres_proposals/psl_examples/taxcalc/Romney2012.json\n",
84+
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
85+
"https://raw.githubusercontent.com/jdebacker/examples/pres_proposals/psl_examples/taxcalc/Clinton2016.json\n",
86+
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
87+
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/Trump2016.json\n",
88+
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
89+
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/Biden2020.json\n",
90+
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json', 'https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/TCJA.json']\n",
91+
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json', 'https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/TCJA.json']\n",
92+
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/TCJA.json\n",
93+
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
94+
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/TCJA.json\n",
95+
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
96+
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/TCJA.json\n",
97+
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n"
98+
]
99+
}
100+
],
77101
"source": [
78102
"# Create IOT objects for each candidate platform\n",
79103
"policies = []\n",
@@ -617,7 +641,109 @@
617641
},
618642
{
619643
"cell_type": "code",
620-
"execution_count": 16,
644+
"execution_count": 17,
645+
"metadata": {},
646+
"outputs": [],
647+
"source": [
648+
"eti_dict = {\n",
649+
" \"eti_values\": [0.18, 0.106, 0.567, 1.83, 1.9],\n",
650+
" \"knot_points\": [30000, 75000, 250000, 2000000, 10000000]\n",
651+
"}\n",
652+
"# ETI values from Gruber and Saez (2002) (Table 3) and Saez (2004) (Tables 2, 4, 5)\n",
653+
"# Compute MTR schedule under current law\n",
654+
"iot_2023 = iot_user.iot_comparison(\n",
655+
" policies=[{}],\n",
656+
" baseline_policies=[None],\n",
657+
" labels=[\"2023 Law\"],\n",
658+
" years=[2023],\n",
659+
" data=\"CPS\",\n",
660+
" eti=eti_dict\n",
661+
" )\n",
662+
"fig = px.line(\n",
663+
" x=iot_2023.iot[0].df().z,\n",
664+
" y=iot_2023.iot[0].df().mtr\n",
665+
" )\n",
666+
"fig.update_layout(\n",
667+
" template=template,\n",
668+
" xaxis_title=\"Wages and Salaries\",\n",
669+
" yaxis_title=r\"$T'(z)$\",\n",
670+
")\n",
671+
"fig.write_image(\n",
672+
" os.path.join(path, \"MTR_2023.png\"),\n",
673+
" scale=4\n",
674+
" )"
675+
]
676+
},
677+
{
678+
"cell_type": "code",
679+
"execution_count": null,
680+
"metadata": {},
681+
"outputs": [],
682+
"source": [
683+
"# Thought experiment: What beliefs about ETI do the candidates need to \n",
684+
"# justify their policies if we assume they are utilitarian? \n",
685+
"# If the elasticities are wildly counterfactual, we can reject this hypothesis\n",
686+
"\n",
687+
"eti_utilitarian = np.zeros((len(iot_all.iot), len(iot_all.iot[0].df().z)))\n",
688+
"for i in range(len(iot_all.iot)):\n",
689+
" eti_utilitarian[i, :] = iot.inverse_optimal_tax.find_eti(\n",
690+
" iot_all.iot[i], g_z = np.ones(len(iot_all.iot[i].df().z))\n",
691+
" )\n",
692+
"\n",
693+
"# Convert the 2D array to a DataFrame for plotting\n",
694+
"eti_df = pd.DataFrame(eti_utilitarian.T, columns=labels)\n",
695+
"\n",
696+
"fig_eti = px.line(\n",
697+
" eti_df,\n",
698+
" x=iot_all.iot[0].df().z,\n",
699+
" y=eti_df.columns,\n",
700+
" labels={\"x\": \"Wages and Salaries\", \"value\": r\"$\\varepsilon$\", \"variable\": \"Candidate\"},\n",
701+
")\n",
702+
"fig_eti.update_layout(\n",
703+
" template=template,\n",
704+
")\n",
705+
"\n",
706+
"fig_eti.update_traces(\n",
707+
" line=dict(dash=\"dot\", color=\"blue\"),\n",
708+
" selector=dict(name=\"Obama 2015\")\n",
709+
")\n",
710+
"fig_eti.update_traces(\n",
711+
" line=dict(dash=\"dot\", color=\"red\"),\n",
712+
" selector=dict(name=\"Romney 2012\")\n",
713+
")\n",
714+
"fig_eti.update_traces(\n",
715+
" line=dict(dash=\"dash\", color=\"blue\"),\n",
716+
" selector=dict(name=\"Clinton 2016\")\n",
717+
")\n",
718+
"fig_eti.update_traces(\n",
719+
" line=dict(dash=\"dash\", color=\"red\"),\n",
720+
" selector=dict(name=\"Trump 2016\")\n",
721+
")\n",
722+
"fig_eti.update_traces(\n",
723+
" line=dict(dash=\"dashdot\", color=\"blue\"),\n",
724+
" selector=dict(name=\"Biden 2020\")\n",
725+
")\n",
726+
"fig_eti.update_traces(\n",
727+
" line=dict(dash=\"dashdot\", color=\"red\"),\n",
728+
" selector=dict(name=\"Trump 2020\")\n",
729+
")\n",
730+
"fig_eti.update_traces(\n",
731+
" line=dict(dash=\"solid\", color=\"blue\"),\n",
732+
" selector=dict(name=\"Harris 2024\")\n",
733+
")\n",
734+
"fig_eti.update_traces(\n",
735+
" line=dict(dash=\"solid\", color=\"red\"),\n",
736+
" selector=dict(name=\"Trump 2024\")\n",
737+
")\n",
738+
"fig_eti.write_image(\n",
739+
" os.path.join(path, \"eti_utilitarian.png\"),\n",
740+
" scale=4\n",
741+
" )"
742+
]
743+
},
744+
{
745+
"cell_type": "code",
746+
"execution_count": null,
621747
"metadata": {},
622748
"outputs": [],
623749
"source": [
@@ -626,6 +752,7 @@
626752
"# one plot with epsilon(z) for each candidate\n",
627753
"# Will pick Trump and Clinton (2016) for example\n",
628754
"\n",
755+
"\n",
629756
"# First, plot just their g(z)\n",
630757
"fig = px.line(\n",
631758
" x=iot_all.iot[2].df().z[10:],\n",
@@ -649,56 +776,59 @@
649776
" os.path.join(path, \"trump_clinton_g_z_numerical.png\"),\n",
650777
" scale=4\n",
651778
" )\n",
652-
"# Now find the epsilon(z) that would give Trump's policies the same g(z) as Clinton\n",
653-
"eti_beliefs_lw, eti_beliefs_jjz = iot.inverse_optimal_tax.find_eti(iot_all.iot[2], iot_all.iot[3], g_z_type=\"g_z\")\n",
654-
"idx = np.where(np.absolute(eti_beliefs_jjz[1:]) < 10)[0]\n",
655-
"fig2 = px.line(\n",
656-
" x=iot_all.iot[2].df().z[idx],\n",
657-
" y=eti_beliefs_jjz[idx],\n",
658-
" labels={\"x\": \"Wages and Salaries\", \"y\": r\"$\\text{Implied } \\varepsilon$\"},\n",
779+
"\n",
780+
"\n",
781+
"# What ETI does Clinton need to justify Trump's SWW given her policy?\n",
782+
"eti_clinton = iot.inverse_optimal_tax.find_eti(\n",
783+
" iot_all.iot[2], \n",
784+
" g_z=iot_all.iot[3].df().g_z)\n",
785+
"\n",
786+
"fig_eti_clinton = px.line(\n",
787+
" x=iot_all.iot[2].df().z,\n",
788+
" y=eti_clinton,\n",
789+
" labels={\"x\": \"Wages and Salaries\", \"y\": r\"$\\varepsilon$\"},\n",
659790
" )\n",
660-
"fig2.update_layout(\n",
791+
"fig_eti_clinton.update_layout(\n",
661792
" template=template,\n",
662793
")\n",
663-
"fig2.write_image(\n",
664-
" os.path.join(path, \"trump_eti.png\"),\n",
794+
"fig_eti_clinton.update_traces(\n",
795+
" line=dict(dash=\"dash\", color=\"blue\"),\n",
796+
" selector=dict(name=\"Clinton 2016\")\n",
797+
")\n",
798+
"fig_eti_clinton.write_image(\n",
799+
" os.path.join(path, \"eti_clinton.png\"),\n",
665800
" scale=4\n",
666-
" )"
801+
" )\n"
667802
]
668803
},
669804
{
670805
"cell_type": "code",
671-
"execution_count": 17,
806+
"execution_count": null,
672807
"metadata": {},
673808
"outputs": [],
674809
"source": [
675-
"eti_dict = {\n",
676-
" \"eti_values\": [0.18, 0.106, 0.567, 1.83, 1.9],\n",
677-
" \"knot_points\": [30000, 75000, 250000, 2000000, 10000000]\n",
678-
"}\n",
679-
"# ETI values from Gruber and Saez (2002) (Table 3) and Saez (2004) (Tables 2, 4, 5)\n",
680-
"# Compute MTR schedule under current law\n",
681-
"iot_2023 = iot_user.iot_comparison(\n",
682-
" policies=[{}],\n",
683-
" baseline_policies=[None],\n",
684-
" labels=[\"2023 Law\"],\n",
685-
" years=[2023],\n",
686-
" data=\"CPS\",\n",
687-
" eti=eti_dict\n",
688-
" )\n",
689-
"fig = px.line(\n",
690-
" x=iot_2023.iot[0].df().z,\n",
691-
" y=iot_2023.iot[0].df().mtr\n",
810+
"\n",
811+
"# Converse: What elasticty does Trump need to justify Clinton's weights?\n",
812+
"eti_trump = iot.inverse_optimal_tax.find_eti(\n",
813+
" iot_all.iot[3], \n",
814+
" g_z=iot_all.iot[2].df().g_z)\n",
815+
"\n",
816+
"fig_eti_trump = px.line(\n",
817+
" x=iot_all.iot[2].df().z,\n",
818+
" y=eti_trump,\n",
819+
" labels={\"x\": \"Wages and Salaries\", \"y\": r\"$\\varepsilon$\"},\n",
692820
" )\n",
693-
"fig.update_layout(\n",
821+
"fig_eti_trump.update_layout(\n",
694822
" template=template,\n",
695-
" xaxis_title=\"Wages and Salaries\",\n",
696-
" yaxis_title=r\"$T'(z)$\",\n",
697823
")\n",
698-
"fig.write_image(\n",
699-
" os.path.join(path, \"MTR_2023.png\"),\n",
824+
"fig_eti_trump.update_traces(\n",
825+
" line=dict(dash=\"dash\", color=\"red\"),\n",
826+
" selector=dict(name=\"Trump 2016\")\n",
827+
")\n",
828+
"fig_eti_trump.write_image(\n",
829+
" os.path.join(path, \"eti_trump.png\"),\n",
700830
" scale=4\n",
701-
" )"
831+
" )\n"
702832
]
703833
}
704834
],
@@ -718,7 +848,7 @@
718848
"name": "python",
719849
"nbconvert_exporter": "python",
720850
"pygments_lexer": "ipython3",
721-
"version": "3.12.3"
851+
"version": "3.11.7"
722852
}
723853
},
724854
"nbformat": 4,

0 commit comments

Comments
 (0)