forked from PSLmodels/Business-Taxation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interest_model.py
145 lines (139 loc) · 5.72 KB
/
interest_model.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
def calcNIDscale(capital_path, eta=0.4):
"""
Calculates the adjustment factor for corporate debt and interest
capital_path: growth path of the corporate capital stock
eta: retirement rate of existing debt
"""
Kstock2016 = capital_path['Kstock'][2]
K_fa = debt_data_corp['Kfa'][:57].tolist()
A = debt_data_corp['A'][:57].tolist()
L = debt_data_corp['L'][:57].tolist()
D = [L[i] - A[i] for i in range(len(L))]
i_t = debt_data_corp['i_t'].tolist()
i_pr = debt_data_corp['i_pr'].tolist()
for i in range(57, 68):
K_fa.append(K_fa[56] * capital_path['Kstock'][i-54] / Kstock2016)
A.append(A[56] * K_fa[i] / K_fa[56])
D.append(D[56] * K_fa[i] / K_fa[56])
L.append(D[i] - A[i])
R = np.zeros(68)
O = np.zeros(68)
for i in range(1, 68):
R[i] = L[i-1] * eta
O[i] = L[i] - L[i-1] + R[i]
i_a = [x / 100. for x in i_t]
i_l = [(i_t[i] + i_pr[i]) / 100. for i in range(len(i_t))]
int_income = [A[i] * i_a[i] for i in range(len(A))]
int_expense = np.zeros(68)
for i in range(1, 68):
for j in range(i+1):
int_expense[i] += O[j] * (1 - eta)**(i - j - 1) * i_l[j]
NID_gross = int_expense - int_income
NID_scale = sum((debt_data_corp['NID_IRS'][38:54] / NID_gross[38:54])) / 16
return NID_scale
adjfactor_int_corp = calcNIDscale(capPath_base_corp)
def calcIDscale_noncorp(capital_path, eta=0.4):
"""
Calculates the adjustment factor for noncorporate debt and interest
capital_path: growth path of the noncorporate capital stock
eta: retirement rate of existing debt
"""
Kstock2016 = capital_path['Kstock'][2]
K_fa = debt_data_noncorp['Kfa'][:57].tolist()
L = debt_data_noncorp['L'][:57].tolist()
i_t = debt_data_noncorp['i_t'].tolist()
i_pr = debt_data_noncorp['i_pr'].tolist()
for i in range(57, 68):
K_fa.append(K_fa[56] * capital_path['Kstock'][i-54] / Kstock2016)
L.append(L[56] * K_fa[i] / K_fa[56])
R = np.zeros(68)
O = np.zeros(68)
for i in range(1, 68):
R[i] = L[i-1] * eta
O[i] = L[i] - L[i-1] + R[i]
i_l = [(i_t[i] + i_pr[i]) / 100. for i in range(len(i_t))]
int_expense = np.zeros(68)
for i in range(1, 68):
for j in range(i+1):
int_expense[i] += O[j] * (1 - eta)**(i - j - 1) * i_l[j]
ID_scale = sum(((debt_data_noncorp['ID_Scorp'][38:54] +
debt_data_noncorp['ID_sp'][38:54] +
debt_data_noncorp['ID_partner'][38:54]) /
int_expense[38:54])) / 16
return ID_scale
adjfactor_int_noncorp = calcIDscale_noncorp(capPath_base_noncorp)
def netInterestDeduction(capital_path, eta=0.4):
"""
Calculates the debt, net interest deduction and interest paid,
baseline for corporations.
capital_path: growth path of the corporate capital stock
eta: retirement rate of existing debt
"""
Kstock2016 = capital_path['Kstock'][2]
K_fa = debt_data_corp['Kfa'][:57].tolist()
A = debt_data_corp['A'][:57].tolist()
L = debt_data_corp['L'][:57].tolist()
D = [L[i] - A[i] for i in range(len(L))]
i_t = debt_data_corp['i_t'].tolist()
i_pr = debt_data_corp['i_pr'].tolist()
for i in range(57, 68):
K_fa.append(K_fa[56] * capital_path['Kstock'][i-54] / Kstock2016)
A.append(A[56] * K_fa[i] / K_fa[56])
D.append(D[56] * K_fa[i] / K_fa[56])
L.append(D[i] + A[i])
R = np.zeros(68)
O = np.zeros(68)
for i in range(1, 68):
R[i] = L[i-1] * eta
O[i] = L[i] - L[i-1] + R[i]
i_a = [x / 100. for x in i_t]
i_l = [(i_t[i] + i_pr[i]) / 100. for i in range(len(i_t))]
int_income = [A[i] * i_a[i] for i in range(len(A))]
int_expense = np.zeros(68)
for i in range(1, 68):
for j in range(i+1):
int_expense[i] += O[j] * (1 - eta)**(i - j - 1) * i_l[j]
NID_gross = int_expense - int_income
NID = np.zeros(len(NID_gross))
NIP = NID_gross * adjfactor_int_corp
for i in range(len(NID)):
NID[i] = NID_gross[i] * adjfactor_int_corp
debt = np.asarray(L) * adjfactor_int_corp
NID_results = pd.DataFrame({'year': range(2014, 2028), 'nid': NID[54:68],
'nip': NIP[54:68], 'debt': debt[54:68]})
# for printing historical results:
# NID_results = pd.DataFrame({'year': range(1998,2014), 'nid': NID[38:54]})
return (NID_results)
def noncorpIntDeduction(capital_path, eta=0.4):
"""
Calculates the debt and interest paid/deducted,
baseline noncorporate businesses.
capital path: growth path of the noncorporate capital stock
eta: retirement rate of existing debt
"""
Kstock2016 = capital_path['Kstock'][2]
K_fa = debt_data_noncorp['Kfa'][:57].tolist()
L = debt_data_noncorp['L'][:57].tolist()
i_t = debt_data_noncorp['i_t'].tolist()
i_pr = debt_data_noncorp['i_pr'].tolist()
for i in range(57, 68):
K_fa.append(K_fa[56] * capital_path['Kstock'][i-54] / Kstock2016)
L.append(L[56] * K_fa[i] / K_fa[56])
R = np.zeros(68)
O = np.zeros(68)
for i in range(1, 68):
R[i] = L[i-1] * eta
O[i] = L[i] - L[i-1] + R[i]
i_l = [(i_t[i] + i_pr[i]) / 100. for i in range(len(i_t))]
int_expense = np.zeros(68)
for i in range(1, 68):
for j in range(i+1):
int_expense[i] += O[j] * (1 - eta)**(i - j - 1) * i_l[j]
int_total = int_expense * adjfactor_int_noncorp
debt = np.asarray(L) * adjfactor_int_noncorp
ID_results = pd.DataFrame({'year': range(2014, 2028),
'intpaid': int_total[54:68],
'debt': debt[54:68]})
# ID_results = pd.DataFrame({'year': range(1998,2014),
# 'intpaid': int_total[38:54]})
return ID_results