-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/PolicyEngine/policyengine-us into hua7450/issue5109
- Loading branch information
Showing
18 changed files
with
603 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Inputting Dates for Structural Reforms\n", | ||
"\n", | ||
"\"Structural\" reforms are those reforms that modify not only set values in the tax-benefit system, but also the formulas used to calculate taxes and benefits. These are typcially larger, more involved reforms that require custom coding.\n", | ||
"\n", | ||
"Due to the current limitations of the `Microsimulation` class, a code patch is required when running structural reforms with parameters that begin at any date other than January 1st of the current year. \n", | ||
"\n", | ||
"For example, the code cell below illustrates a standard way to instantiating a structural reform, without the patch, when simulating in 2024:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/opt/miniconda3/envs/us-3.11/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", | ||
" from .autonotebook import tqdm as notebook_tqdm\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Diff: -2605373719.2974854\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from policyengine_us import Microsimulation\n", | ||
"from policyengine_core.reforms import Reform\n", | ||
"\n", | ||
"reform_1 = Reform.from_dict(\n", | ||
" {\n", | ||
" \"gov.contrib.salt_phase_out.in_effect\": {\n", | ||
" \"2024-01-01.2100-12-31\": True\n", | ||
" },\n", | ||
" \"gov.contrib.salt_phase_out.rate.joint[1].rate\": {\n", | ||
" \"2024-01-01.2100-12-31\": 0.001\n", | ||
" },\n", | ||
" \"gov.contrib.salt_phase_out.rate.joint[1].threshold\": {\n", | ||
" \"2024-01-01.2100-12-31\": 200000\n", | ||
" },\n", | ||
" \"gov.contrib.salt_phase_out.rate.other[1].rate\": {\n", | ||
" \"2024-01-01.2100-12-31\": 0.001\n", | ||
" },\n", | ||
" \"gov.contrib.salt_phase_out.rate.other[1].threshold\": {\n", | ||
" \"2024-01-01.2100-12-31\": 400000\n", | ||
" },\n", | ||
" },\n", | ||
" country_id=\"us\",\n", | ||
")\n", | ||
"\n", | ||
"\n", | ||
"baseline_sim_1 = Microsimulation()\n", | ||
"reformed_sim_1 = Microsimulation(reform=reform_1)\n", | ||
"baseline_salt_1 = baseline_sim_1.calculate(\"salt_deduction\", period=2026)\n", | ||
"reformed_salt_1 = reformed_sim_1.calculate(\"salt_deduction\", period=2026)\n", | ||
"print(f\"Diff: {reformed_salt_1.sum() - baseline_salt_1.sum()}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The cell below shows a series of reforms that begin in 2026, later than the current year. To effectively handle this case, we need to add an argument to the `Microsimulation` classes that we call. \n", | ||
"\n", | ||
"This argument, called `start_instant`, should be set to the same date as the start of the reforms, in ISO date format. In the case of the example below, this is `2026-01-01`, so our altered call to `Microsimulation` looks like:\n", | ||
"\n", | ||
"```\n", | ||
"baseline_sim_2 = Microsimulation(start_instant=\"2026-01-01\")\n", | ||
"reformed_sim_2 = Microsimulation(reform=reform_2, start_instant=\"2026-01-01\")\n", | ||
"```" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Diff: -2605373719.2974854\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from policyengine_us import Microsimulation\n", | ||
"from policyengine_core.reforms import Reform\n", | ||
"\n", | ||
"reform_2 = Reform.from_dict(\n", | ||
" {\n", | ||
" \"gov.contrib.salt_phase_out.in_effect\": {\n", | ||
" \"2026-01-01.2100-12-31\": True\n", | ||
" },\n", | ||
" \"gov.contrib.salt_phase_out.rate.joint[1].rate\": {\n", | ||
" \"2026-01-01.2100-12-31\": 0.001\n", | ||
" },\n", | ||
" \"gov.contrib.salt_phase_out.rate.joint[1].threshold\": {\n", | ||
" \"2026-01-01.2100-12-31\": 200000\n", | ||
" },\n", | ||
" \"gov.contrib.salt_phase_out.rate.other[1].rate\": {\n", | ||
" \"2026-01-01.2100-12-31\": 0.001\n", | ||
" },\n", | ||
" \"gov.contrib.salt_phase_out.rate.other[1].threshold\": {\n", | ||
" \"2026-01-01.2100-12-31\": 400000\n", | ||
" },\n", | ||
" },\n", | ||
" country_id=\"us\",\n", | ||
")\n", | ||
"\n", | ||
"\n", | ||
"baseline_sim_2 = Microsimulation(start_instant=\"2026-01-01\")\n", | ||
"reformed_sim_2 = Microsimulation(reform=reform_2, start_instant=\"2026-01-01\")\n", | ||
"baseline_salt_2 = baseline_sim_2.calculate(\"salt_deduction\", period=2026)\n", | ||
"reformed_salt_2 = reformed_sim_2.calculate(\"salt_deduction\", period=2026)\n", | ||
"print(f\"Diff: {reformed_salt_2.sum() - baseline_salt_2.sum()}\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "us-3.11", | ||
"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.11.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
2 changes: 1 addition & 1 deletion
2
policyengine_us/parameters/gov/contrib/states/ny/wftc/child_age_threshold.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
policyengine_us/parameters/gov/contrib/states/ny/wftc/exemptions/child_age_threshold.yaml
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...rameters/gov/states/ne/tax/income/agi/subtractions/military_retirement/age_threshold.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
description: Nebraska limits the military retirement benefits to filers this age or older. | ||
|
||
values: | ||
2015-01-01: 67 | ||
|
||
metadata: | ||
unit: year | ||
period: year | ||
label: Nebraska military retirement benefits age threshold | ||
reference: | ||
- title: 2021 Nebraska Individual Income Tax Booklet | ||
href: https://revenue.nebraska.gov/sites/revenue.nebraska.gov/files/doc/f_1040n_booklet.pdf#page=16 | ||
- title: 2022 NE income tax form and instruction booklet | ||
href: https://revenue.nebraska.gov/sites/revenue.nebraska.gov/files/doc/2022_Ne_Individual_Income_Tax_Booklet_8-307-2022_final_8.pdf#page=3 | ||
- title: 2023 Nebraska Individual Income Tax Booklet | ||
href: https://revenue.nebraska.gov/sites/revenue.nebraska.gov/files/doc/tax-forms/2023/incometax/f_1040n_booklet_2023_Final.pdf#page=19 | ||
- title: Nebraska Revised Statute 77-2716 (15)(a) | ||
href: https://nebraskalegislature.gov/laws/statutes.php?statute=77-2716 |
19 changes: 19 additions & 0 deletions
19
...us/parameters/gov/states/ne/tax/income/agi/subtractions/military_retirement/fraction.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
description: Nebraska subtracts this fraction of military retirement benefits from federal adjusted gross income. | ||
values: | ||
2021-01-01: 0.4 | ||
2022-01-01: 1 | ||
|
||
metadata: | ||
label: Nebraska military retirement subtraction fraction | ||
unit: /1 | ||
period: year | ||
reference: | ||
- title: 2021 Nebraska Individual Income Tax Booklet | ||
href: https://revenue.nebraska.gov/sites/revenue.nebraska.gov/files/doc/f_1040n_booklet.pdf#page=16 | ||
- title: 2022 NE income tax form and instruction booklet | ||
href: https://revenue.nebraska.gov/sites/revenue.nebraska.gov/files/doc/2022_Ne_Individual_Income_Tax_Booklet_8-307-2022_final_8.pdf#page=3 | ||
- title: 2023 Nebraska Individual Income Tax Booklet | ||
href: https://revenue.nebraska.gov/sites/revenue.nebraska.gov/files/doc/tax-forms/2023/incometax/f_1040n_booklet_2023_Final.pdf#page=19 | ||
- title: Nebraska Revised Statute 77-2716(15) | ||
href: https://nebraskalegislature.gov/laws/statutes.php?statute=77-2716 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.