-
Notifications
You must be signed in to change notification settings - Fork 59
/
app02.py
103 lines (93 loc) · 4.05 KB
/
app02.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
"""
app02.py illustrates use of TPRU-India taxcalc release 2.0.0
USAGE: python app02.py > app02.res
CHECK: Use your favorite Windows diff utility to confirm that app02.res is
the same as the app02.out file that is in the repository.
"""
import pandas as pd
from taxcalc import *
# create Records object containing pit.csv and pit_weights.csv input data
recs = Records()
grecs = GSTRecords()
# create CorpRecords object using cross-section data
crecs1 = CorpRecords(data='cit_cross.csv', weights='cit_cross_wgts.csv')
# create CorpRecords object using panel data
crecs2 = CorpRecords(data='cit_panel.csv', data_type='panel')
# create Policy object containing current-law polic
pol1 = Policy()
pol2 = Policy()
reform = Calculator.read_json_param_objects('app01_reform.json', None)
pol2.implement_reform(reform['policy'])
# specify Calculator objects for current-law policy
calc1c = Calculator(policy=pol1, records=recs, corprecords=crecs1,
gstrecords=grecs, verbose=False)
calc1p = Calculator(policy=pol1, records=recs, corprecords=crecs2,
gstrecords=grecs, verbose=False)
calc2c = Calculator(policy=pol2, records=recs, corprecords=crecs1,
gstrecords=grecs, verbose=False)
calc2p = Calculator(policy=pol2, records=recs, corprecords=crecs2,
gstrecords=grecs, verbose=False)
for year in range(2017, 2022):
calc1c.advance_to_year(year)
calc1p.advance_to_year(year)
calc2c.advance_to_year(year)
calc2p.advance_to_year(year)
# Produce DataFrame of results using cross-section
calc1c.calc_all()
AggIncCB = calc1c.carray('GTI_Before_Loss')
GTICB = calc1c.carray('GTI')
TTICB = calc1c.carray('TTI')
citaxCB = calc1c.carray('citax')
wgtCB = calc1c.carray('weight')
calc2c.calc_all()
AggIncCR = calc2c.carray('GTI_Before_Loss')
GTICR = calc2c.carray('GTI')
TTICR = calc2c.carray('TTI')
citaxCR = calc2c.carray('citax')
wgtCR = calc2c.carray('weight')
# Produce DataFrame of results using panel
calc1p.calc_all()
AggIncPB = calc1p.carray('GTI_Before_Loss')
GTIPB = calc1p.carray('GTI')
TTIPB = calc1p.carray('TTI')
citaxPB = calc1p.carray('citax')
wgtPB = calc1p.carray('weight')
calc2p.calc_all()
AggIncPR = calc2p.carray('GTI_Before_Loss')
GTIPR = calc2p.carray('GTI')
TTIPR = calc2p.carray('TTI')
citaxPR = calc2p.carray('citax')
wgtPR = calc2p.carray('weight')
# print(f'Year {year}: {weighted_tax1 * 1e-9:,.2f}')
print(f'************* Year {year} *************')
# print('*************Year ' + str(year) + ' *************')
print('GTI before loss, baseline, cross: ' +
str(sum(AggIncCB * wgtCB) / 10**7))
print('GTI, baseline, cross: ' + str(sum(GTICB * wgtCB) / 10**7))
print('TTI, baseline, cross: ' + str(sum(TTICB * wgtCB) / 10**7))
print('Tax, baseline, cross: ' + str(sum(citaxCB * wgtCB) / 10**7))
print('\n')
print('GTI before loss, reform, cross: ' +
str(sum(AggIncCR * wgtCR) / 10**7))
print('GTI, reform, cross: ' + str(sum(GTICR * wgtCR) / 10**7))
print('TTI, reform, cross: ' + str(sum(TTICR * wgtCR) / 10**7))
print('Tax, reform, cross: ' + str(sum(citaxCR * wgtCR) / 10**7))
print('\n')
print('Change in tax, cross: ' +
str(sum((citaxCR - citaxCB) * wgtCB) / 10**7))
print('\n')
print('GTI before loss, baseline, panel: ' +
str(sum(AggIncPB * wgtPB) / 10**7))
print('GTI, baseline, panel: ' + str(sum(GTIPB * wgtPB) / 10**7))
print('TTI, baseline, panel: ' + str(sum(TTIPB * wgtPB) / 10**7))
print('Tax, baseline, panel: ' + str(sum(citaxPB * wgtPB) / 10**7))
print('\n')
print('GTI before loss, reform, panel: ' +
str(sum(AggIncPR * wgtPR) / 10**7))
print('GTI, reform, panel: ' + str(sum(GTIPR * wgtPR) / 10**7))
print('TTI, reform, panel: ' + str(sum(TTIPR * wgtPR) / 10**7))
print('Tax, reform, panel: ' + str(sum(citaxPR * wgtPR) / 10**7))
print('\n')
print('Change in tax, panel: ' +
str(sum((citaxPR - citaxPB) * wgtPB) / 10**7))
print('\n')