|
10 | 10 | }, |
11 | 11 | { |
12 | 12 | "cell_type": "code", |
13 | | - "execution_count": null, |
| 13 | + "execution_count": 1, |
14 | 14 | "metadata": {}, |
15 | 15 | "outputs": [], |
16 | 16 | "source": [ |
|
617 | 617 | }, |
618 | 618 | { |
619 | 619 | "cell_type": "code", |
620 | | - "execution_count": 16, |
| 620 | + "execution_count": 17, |
| 621 | + "metadata": {}, |
| 622 | + "outputs": [], |
| 623 | + "source": [ |
| 624 | + "eti_dict = {\n", |
| 625 | + " \"eti_values\": [0.18, 0.106, 0.567, 1.83, 1.9],\n", |
| 626 | + " \"knot_points\": [30000, 75000, 250000, 2000000, 10000000]\n", |
| 627 | + "}\n", |
| 628 | + "# ETI values from Gruber and Saez (2002) (Table 3) and Saez (2004) (Tables 2, 4, 5)\n", |
| 629 | + "# Compute MTR schedule under current law\n", |
| 630 | + "iot_2023 = iot_user.iot_comparison(\n", |
| 631 | + " policies=[{}],\n", |
| 632 | + " baseline_policies=[None],\n", |
| 633 | + " labels=[\"2023 Law\"],\n", |
| 634 | + " years=[2023],\n", |
| 635 | + " data=\"CPS\",\n", |
| 636 | + " eti=eti_dict\n", |
| 637 | + " )\n", |
| 638 | + "fig = px.line(\n", |
| 639 | + " x=iot_2023.iot[0].df().z,\n", |
| 640 | + " y=iot_2023.iot[0].df().mtr\n", |
| 641 | + " )\n", |
| 642 | + "fig.update_layout(\n", |
| 643 | + " template=template,\n", |
| 644 | + " xaxis_title=\"Wages and Salaries\",\n", |
| 645 | + " yaxis_title=r\"$T'(z)$\",\n", |
| 646 | + ")\n", |
| 647 | + "fig.write_image(\n", |
| 648 | + " os.path.join(path, \"MTR_2023.png\"),\n", |
| 649 | + " scale=4\n", |
| 650 | + " )" |
| 651 | + ] |
| 652 | + }, |
| 653 | + { |
| 654 | + "cell_type": "code", |
| 655 | + "execution_count": null, |
| 656 | + "metadata": {}, |
| 657 | + "outputs": [], |
| 658 | + "source": [ |
| 659 | + "# Thought experiment: What beliefs about ETI do the candidates need to \n", |
| 660 | + "# justify their policies if we assume they are utilitarian? \n", |
| 661 | + "# If the elasticities are wildly counterfactual, we can reject this hypothesis\n", |
| 662 | + "\n", |
| 663 | + "eti_utilitarian = np.zeros((len(iot_all.iot), len(iot_all.iot[0].df().z)))\n", |
| 664 | + "for i in range(len(iot_all.iot)):\n", |
| 665 | + " eti_utilitarian[i, :] = iot.inverse_optimal_tax.find_eti(\n", |
| 666 | + " iot_all.iot[i], g_z = np.ones(len(iot_all.iot[i].df().z))\n", |
| 667 | + " )\n", |
| 668 | + "\n", |
| 669 | + "# Convert the 2D array to a DataFrame for plotting\n", |
| 670 | + "eti_df = pd.DataFrame(eti_utilitarian.T, columns=labels)\n", |
| 671 | + "\n", |
| 672 | + "fig_eti = px.line(\n", |
| 673 | + " eti_df,\n", |
| 674 | + " x=iot_all.iot[0].df().z,\n", |
| 675 | + " y=eti_df.columns,\n", |
| 676 | + " labels={\"x\": \"Wages and Salaries\", \"value\": r\"$\\varepsilon$\", \"variable\": \"Candidate\"},\n", |
| 677 | + ")\n", |
| 678 | + "fig_eti.update_layout(\n", |
| 679 | + " template=template,\n", |
| 680 | + ")\n", |
| 681 | + "\n", |
| 682 | + "fig_eti.update_traces(\n", |
| 683 | + " line=dict(dash=\"dot\", color=\"blue\"),\n", |
| 684 | + " selector=dict(name=\"Obama 2015\")\n", |
| 685 | + ")\n", |
| 686 | + "fig_eti.update_traces(\n", |
| 687 | + " line=dict(dash=\"dot\", color=\"red\"),\n", |
| 688 | + " selector=dict(name=\"Romney 2012\")\n", |
| 689 | + ")\n", |
| 690 | + "fig_eti.update_traces(\n", |
| 691 | + " line=dict(dash=\"dash\", color=\"blue\"),\n", |
| 692 | + " selector=dict(name=\"Clinton 2016\")\n", |
| 693 | + ")\n", |
| 694 | + "fig_eti.update_traces(\n", |
| 695 | + " line=dict(dash=\"dash\", color=\"red\"),\n", |
| 696 | + " selector=dict(name=\"Trump 2016\")\n", |
| 697 | + ")\n", |
| 698 | + "fig_eti.update_traces(\n", |
| 699 | + " line=dict(dash=\"dashdot\", color=\"blue\"),\n", |
| 700 | + " selector=dict(name=\"Biden 2020\")\n", |
| 701 | + ")\n", |
| 702 | + "fig_eti.update_traces(\n", |
| 703 | + " line=dict(dash=\"dashdot\", color=\"red\"),\n", |
| 704 | + " selector=dict(name=\"Trump 2020\")\n", |
| 705 | + ")\n", |
| 706 | + "fig_eti.update_traces(\n", |
| 707 | + " line=dict(dash=\"solid\", color=\"blue\"),\n", |
| 708 | + " selector=dict(name=\"Harris 2024\")\n", |
| 709 | + ")\n", |
| 710 | + "fig_eti.update_traces(\n", |
| 711 | + " line=dict(dash=\"solid\", color=\"red\"),\n", |
| 712 | + " selector=dict(name=\"Trump 2024\")\n", |
| 713 | + ")\n", |
| 714 | + "fig_eti.write_image(\n", |
| 715 | + " os.path.join(path, \"eti_utilitarian.png\"),\n", |
| 716 | + " scale=4\n", |
| 717 | + " )" |
| 718 | + ] |
| 719 | + }, |
| 720 | + { |
| 721 | + "cell_type": "code", |
| 722 | + "execution_count": null, |
621 | 723 | "metadata": {}, |
622 | 724 | "outputs": [], |
623 | 725 | "source": [ |
|
626 | 728 | "# one plot with epsilon(z) for each candidate\n", |
627 | 729 | "# Will pick Trump and Clinton (2016) for example\n", |
628 | 730 | "\n", |
| 731 | + "\n", |
629 | 732 | "# First, plot just their g(z)\n", |
630 | 733 | "fig = px.line(\n", |
631 | 734 | " x=iot_all.iot[2].df().z[10:],\n", |
|
649 | 752 | " os.path.join(path, \"trump_clinton_g_z_numerical.png\"),\n", |
650 | 753 | " scale=4\n", |
651 | 754 | " )\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", |
| 755 | + "\n", |
| 756 | + "\n", |
| 757 | + "# What ETI does Clinton need to justify Trump's SWW given her policy?\n", |
| 758 | + "eti_clinton = iot.inverse_optimal_tax.find_eti(\n", |
| 759 | + " iot_all.iot[2], \n", |
| 760 | + " g_z=iot_all.iot[3].df().g_z)\n", |
| 761 | + "\n", |
| 762 | + "fig_eti_clinton = px.line(\n", |
| 763 | + " x=iot_all.iot[2].df().z,\n", |
| 764 | + " y=eti_clinton,\n", |
| 765 | + " labels={\"x\": \"Wages and Salaries\", \"y\": r\"$\\varepsilon$\"},\n", |
659 | 766 | " )\n", |
660 | | - "fig2.update_layout(\n", |
| 767 | + "fig_eti_clinton.update_layout(\n", |
661 | 768 | " template=template,\n", |
662 | 769 | ")\n", |
663 | | - "fig2.write_image(\n", |
664 | | - " os.path.join(path, \"trump_eti.png\"),\n", |
| 770 | + "fig_eti_clinton.update_traces(\n", |
| 771 | + " line=dict(dash=\"dash\", color=\"blue\"),\n", |
| 772 | + " selector=dict(name=\"Clinton 2016\")\n", |
| 773 | + ")\n", |
| 774 | + "fig_eti_clinton.write_image(\n", |
| 775 | + " os.path.join(path, \"eti_clinton.png\"),\n", |
665 | 776 | " scale=4\n", |
666 | | - " )" |
| 777 | + " )\n" |
667 | 778 | ] |
668 | 779 | }, |
669 | 780 | { |
670 | 781 | "cell_type": "code", |
671 | | - "execution_count": 17, |
| 782 | + "execution_count": null, |
672 | 783 | "metadata": {}, |
673 | 784 | "outputs": [], |
674 | 785 | "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", |
| 786 | + "\n", |
| 787 | + "# Converse: What elasticty does Trump need to justify Clinton's weights?\n", |
| 788 | + "eti_trump = iot.inverse_optimal_tax.find_eti(\n", |
| 789 | + " iot_all.iot[3], \n", |
| 790 | + " g_z=iot_all.iot[2].df().g_z)\n", |
| 791 | + "\n", |
| 792 | + "fig_eti_trump = px.line(\n", |
| 793 | + " x=iot_all.iot[2].df().z,\n", |
| 794 | + " y=eti_trump,\n", |
| 795 | + " labels={\"x\": \"Wages and Salaries\", \"y\": r\"$\\varepsilon$\"},\n", |
692 | 796 | " )\n", |
693 | | - "fig.update_layout(\n", |
| 797 | + "fig_eti_trump.update_layout(\n", |
694 | 798 | " template=template,\n", |
695 | | - " xaxis_title=\"Wages and Salaries\",\n", |
696 | | - " yaxis_title=r\"$T'(z)$\",\n", |
697 | 799 | ")\n", |
698 | | - "fig.write_image(\n", |
699 | | - " os.path.join(path, \"MTR_2023.png\"),\n", |
| 800 | + "fig_eti_trump.update_traces(\n", |
| 801 | + " line=dict(dash=\"dash\", color=\"red\"),\n", |
| 802 | + " selector=dict(name=\"Trump 2016\")\n", |
| 803 | + ")\n", |
| 804 | + "fig_eti_trump.write_image(\n", |
| 805 | + " os.path.join(path, \"eti_trump.png\"),\n", |
700 | 806 | " scale=4\n", |
701 | | - " )" |
| 807 | + " )\n" |
702 | 808 | ] |
703 | 809 | } |
704 | 810 | ], |
|
718 | 824 | "name": "python", |
719 | 825 | "nbconvert_exporter": "python", |
720 | 826 | "pygments_lexer": "ipython3", |
721 | | - "version": "3.12.3" |
| 827 | + "version": "3.11.7" |
722 | 828 | } |
723 | 829 | }, |
724 | 830 | "nbformat": 4, |
|
0 commit comments