Skip to content

Instantly share code, notes, and snippets.

@MaxGhenis
Created July 26, 2025 04:06
Show Gist options
  • Save MaxGhenis/e16d573c11f312863a61fa7b96206db4 to your computer and use it in GitHub Desktop.
Save MaxGhenis/e16d573c11f312863a61fa7b96206db4 to your computer and use it in GitHub Desktop.
Federal CTC expansion reduces MA state tax by triggering itemization
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"# Federal CTC Expansion Reduces MA State Tax\n",
"\n",
"This notebook demonstrates how federal CTC expansion reduces Massachusetts state tax for household 4428 (tax unit 442801)."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "2",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-26T04:05:27.521780Z",
"iopub.status.busy": "2025-07-26T04:05:27.521470Z",
"iopub.status.idle": "2025-07-26T04:05:33.259700Z",
"shell.execute_reply": "2025-07-26T04:05:33.259369Z"
}
},
"outputs": [],
"source": [
"from policyengine_us import Microsimulation\n",
"from policyengine_us.model_api import *\n",
"import numpy as np\n",
"\n",
"DATASET = \"hf://policyengine/policyengine-us-data/enhanced_cps_2024.h5\"\n",
"YEAR = 2026\n",
"TAX_UNIT_ID = 442801"
]
},
{
"cell_type": "markdown",
"id": "3",
"metadata": {},
"source": [
"## Step 1: Without CTC Expansion"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-26T04:05:33.261686Z",
"iopub.status.busy": "2025-07-26T04:05:33.261578Z",
"iopub.status.idle": "2025-07-26T04:06:07.685209Z",
"shell.execute_reply": "2025-07-26T04:06:07.683385Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WITHOUT CTC EXPANSION:\n",
" Federal itemizes: False\n",
" MA state tax: $-4,409.01\n",
" MA Part B exemption: $12,800.00\n"
]
}
],
"source": [
"# Reform stack WITHOUT CTC\n",
"reform_no_ctc = Reform.from_dict({\n",
" \"gov.irs.income.bracket.rates.2\": {\"2026-01-01\": 0.15},\n",
" \"gov.irs.income.bracket.rates.3\": {\"2026-01-01\": 0.25},\n",
" \"gov.irs.income.bracket.rates.4\": {\"2026-01-01\": 0.28},\n",
" \"gov.irs.deductions.standard.amount.JOINT\": {\"2026-01-01\": 48900},\n",
" \"gov.irs.income.exemption.amount\": {\"2026-01-01\": 0},\n",
"}, country_id=\"us\")\n",
"\n",
"sim_no_ctc = Microsimulation(reform=reform_no_ctc, dataset=DATASET)\n",
"\n",
"# Find our tax unit\n",
"tax_unit_ids = sim_no_ctc.calculate(\"tax_unit_id\", period=YEAR).values\n",
"tu_idx = np.where(tax_unit_ids == TAX_UNIT_ID)[0][0]\n",
"\n",
"itemizes_no_ctc = bool(sim_no_ctc.calculate('tax_unit_itemizes', YEAR).values[tu_idx])\n",
"ma_tax_no_ctc = sim_no_ctc.calculate('ma_income_tax', YEAR).values[tu_idx]\n",
"ma_exemption_no_ctc = sim_no_ctc.calculate('ma_part_b_taxable_income_exemption', YEAR).values[tu_idx]\n",
"\n",
"print(\"WITHOUT CTC EXPANSION:\")\n",
"print(f\" Federal itemizes: {itemizes_no_ctc}\")\n",
"print(f\" MA state tax: ${ma_tax_no_ctc:,.2f}\")\n",
"print(f\" MA Part B exemption: ${ma_exemption_no_ctc:,.2f}\")"
]
},
{
"cell_type": "markdown",
"id": "5",
"metadata": {},
"source": [
"## Step 2: With CTC Expansion"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-26T04:06:07.691608Z",
"iopub.status.busy": "2025-07-26T04:06:07.691489Z",
"iopub.status.idle": "2025-07-26T04:06:42.388653Z",
"shell.execute_reply": "2025-07-26T04:06:42.387992Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WITH CTC EXPANSION:\n",
" Federal itemizes: True\n",
" MA state tax: $-4,465.42\n",
" MA Part B exemption: $13,928.17\n"
]
}
],
"source": [
"# Add CTC expansion\n",
"reform_with_ctc = Reform.from_dict({\n",
" \"gov.irs.income.bracket.rates.2\": {\"2026-01-01\": 0.15},\n",
" \"gov.irs.income.bracket.rates.3\": {\"2026-01-01\": 0.25},\n",
" \"gov.irs.income.bracket.rates.4\": {\"2026-01-01\": 0.28},\n",
" \"gov.irs.deductions.standard.amount.JOINT\": {\"2026-01-01\": 48900},\n",
" \"gov.irs.income.exemption.amount\": {\"2026-01-01\": 0},\n",
" # CTC expansion parameters\n",
" \"gov.contrib.reconciliation.ctc.in_effect\": {\"2026-01-01\": True},\n",
" \"gov.irs.credits.ctc.amount.base[0].amount\": {\"2026-01-01\": 2200},\n",
"}, country_id=\"us\")\n",
"\n",
"sim_with_ctc = Microsimulation(reform=reform_with_ctc, dataset=DATASET)\n",
"\n",
"itemizes_with_ctc = bool(sim_with_ctc.calculate('tax_unit_itemizes', YEAR).values[tu_idx])\n",
"ma_tax_with_ctc = sim_with_ctc.calculate('ma_income_tax', YEAR).values[tu_idx]\n",
"ma_exemption_with_ctc = sim_with_ctc.calculate('ma_part_b_taxable_income_exemption', YEAR).values[tu_idx]\n",
"\n",
"print(\"WITH CTC EXPANSION:\")\n",
"print(f\" Federal itemizes: {itemizes_with_ctc}\")\n",
"print(f\" MA state tax: ${ma_tax_with_ctc:,.2f}\")\n",
"print(f\" MA Part B exemption: ${ma_exemption_with_ctc:,.2f}\")"
]
},
{
"cell_type": "markdown",
"id": "7",
"metadata": {},
"source": [
"## Step 3: Analysis"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "8",
"metadata": {
"execution": {
"iopub.execute_input": "2025-07-26T04:06:42.391046Z",
"iopub.status.busy": "2025-07-26T04:06:42.390926Z",
"iopub.status.idle": "2025-07-26T04:06:42.394801Z",
"shell.execute_reply": "2025-07-26T04:06:42.394556Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"IMPACT OF FEDERAL CTC EXPANSION ON MA STATE TAX:\n",
" MA state tax reduction: $56.41\n",
" MA Part B exemption increase: $1,128.17\n",
"\n",
"MECHANISM:\n",
"1. CTC expansion triggers federal itemization: True → True\n",
"2. MA allows itemizers to claim medical expense deduction in Part B exemption\n",
"3. Medical expense deduction: $1,128.17\n",
"4. MA tax rate: 5%\n",
"5. Tax savings: $1,128.17 × 5% = $56.41\n",
"\n",
"Federal tax comparison (with CTC):\n",
" If itemizing: $-11,554.11\n",
" If standard deduction: $-11,554.11\n",
" Difference: $0.00\n",
" → Federal tax is essentially the same either way\n"
]
}
],
"source": [
"# Calculate the impact\n",
"ma_tax_change = ma_tax_with_ctc - ma_tax_no_ctc\n",
"exemption_change = ma_exemption_with_ctc - ma_exemption_no_ctc\n",
"\n",
"print(\"IMPACT OF FEDERAL CTC EXPANSION ON MA STATE TAX:\")\n",
"print(f\" MA state tax reduction: ${-ma_tax_change:,.2f}\")\n",
"print(f\" MA Part B exemption increase: ${exemption_change:,.2f}\")\n",
"\n",
"print(f\"\\nMECHANISM:\")\n",
"print(f\"1. CTC expansion triggers federal itemization: {not itemizes_no_ctc} → {itemizes_with_ctc}\")\n",
"print(f\"2. MA allows itemizers to claim medical expense deduction in Part B exemption\")\n",
"\n",
"# Show medical expense deduction\n",
"med_expense = sim_with_ctc.calculate('medical_expense_deduction', YEAR).values[tu_idx]\n",
"print(f\"3. Medical expense deduction: ${med_expense:,.2f}\")\n",
"print(f\"4. MA tax rate: 5%\")\n",
"print(f\"5. Tax savings: ${exemption_change:,.2f} × 5% = ${exemption_change * 0.05:,.2f}\")\n",
"\n",
"# Verify federal tax is same either way\n",
"fed_tax_item = sim_with_ctc.calculate('tax_liability_if_itemizing', YEAR).values[tu_idx]\n",
"fed_tax_std = sim_with_ctc.calculate('tax_liability_if_not_itemizing', YEAR).values[tu_idx]\n",
"print(f\"\\nFederal tax comparison (with CTC):\")\n",
"print(f\" If itemizing: ${fed_tax_item:,.2f}\")\n",
"print(f\" If standard deduction: ${fed_tax_std:,.2f}\")\n",
"print(f\" Difference: ${abs(fed_tax_item - fed_tax_std):,.2f}\")\n",
"print(f\" → Federal tax is essentially the same either way\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.13.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment