Skip to content
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

New Jersey CTC impact #1

Open
wants to merge 5 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
209 changes: 209 additions & 0 deletions us/neutralize_state_eitc_and_ctc.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"from policyengine_us import Microsimulation\n",
"from policyengine_core.reforms import Reform\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [],
"source": [
"REFORMS = {\n",
" \"Baseline\": None,\n",
" \"Expand refundable CTC\": {\n",
" \"gov.contrib.congress.wyden_smith.per_child_actc_phase_in\": {\n",
" \"2024-01-01.2100-12-31\": True\n",
" },\n",
" \"gov.irs.credits.ctc.refundable.individual_max\": {\n",
" \"2024-01-01.2100-12-31\": 2000\n",
" },\n",
" \"gov.irs.credits.ctc.refundable.phase_in.threshold\": {\n",
" \"2024-01-01.2100-12-31\": 0\n",
" }\n",
" },\n",
" \"Restore ARPA EITC expansion for childless filers\": {\n",
" \"gov.irs.credits.eitc.eligibility.age.max\": {\n",
" \"2023-01-01.2028-12-31\": 100\n",
" },\n",
" \"gov.irs.credits.eitc.eligibility.age.min\": {\n",
" \"2023-01-01.2028-12-31\": 19\n",
" },\n",
" \"gov.irs.credits.eitc.max[0].amount\": {\n",
" \"2023-01-01.2028-12-31\": 1502\n",
" },\n",
" \"gov.irs.credits.eitc.phase_in_rate[0].amount\": {\n",
" \"2023-01-01.2028-12-31\": 0.153\n",
" },\n",
" \"gov.irs.credits.eitc.phase_out.rate[0].amount\": {\n",
" \"2023-01-01.2028-12-31\": 0.153\n",
" },\n",
" \"gov.irs.credits.eitc.phase_out.start[0].amount\": {\n",
" \"2023-01-01.2028-12-31\": 11610\n",
" }\n",
" },\n",
" \"SSI Reform\": {\n",
" \"gov.ssa.ssi.income.exclusions.earned_share\": {\n",
" \"2024-01-01.2100-12-31\": 0.7\n",
" }\n",
" },\n",
" \"SNAP Reform\": {\n",
" \"gov.usda.snap.expected_contribution\": {\n",
" \"2024-01-01.2100-12-31\": 0.2\n",
" },\n",
" \"gov.usda.snap.income.deductions.earned_income\": {\n",
" \"2024-01-01.2100-12-31\": 0.3\n",
" },\n",
" \"gov.usda.snap.income.limit.gross\": {\n",
" \"2024-01-01.2100-12-31\": 2\n",
" },\n",
" \"gov.usda.snap.income.limit.net\": {\n",
" \"2024-01-01.2100-12-31\": 10000\n",
" }\n",
" }\n",
"}\n"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [],
"source": [
"def get_earners_above_mtr(reform=None, threshold=0.45, adult_index_limit=3):\n",
" if reform is None:\n",
" sim = Microsimulation(dataset=\"enhanced_cps_2022\")\n",
" else:\n",
" sim = Microsimulation(reform=Reform.from_dict(reform, country_id=\"us\"), dataset=\"enhanced_cps_2022\")\n",
" \n",
" mtr = sim.calculate(\"marginal_tax_rate\", map_to=\"person\", period=2024)\n",
"\n",
" adult_index = sim.calculate(\"adult_index\", map_to=\"person\", period=2024)\n",
"\n",
" is_adult = adult_index > 0\n",
" include = is_adult[adult_index <= adult_index_limit]\n",
"\n",
" total = include.sum()\n",
"\n",
" exceeds_mtr = include[mtr > threshold]\n",
" return exceeds_mtr.sum() / total\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running Baseline\n",
"Running Expand refundable CTC\n",
"Running Restore ARPA EITC expansion for childless filers\n",
"Running SSI Reform\n",
"Running SNAP Reform\n"
]
}
],
"source": [
"results = []\n",
"\n",
"for reform_name, reform_details in REFORMS.items():\n",
" print(f\"Running {reform_name}\")\n",
" proportion = get_earners_above_mtr(reform=reform_details)\n",
" results.append({\"Reform\": reform_name, \"Proportion Above MTR\": proportion})\n",
"\n",
"# Add one more run with all four reforms applied as a tuple.\n",
"all_reforms = {k: v for reform in REFORMS.values() if reform is not None for k, v in reform.items()}\n",
"results.append({\"Reform\": \"All reforms\", \"Proportion Above MTR\": get_earners_above_mtr(reform=all_reforms)})"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [],
"source": [
"# Add one more run with all four reforms applied as a tuple.\n",
"all_reforms = {k: v for reform in REFORMS.values() if reform is not None for k, v in reform.items()}\n",
"results.append({\"Reform\": \"All Reforms\", \"Proportion Above MTR\": get_earners_above_mtr(reform=all_reforms)})"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Reform Proportion Above MTR \\\n",
"0 Baseline 0.105700 \n",
"1 Expand refundable CTC 0.064971 \n",
"2 Restore ARPA EITC expansion for childless filers 0.109615 \n",
"3 SSI Reform 0.081134 \n",
"4 SNAP Reform 0.083002 \n",
"5 All reforms 0.079570 \n",
"\n",
" change \n",
"0 0.000000 \n",
"1 -0.385323 \n",
"2 0.037038 \n",
"3 -0.232416 \n",
"4 -0.214738 \n",
"5 -0.247211 \n"
]
}
],
"source": [
"# Create a DataFrame from the results\n",
"df = pd.DataFrame(results)\n",
"\n",
"# Add a column for the reform as a percentage of the baseline\n",
"df[\"change\"] = (df[\"Proportion Above MTR\"] / df.loc[0, \"Proportion Above MTR\"]) - 1\n",
"\n",
"# Display the DataFrame\n",
"print(df)"
]
},
{
"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
}
115 changes: 115 additions & 0 deletions us/states/nj/nj_ctc_impact_neitralize.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"from policyengine_us import Microsimulation\n",
"from policyengine_core.reforms import Reform\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"baseline = Microsimulation()\n",
"baseline_net_income = baseline.calculate(\"household_net_income\", period = 2024)\n",
"baseline_in_poverty = baseline.calculate(\"in_poverty\", map_to=\"household\")\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"def calculate_changes_for_program():\n",
" class NeutralizeProgram(Reform):\n",
" def apply(self):\n",
" self.neutralize_variable(\"nj_ctc\")\n",
"\n",
" # Initialize the baseline and reformed simulations\n",
" reformed = Microsimulation(reform = NeutralizeProgram)\n",
" baseline.macro_cache_read = False\n",
" reformed.macro_cache_read = False\n",
"\n",
" # Calculate net income change for the specific state\n",
" state_codes = baseline.calculate(\"state_code\")\n",
" reformed_net_income = reformed.calculate(\"household_net_income\", period = 2024)\n",
" net_income_change = reformed_net_income[state_codes == \"NJ\"].sum() - baseline_net_income[state_codes == \"NJ\"].sum()\n",
"\n",
"\n",
" # Calculate in_poverty mean for persons for the specific state\n",
" reformed_in_poverty = reformed.calculate(\"in_poverty\", map_to=\"household\")\n",
" baseline_in_poverty_mean = baseline_in_poverty[state_codes == \"NJ\"].mean()\n",
" reformed_in_poverty_mean = reformed_in_poverty[state_codes == \"NJ\"].mean()\n",
" in_poverty_mean_change = reformed_in_poverty_mean - baseline_in_poverty_mean\n",
"\n",
" # Calculate Gini index for the specific state\n",
" personal_hh_equiv_income = reformed.calculate(\"equiv_household_net_income\")\n",
" household_count_people = reformed.calculate(\"household_count_people\")\n",
" personal_hh_equiv_income.weights *= household_count_people\n",
" gini_index = personal_hh_equiv_income.gini()\n",
"\n",
" return net_income_change, in_poverty_mean_change, gini_index"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Program State Net Income Change In Poverty Mean Change Gini Index\n",
"0 ca_eitc CA -6.510572e+08 0.0 0.39275\n"
]
}
],
"source": [
"# Create a DataFrame and store the results directly\n",
"results = [{\n",
" 'Program': \"nj_ctc\",\n",
" 'State': \"NJ\",\n",
" 'Net Income Change': calculate_changes_for_program()[0],\n",
" 'In Poverty Mean Change': calculate_changes_for_program()[1],\n",
" 'Gini Index': calculate_changes_for_program()[2]\n",
"}]\n",
"\n",
"# Convert the results to a DataFrame\n",
"results_df = pd.DataFrame(results)\n",
"\n",
"# Display the DataFrame\n",
"print(results_df)\n"
]
}
],
"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
}
Loading