-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1579 from martinholmer/fix-gdp-logic
Fix macro-elasticity logic so that GDP change in year t depends on tax change in year t-1
- Loading branch information
Showing
9 changed files
with
134 additions
and
60 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
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
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 |
---|---|---|
@@ -1,17 +1,43 @@ | ||
from taxcalc import Policy, Records, Calculator, proportional_change_gdp | ||
""" | ||
Tests of proportional_change_in_gdp function. | ||
""" | ||
# CODING-STYLE CHECKS: | ||
# pep8 --ignore=E402 test_macro_elasticity.py | ||
# pylint --disable=locally-disabled test_macro_elasticity.py | ||
|
||
import pytest | ||
from taxcalc import (Policy, Records, # pylint: disable=import-error | ||
Calculator, proportional_change_in_gdp) | ||
|
||
def test_proportional_change_gdp(cps_subsample): | ||
|
||
def test_proportional_change_in_gdp(cps_subsample): | ||
""" | ||
Test correct and incorrect calls to proportional_change_in_gdp function. | ||
""" | ||
rec1 = Records.cps_constructor(data=cps_subsample) | ||
calc1 = Calculator(policy=Policy(), records=rec1) | ||
rec2 = Records.cps_constructor(data=cps_subsample) | ||
pol2 = Policy() | ||
reform = {2013: {'_II_em': [0.0]}} # reform increases taxes and MTRs | ||
reform = {2015: {'_II_em': [0.0]}} # reform increases taxes and MTRs | ||
pol2.implement_reform(reform) | ||
calc2 = Calculator(policy=pol2, records=rec2) | ||
calc1.advance_to_year(2014) | ||
calc2.advance_to_year(2014) | ||
gdp_pchg = 100.0 * proportional_change_gdp(calc1, calc2, elasticity=0.36) | ||
exp_pchg = -0.6 # higher MTRs imply negative expected GDP percent change | ||
assert calc1.current_year == 2014 # because using CPS data | ||
gdpc = proportional_change_in_gdp(2014, calc1, calc2, elasticity=0.36) | ||
assert gdpc == 0.0 # no effect for first data year | ||
gdpc = proportional_change_in_gdp(2015, calc1, calc2, elasticity=0.36) | ||
assert gdpc == 0.0 # no effect in first year of reform | ||
calc1.increment_year() | ||
calc2.increment_year() | ||
assert calc1.current_year == 2015 | ||
gdp_pchg = 100.0 * proportional_change_in_gdp(2016, calc1, calc2, | ||
elasticity=0.36) | ||
exp_pchg = -0.54 # higher MTRs imply negative expected GDP percent change | ||
abs_diff_pchg = abs(gdp_pchg - exp_pchg) | ||
assert abs_diff_pchg < 0.05 | ||
if abs_diff_pchg > 0.01: | ||
msg = 'year,gdp_pchg,exp_pchg= {} {:.3f} {:.3f}'.format(2016, | ||
gdp_pchg, | ||
exp_pchg) | ||
assert msg == 'ERROR: gdp_pchg not close to exp_pchg' | ||
# skip calcN.increment_year to 2016, so calcN.current_year is still 2015 | ||
with pytest.raises(ValueError): | ||
proportional_change_in_gdp(2017, calc1, calc2, elasticity=0.36) |
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