-
Notifications
You must be signed in to change notification settings - Fork 65
/
app02.py
149 lines (131 loc) · 5.88 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
"""
app01.py illustrates use of pitaxcalc-demo release 2.0.0 (India version).
USAGE: python app0.py > app0.res
CHECK: Use your favorite Windows diff utility to confirm that app0.res is
the same as the app0.out file that is in the repository.
"""
import pandas as pd
#import taxcalc.taxcalc_globals as global_var
import json
data_filename = "pit.csv"
weights_filename = "pit_weights1.csv"
records_variables_filename = "records_variables.json"
cit_data_filename = "cit_cross.csv"
cit_weights_filename = "cit_cross_wgts1.csv"
corprecords_variables_filename = "corprecords_variables.json"
gst_data_filename = "gst.csv"
gst_weights_filename = "gst_weights.csv"
gstrecords_variables_filename = "gstrecords_variables.json"
policy_filename = "current_law_policy_cmie.json"
growfactors_filename = "growfactors1.csv"
benchmark_filename = "tax_incentives_benchmark.json"
vars = {}
vars['DEFAULTS_FILENAME'] = policy_filename
vars['GROWFACTORS_FILENAME'] = growfactors_filename
vars['pit_data_filename'] = data_filename
vars['pit_weights_filename'] = weights_filename
vars['records_variables_filename'] = records_variables_filename
vars['cit_data_filename'] = cit_data_filename
vars['cit_weights_filename'] = cit_weights_filename
vars['corprecords_variables_filename'] = corprecords_variables_filename
vars['gst_data_filename'] = gst_data_filename
vars['gst_weights_filename'] = gst_weights_filename
vars['gstrecords_variables_filename'] = gstrecords_variables_filename
vars['benchmark_filename'] = benchmark_filename
with open('global_vars.json', 'w') as f:
json.dump(vars, f)
from taxcalc import *
#Policy.default_data(metadata=True).keys()
# 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_wgts1.csv')
# create CorpRecords object using panel data
crecs2 = CorpRecords(data='cit_panel.csv', data_type='panel')
#pbase = ParametersBase()
#pbase.DEFAULTS_FILENAME = 'current_law_policy_cmie.json'
# create Policy object containing current-law policy
#pol1 = Policy(pbase)
#pol2 = Policy(pbase)
print("in app02 - starting Pol")
pol1 = Policy(DEFAULTS_FILENAME='current_law_policy_cmie.json')
pol2 = Policy(DEFAULTS_FILENAME='current_law_policy_cmie.json')
#from taxcalc.calculator import *
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(2019, 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')
"""