Skip to content

Harris CTC budget impact #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions us/irs/income/credits/ctc/harris/harris_ctc_budget.ipynb
Original file line number Diff line number Diff line change
@@ -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}<br>Impact: $%{y:,.0f}<br>($%{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
}