Skip to content

Commit

Permalink
Adjust plots for trump-clinton ETI and add utilitarian ETI plot
Browse files Browse the repository at this point in the history
  • Loading branch information
john-p-ryan committed Feb 25, 2025
1 parent a3e521e commit cef5321
Showing 1 changed file with 170 additions and 40 deletions.
210 changes: 170 additions & 40 deletions examples/Simulate_all_policies.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -71,9 +71,33 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://raw.githubusercontent.com/jdebacker/examples/pres_proposals/psl_examples/taxcalc/Obama2015.json\n",
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
"https://raw.githubusercontent.com/jdebacker/examples/pres_proposals/psl_examples/taxcalc/Romney2012.json\n",
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
"https://raw.githubusercontent.com/jdebacker/examples/pres_proposals/psl_examples/taxcalc/Clinton2016.json\n",
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/Trump2016.json\n",
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/Biden2020.json\n",
"['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",
"['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",
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/TCJA.json\n",
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/TCJA.json\n",
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n",
"https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/TCJA.json\n",
"['https://raw.githubusercontent.com/PSLmodels/examples/main/psl_examples/taxcalc/2017_law.json']\n"
]
}
],
"source": [
"# Create IOT objects for each candidate platform\n",
"policies = []\n",
Expand Down Expand Up @@ -617,7 +641,109 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"eti_dict = {\n",
" \"eti_values\": [0.18, 0.106, 0.567, 1.83, 1.9],\n",
" \"knot_points\": [30000, 75000, 250000, 2000000, 10000000]\n",
"}\n",
"# ETI values from Gruber and Saez (2002) (Table 3) and Saez (2004) (Tables 2, 4, 5)\n",
"# Compute MTR schedule under current law\n",
"iot_2023 = iot_user.iot_comparison(\n",
" policies=[{}],\n",
" baseline_policies=[None],\n",
" labels=[\"2023 Law\"],\n",
" years=[2023],\n",
" data=\"CPS\",\n",
" eti=eti_dict\n",
" )\n",
"fig = px.line(\n",
" x=iot_2023.iot[0].df().z,\n",
" y=iot_2023.iot[0].df().mtr\n",
" )\n",
"fig.update_layout(\n",
" template=template,\n",
" xaxis_title=\"Wages and Salaries\",\n",
" yaxis_title=r\"$T'(z)$\",\n",
")\n",
"fig.write_image(\n",
" os.path.join(path, \"MTR_2023.png\"),\n",
" scale=4\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Thought experiment: What beliefs about ETI do the candidates need to \n",
"# justify their policies if we assume they are utilitarian? \n",
"# If the elasticities are wildly counterfactual, we can reject this hypothesis\n",
"\n",
"eti_utilitarian = np.zeros((len(iot_all.iot), len(iot_all.iot[0].df().z)))\n",
"for i in range(len(iot_all.iot)):\n",
" eti_utilitarian[i, :] = iot.inverse_optimal_tax.find_eti(\n",
" iot_all.iot[i], g_z = np.ones(len(iot_all.iot[i].df().z))\n",
" )\n",
"\n",
"# Convert the 2D array to a DataFrame for plotting\n",
"eti_df = pd.DataFrame(eti_utilitarian.T, columns=labels)\n",
"\n",
"fig_eti = px.line(\n",
" eti_df,\n",
" x=iot_all.iot[0].df().z,\n",
" y=eti_df.columns,\n",
" labels={\"x\": \"Wages and Salaries\", \"value\": r\"$\\varepsilon$\", \"variable\": \"Candidate\"},\n",
")\n",
"fig_eti.update_layout(\n",
" template=template,\n",
")\n",
"\n",
"fig_eti.update_traces(\n",
" line=dict(dash=\"dot\", color=\"blue\"),\n",
" selector=dict(name=\"Obama 2015\")\n",
")\n",
"fig_eti.update_traces(\n",
" line=dict(dash=\"dot\", color=\"red\"),\n",
" selector=dict(name=\"Romney 2012\")\n",
")\n",
"fig_eti.update_traces(\n",
" line=dict(dash=\"dash\", color=\"blue\"),\n",
" selector=dict(name=\"Clinton 2016\")\n",
")\n",
"fig_eti.update_traces(\n",
" line=dict(dash=\"dash\", color=\"red\"),\n",
" selector=dict(name=\"Trump 2016\")\n",
")\n",
"fig_eti.update_traces(\n",
" line=dict(dash=\"dashdot\", color=\"blue\"),\n",
" selector=dict(name=\"Biden 2020\")\n",
")\n",
"fig_eti.update_traces(\n",
" line=dict(dash=\"dashdot\", color=\"red\"),\n",
" selector=dict(name=\"Trump 2020\")\n",
")\n",
"fig_eti.update_traces(\n",
" line=dict(dash=\"solid\", color=\"blue\"),\n",
" selector=dict(name=\"Harris 2024\")\n",
")\n",
"fig_eti.update_traces(\n",
" line=dict(dash=\"solid\", color=\"red\"),\n",
" selector=dict(name=\"Trump 2024\")\n",
")\n",
"fig_eti.write_image(\n",
" os.path.join(path, \"eti_utilitarian.png\"),\n",
" scale=4\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -626,6 +752,7 @@
"# one plot with epsilon(z) for each candidate\n",
"# Will pick Trump and Clinton (2016) for example\n",
"\n",
"\n",
"# First, plot just their g(z)\n",
"fig = px.line(\n",
" x=iot_all.iot[2].df().z[10:],\n",
Expand All @@ -649,56 +776,59 @@
" os.path.join(path, \"trump_clinton_g_z_numerical.png\"),\n",
" scale=4\n",
" )\n",
"# Now find the epsilon(z) that would give Trump's policies the same g(z) as Clinton\n",
"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",
"idx = np.where(np.absolute(eti_beliefs_jjz[1:]) < 10)[0]\n",
"fig2 = px.line(\n",
" x=iot_all.iot[2].df().z[idx],\n",
" y=eti_beliefs_jjz[idx],\n",
" labels={\"x\": \"Wages and Salaries\", \"y\": r\"$\\text{Implied } \\varepsilon$\"},\n",
"\n",
"\n",
"# What ETI does Clinton need to justify Trump's SWW given her policy?\n",
"eti_clinton = iot.inverse_optimal_tax.find_eti(\n",
" iot_all.iot[2], \n",
" g_z=iot_all.iot[3].df().g_z)\n",
"\n",
"fig_eti_clinton = px.line(\n",
" x=iot_all.iot[2].df().z,\n",
" y=eti_clinton,\n",
" labels={\"x\": \"Wages and Salaries\", \"y\": r\"$\\varepsilon$\"},\n",
" )\n",
"fig2.update_layout(\n",
"fig_eti_clinton.update_layout(\n",
" template=template,\n",
")\n",
"fig2.write_image(\n",
" os.path.join(path, \"trump_eti.png\"),\n",
"fig_eti_clinton.update_traces(\n",
" line=dict(dash=\"dash\", color=\"blue\"),\n",
" selector=dict(name=\"Clinton 2016\")\n",
")\n",
"fig_eti_clinton.write_image(\n",
" os.path.join(path, \"eti_clinton.png\"),\n",
" scale=4\n",
" )"
" )\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"eti_dict = {\n",
" \"eti_values\": [0.18, 0.106, 0.567, 1.83, 1.9],\n",
" \"knot_points\": [30000, 75000, 250000, 2000000, 10000000]\n",
"}\n",
"# ETI values from Gruber and Saez (2002) (Table 3) and Saez (2004) (Tables 2, 4, 5)\n",
"# Compute MTR schedule under current law\n",
"iot_2023 = iot_user.iot_comparison(\n",
" policies=[{}],\n",
" baseline_policies=[None],\n",
" labels=[\"2023 Law\"],\n",
" years=[2023],\n",
" data=\"CPS\",\n",
" eti=eti_dict\n",
" )\n",
"fig = px.line(\n",
" x=iot_2023.iot[0].df().z,\n",
" y=iot_2023.iot[0].df().mtr\n",
"\n",
"# Converse: What elasticty does Trump need to justify Clinton's weights?\n",
"eti_trump = iot.inverse_optimal_tax.find_eti(\n",
" iot_all.iot[3], \n",
" g_z=iot_all.iot[2].df().g_z)\n",
"\n",
"fig_eti_trump = px.line(\n",
" x=iot_all.iot[2].df().z,\n",
" y=eti_trump,\n",
" labels={\"x\": \"Wages and Salaries\", \"y\": r\"$\\varepsilon$\"},\n",
" )\n",
"fig.update_layout(\n",
"fig_eti_trump.update_layout(\n",
" template=template,\n",
" xaxis_title=\"Wages and Salaries\",\n",
" yaxis_title=r\"$T'(z)$\",\n",
")\n",
"fig.write_image(\n",
" os.path.join(path, \"MTR_2023.png\"),\n",
"fig_eti_trump.update_traces(\n",
" line=dict(dash=\"dash\", color=\"red\"),\n",
" selector=dict(name=\"Trump 2016\")\n",
")\n",
"fig_eti_trump.write_image(\n",
" os.path.join(path, \"eti_trump.png\"),\n",
" scale=4\n",
" )"
" )\n"
]
}
],
Expand All @@ -718,7 +848,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down

0 comments on commit cef5321

Please sign in to comment.