diff --git a/us/irs/income/credits/ctc/harris/harris_ctc_budget.ipynb b/us/irs/income/credits/ctc/harris/harris_ctc_budget.ipynb new file mode 100644 index 0000000..b5257df --- /dev/null +++ b/us/irs/income/credits/ctc/harris/harris_ctc_budget.ipynb @@ -0,0 +1,158 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from policyengine_us import Microsimulation\n", + "from policyengine_core.reforms import Reform\n", + "import plotly.graph_objects as go\n", + "import numpy as np\n", + "from multiprocessing import Pool, cpu_count\n", + "from functools import lru_cache" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\n", + "reform = Reform.from_dict({\n", + " \"gov.contrib.congress.delauro.american_family_act.baby_bonus\": {\n", + " \"2024-01-01.2100-12-31\": 2400\n", + " },\n", + " \"gov.irs.credits.ctc.amount.arpa[0].amount\": {\n", + " \"2023-01-01.2028-12-31\": 3600\n", + " },\n", + " \"gov.irs.credits.ctc.amount.arpa[1].amount\": {\n", + " \"2023-01-01.2028-12-31\": 3000\n", + " },\n", + " \"gov.irs.credits.ctc.phase_out.arpa.in_effect\": {\n", + " \"2023-01-01.2028-12-31\": True\n", + " },\n", + " \"gov.irs.credits.ctc.refundable.fully_refundable\": {\n", + " \"2023-01-01.2028-12-31\": True\n", + " }\n", + "}, country_id=\"us\")\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# Initialize simulations\n", + "baseline = Microsimulation(dataset=\"enhanced_cps_2022\")\n", + "reformed = Microsimulation(reform=reform, dataset=\"enhanced_cps_2022\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "@lru_cache(maxsize=None)\n", + "def calculate_difference(year):\n", + " try:\n", + " baseline_person = baseline.calculate(\"household_net_income\", period=year)\n", + " reformed_person = reformed.calculate(\"household_net_income\", period=year)\n", + " difference = (reformed_person - baseline_person).sum()\n", + " return year, difference\n", + " except Exception as e:\n", + " print(f\"Error calculating for year {year}: {str(e)}\")\n", + " return year, None" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "def main():\n", + " years = list(range(2025, 2035))\n", + " \n", + " # Calculate differences sequentially\n", + " results = [calculate_difference(year) for year in years]\n", + " \n", + " # Filter out any None results from errors\n", + " valid_results = [(year, diff) for year, diff in results if diff is not None]\n", + " valid_years, differences = zip(*valid_results)\n", + "\n", + " # Create Plotly bar chart\n", + " fig = go.Figure(data=[\n", + " go.Bar(name='Impact', x=valid_years, y=differences)\n", + " ])\n", + "\n", + " # Update layout\n", + " fig.update_layout(\n", + " title='Impact of CTC Reform on Household Net Income (2025-2034)',\n", + " xaxis_title='Year',\n", + " yaxis_title='Total Difference in Household Net Income',\n", + " yaxis_tickformat='$,.0f',\n", + " )\n", + "\n", + " # Add hover template to show values in billions\n", + " fig.update_traces(\n", + " hovertemplate='Year: %{x}
Impact: $%{y:,.0f}
($%{y:,.1f} billion)',\n", + " text=[f'${d/1e9:.1f}B' for d in differences],\n", + " textposition='outside'\n", + " )\n", + "\n", + " # Show the plot\n", + " fig.show()\n", + "\n", + " # Print numerical results\n", + " for year, difference in zip(valid_years, differences):\n", + " print(f\"{year}: ${difference/1e9:.2f} billion\")" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "if __name__ == \"__main__\":\n", + " main()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "policyengine", + "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.9.16" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/us/irs/income/credits/ctc/harris_ctc.ipynb b/us/irs/income/credits/ctc/harris/harris_ctc_household.ipynb similarity index 100% rename from us/irs/income/credits/ctc/harris_ctc.ipynb rename to us/irs/income/credits/ctc/harris/harris_ctc_household.ipynb