You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@MattHJensen, Thanks for the enhancement in B-R PR #44. The new test records are good. But your original thought was that short-term capital gains/losses would complicate the calculation of the the largest long-term capital loss that could be used in the new adjustment. If you specify each of the five test cases to have $9000 in short-term capital gains, then the independence test fails for RECIDs 3, 4, and 5. Here are the alternative test cases:
@MattHJensen, Your original notion that the amount of short-term capital gains would complicate the long-term capital loss adjustment is correct. The adjustment I suggested is not correct. A stronger test shows that my suggestion is incorrect. I suggest you copy and paste the revised test (see below) into your PR branch and then figure out what adjustment formula allows you to pass all the tests. You can run the tests quickly using this command: cd behresp ; pytest -m one -n4 ; cd ..
Here is the revised test:
@pytest.mark.one
@pytest.mark.parametrize("stcg",
[-3600,
-2400,
-1200,
0,
1200,
2400,
3600,
4800])
def test_sub_effect_independence(stcg):
"""
Ensure that LTCG amount does not affect magnitude of substitution effect.
"""
# specify reform that raises top-bracket marginal tax rate
refyear = 2020
reform = {refyear: {'_II_rt7': [0.70]}}
# specify a substitution effect behavioral response
beh_json = """{
"BE_sub": {"2013": 0.25}
}"""
# specify several high-earning filing units
num_recs = 9
input_csv = (u'RECID,MARS,e00200,e00200p,p22250,p23250\n'
u'1,2,1000000,1000000,stcg, 0\n'
u'2,2,1000000,1000000,stcg, 4800\n'
u'3,2,1000000,1000000,stcg, 3600\n'
u'4,2,1000000,1000000,stcg, 2400\n'
u'5,2,1000000,1000000,stcg, 1200\n'
u'6,2,1000000,1000000,stcg, 0\n'
u'7,2,1000000,1000000,stcg,-1200\n'
u'8,2,1000000,1000000,stcg,-2400\n'
u'9,2,1000000,1000000,stcg,-3600\n')
inputcsv = input_csv.replace('stcg', str(stcg))
input_dataframe = pd.read_csv(StringIO(inputcsv))
assert len(input_dataframe.index) == num_recs
recs = tc.Records(data=input_dataframe,
start_year=refyear,
gfactors=None, weights=None)
beh_dict = tc.Calculator.read_json_assumptions(beh_json)
pol = tc.Policy()
calc1 = tc.Calculator(records=recs, policy=pol)
assert calc1.current_year == refyear
pol.implement_reform(reform)
calc2 = tc.Calculator(records=recs, policy=pol)
assert calc2.current_year == refyear
del pol
df1, df2 = response(calc1, calc2, beh_dict)
del calc1
del calc2
# compute change in taxable income for each of the filing units
chg_funit = dict()
for rid in range(1, num_recs + 1):
idx = rid - 1
chg_funit[rid] = df2['c04800'][idx] - df1['c04800'][idx]
del df1
del df2
# confirm reform reduces taxable income when assuming substitution effect
emsg = ''
for rid in range(1, num_recs + 1):
if not chg_funit[rid] < 0:
txt = '\nFAIL: stcg={} : chg[{}]={:.2f} is not negative'
emsg += txt.format(stcg, rid, chg_funit[rid])
# confirm change in taxable income is same for all filing units
for rid in range(2, num_recs + 1):
if not np.allclose(chg_funit[rid], chg_funit[1]):
txt = '\nFAIL: stcg={} : chg[{}]={:.2f} != chg[1]={:.2f}'
emsg += txt.format(stcg, rid, chg_funit[rid], chg_funit[1])
del chg_funit
if emsg:
raise ValueError(emsg)
MattHJensen
changed the title
Increases independence of substitution effects
[WIP] Increases independence of substitution effects
Aug 6, 2020
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This resolves the lack of independence between the substitution effect and the long term capital gains elasticity identified by @martinholmer in #41.