Skip to content
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
112 changes: 112 additions & 0 deletions us/irs/ctc/phase_out_75k_150k/ctc_reform_2026_2035.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env python
"""
CTC Reform Analysis for 2026-2035
Calculates changes in net income and income tax for each year
"""

from policyengine_us import Microsimulation
from policyengine_core.reforms import Reform
import pandas as pd
import gc
import os

# Define the CTC reform
reform = Reform.from_dict(
{
"gov.irs.credits.ctc.phase_out.threshold.JOINT": {
"2025-01-01.2100-12-31": 150000
},
"gov.irs.credits.ctc.phase_out.threshold.SINGLE": {
"2025-01-01.2100-12-31": 75000
},
"gov.irs.credits.ctc.phase_out.threshold.SEPARATE": {
"2025-01-01.2100-12-31": 75000
},
"gov.irs.credits.ctc.phase_out.threshold.SURVIVING_SPOUSE": {
"2025-01-01.2100-12-31": 150000
},
"gov.irs.credits.ctc.phase_out.threshold.HEAD_OF_HOUSEHOLD": {
"2025-01-01.2100-12-31": 75000
},
},
country_id="us",
)

print("Running CTC Reform Analysis for 2026-2035...")
print("=" * 50)

# CSV filename
csv_filename = "us/ctc_reform_2026_2035_results.csv"

# Remove existing file if it exists
if os.path.exists(csv_filename):
os.remove(csv_filename)
print(f"Removed existing {csv_filename}")

# Store results
results = []

# Analyze each year
for year in range(2026, 2036):
print(f"\nAnalyzing year {year}...")

# Create simulations fresh for each year to avoid memory issues
baseline = Microsimulation()
reformed = Microsimulation(reform=reform)

# Calculate net income
baseline_income = baseline.calculate("household_net_income", period=year)
reformed_income = reformed.calculate("household_net_income", period=year)
income_change = (reformed_income - baseline_income).sum()

# Calculate income tax (aggregated to household level)
baseline_tax = baseline.calculate("income_tax", period=year, map_to="household")
reformed_tax = reformed.calculate("income_tax", period=year, map_to="household")
tax_change = (reformed_tax - baseline_tax).sum()

result = {
"year": year,
"net_income_change": income_change,
"income_tax_change": tax_change
}
results.append(result)

print(f" Net income change: ${income_change:,.0f}")
print(f" Income tax change: ${tax_change:,.0f}")

# Write to CSV incrementally
df_temp = pd.DataFrame(results)
df_temp.to_csv(csv_filename, index=False)
print(f" Saved progress to {csv_filename}")

# Clean up memory
del baseline
del reformed
del baseline_income
del reformed_income
del baseline_tax
del reformed_tax
gc.collect()

# Create final DataFrame with total
df = pd.DataFrame(results)

# Add total row
total_row = pd.DataFrame([{
"year": "Total",
"net_income_change": df["net_income_change"].sum(),
"income_tax_change": df["income_tax_change"].sum()
}])

df = pd.concat([df, total_row], ignore_index=True)

# Save final CSV with total
df.to_csv(csv_filename, index=False)

print("\n" + "=" * 50)
print("SUMMARY RESULTS")
print("=" * 50)
print(df.to_string(index=False))

print(f"\nResults saved to: {csv_filename}")
print("Done!")
12 changes: 12 additions & 0 deletions us/irs/ctc/phase_out_75k_150k/ctc_reform_2026_2035_results.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
year,net_income_change,income_tax_change
2026,-21319920026.623302,21327176345.411194
2027,-23334467358.78863,23342990910.804153
2028,-25413250650.04707,25019280284.84611
2029,-27982635607.501617,27542251556.544712
2030,-29864186181.356224,29397985066.77014
2031,-32238075553.132988,31731941956.156883
2032,-33806888859.782974,33277892781.083076
2033,-36206939820.67604,35636937981.324974
2034,-37942321527.10655,37340956600.95574
2035,-40479871308.47856,39837039465.4972
Total,-308588556893.494,304454452949.3942