Skip to content

Commit 75302e9

Browse files
committed
WIp
1 parent 7d827e8 commit 75302e9

File tree

7 files changed

+990
-31
lines changed

7 files changed

+990
-31
lines changed

ICAI/partial.dyno

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
χ <- 0.05
2+
y_bar <- 0.1
3+
inc_share <- 0.25
4+
ζ_bar <- (inc_share-y_bar)/(1-y_bar)
5+
r_w <- 0.04
6+
r <- r_w
7+
β <- 1-r
8+
δ_β <- 0.005
9+
δ_b <- 0.005
10+
ρ_a <- 0.99
11+
ρ_y <- 0.99
12+
ρ_ζ <- 0.99
13+
β_τ <- β - δ_β
14+
β_b <- β - δ_b
15+
16+
σ <- 2.0
17+
η <- 2.5
18+
η_b <- 2.5
19+
ω <- 0.5
20+
hand_to_mouth <- 0.0
21+
22+
y[~] <- y_bar
23+
ζ[~] <- ζ_bar
24+
25+
# Steady-states
26+
a[~] <- 1
27+
d[~] <- 0
28+
d_b[~] <- 0
29+
b_b[~] <- 0
30+
b_τ[~] <- 0
31+
p[~] <- β/(1-β)*r
32+
q[~] <- p[~]*a[~]*y[~]/r
33+
n[~] <- 1 # total number of shares
34+
x[~] <- 1/χ # number of shares per top earner
35+
36+
W_τ[~] <- p[~]*(b_τ[~]) + q[~]*x[~]
37+
W_b[~] <- 1.0 + p[~]*(b_b[~])*0 # adding/removing the last term affects the result !
38+
c_b[~] <- a[~]*(1-y[~])*(1-ζ[~])/(1-χ)
39+
c_τ[~] <- a[~]*(1-y[~])*ζ[~]*x[~] + b_τ[~]*r + (a[~]*y[~])*x[~]
40+
y_b[~] <- a[~]*(1-y[~])*(1-ζ[~])/(1-χ) # labor income for bottom-earners
41+
y_τ[~] <- a[~]*(1-y[~])*ζ[~]*x[~] + (a[~]*y[~])*x[~] # top earners income (labor plus dividends)
42+
c_b[~] <- b_b[~]*r + y_b[~]
43+
c_τ[~] <- b_τ[~]*r + y_τ[~]
44+
45+
46+
φ_τ <- (1-β_τ/p[~])*c_τ[~]^(-σ)/(W_τ[~])^(-η)
47+
φ_b <- (1-β_b/p[~])*c_b[~]^(-σ)/(W_b[~])^(-η_b)
48+
49+
50+
51+
# exogenous processes
52+
y[t] = y[~] + ρ_y*(y[t-1]-y[~])
53+
ζ[t] = ζ[~] + ρ_ζ*(ζ[t-1]-ζ[~])
54+
x[t] = x[~]
55+
a[t] = 1 + ρ_a*(a[t-1]-1)
56+
57+
d[t] = d[t-1] + e_d[t] # income shock for top earners
58+
d_b[t] = d_b[t-1] + e_d_b[t] # income shock for bottom earners
59+
60+
y_b[t] = a[t]*(1-y[t])*(1-ζ[t])/(1-χ) # labor income for bottom-earners
61+
y_τ[t] = a[t]*(1-y[t])*ζ[t]*x[t] + (a[t]*y[t])*x[t] # top earners income (labor plus dividends)
62+
63+
c_b[t] = d_b[t]/(1-χ) + b_b[t-1]*r - (b_b[t]-b_b[t-1])*p[t] + y_b[t]
64+
c_τ[t] = d[t] + b_τ[t-1]*r - (b_τ[t]-b_τ[t-1])*p[t] + y_τ[t]
65+
66+
W_τ[t] = q[t]*x[t] + p[t]*(b_τ[t])
67+
W_b[t] = 1 + p[t]*(b_b[t])
68+
69+
p[t] = β_b*(c_b[t+1]/c_b[t])^(-σ)*(r+p[t+1]) + φ_b*(W_b[t])^(-η_b)/(c_b[t])^(-σ)*p[t]
70+
p[t] = β_τ*(c_τ[t+1]/c_τ[t])^(-σ)*(r+p[t+1]) + φ_τ*(W_τ[t])^(-η )/(c_τ[t])^(-σ)*p[t]
71+
72+
r_w + p[t] = 1
73+
74+
q[t] = p[~]*a[~]*y[~]/r
75+
76+
# e_d[t] <- N(0, 0.1)
77+
e_d_b[t] <- N(0, 0.1)

ICAI/partial2.dyno

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
χ <- 0.05
2+
y_bar <- 0.1
3+
inc_share <- 0.25
4+
ζ_bar <- (inc_share-y_bar)/(1-y_bar)
5+
6+
r_w <- 0.04
7+
r <- r_w
8+
β <- 1-r
9+
δ_β <- 0.005
10+
δ_b <- 0.005
11+
ρ_a <- 0.99
12+
ρ_y <- 0.99
13+
ρ_ζ <- 0.99
14+
β_τ <- β - δ_β
15+
β_b <- β - δ_b
16+
17+
σ <- 2.0
18+
η <- 2.5
19+
η_b <- 2.5
20+
ω <- 0.5
21+
hand_to_mouth <- 0.0
22+
23+
y[~] <- y_bar
24+
ζ[~] <- ζ_bar
25+
26+
# Steady-states
27+
a[~] <- 1
28+
d[~] <- 0
29+
d_b[~] <- 0
30+
b_b[~] <- 0
31+
b_τ[~] <- 0
32+
p[~] <- β/(1-β)*r
33+
q[~] <- p[~]*a[~]*y[~]/r
34+
n[~] <- 1 # total number of shares
35+
x[~] <- 1/χ # number of shares per top earner
36+
W_τ[~] <- p[~]*(b_τ[~]) + q[~]*x[~]
37+
W_b[~] <- 1.0 + p[~]*(b_b[~])*0 # adding/removing the last term affects the result !
38+
c_b[~] <- a[~]*(1-y[~])*(1-ζ[~])/(1-χ)
39+
c_τ[~] <- a[~]*(1-y[~])*ζ[~]*x[~] + b_τ[~]*r + (a[~]*y[~])*x[~]
40+
y_b[~] <- a[~]*(1-y[~])*(1-ζ[~])/(1-χ) # labor income for bottom-earners
41+
y_τ[~] <- a[~]*(1-y[~])*ζ[~]*x[~] + (a[~]*y[~])*x[~] # top earners income (labor plus dividends)
42+
c_b[~] <- b_b[~]*r + y_b[~]
43+
c_τ[~] <- b_τ[~]*r + y_τ[~]
44+
45+
46+
φ_τ <- (1-β_τ/p[~])*c_τ[~]^(-σ)/(W_τ[~])^(-η)
47+
φ_b <- (1-β_b/p[~])*c_b[~]^(-σ)/(W_b[~])^(-η_b)
48+
49+
50+
51+
# exogenous processes
52+
y[t] = y[~] + ρ_y*(y[t-1]-y[~])
53+
ζ[t] = ζ[~] + ρ_ζ*(ζ[t-1]-ζ[~])
54+
x[t] = x[~]
55+
a[t] = 1 + ρ_a*(a[t-1]-1)
56+
57+
d[t] = d[t-1] + e_d[t] # income shock for top earners
58+
d_b[t] = d_b[t-1] + e_d_b[t] # income shock for bottom earners
59+
60+
y_b[t] = a[t]*(1-y[t])*(1-ζ[t])/(1-χ) # labor income for bottom-earners
61+
y_τ[t] = a[t]*(1-y[t])*ζ[t]*x[t] + (a[t]*y[t])*x[t] # top earners income (labor plus dividends)
62+
63+
c_b[t] = d_b[t]/(1-χ) + b_b[t-1]*r - (b_b[t]-b_b[t-1])*p[t] + y_b[t]
64+
c_τ[t] = d[t] + b_τ[t-1]*r - (b_τ[t]-b_τ[t-1])*p[t] + y_τ[t]
65+
66+
W_τ[t] = q[t]*x[t] + p[t]*(b_τ[t])
67+
W_b[t] = 1 + p[t]*(b_b[t])
68+
69+
p[t] = β_b*(c_b[t+1]/c_b[t])^(-σ)*(r+p[t+1]) + φ_b*(W_b[t])^(-η_b)/(c_b[t])^(-σ)*p[t]
70+
p[t] = β_τ*(c_τ[t+1]/c_τ[t])^(-σ)*(r+p[t+1]) + φ_τ*(W_τ[t])^(-η )/(c_τ[t])^(-σ)*p[t]
71+
72+
r_w + p[t] = 1
73+
74+
q[t] = p[~]*a[~]*y[~]/r
75+
76+
e_d[t] <- N(0, 0.1)
77+
e_d_b[t] <- N(0, 0.1)

ICAI/solve_icai.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import dyno
2+
from matplotlib import pyplot as plt
3+
from dyno.symbolic_model import SymbolicModel
4+
5+
model = SymbolicModel("partial.dyno")
6+
7+
dr = model.solve()
8+
9+
10+
######
11+
12+
import dyno
13+
14+
from matplotlib import pyplot as plt
15+
16+
from dyno.symbolic_model import SymbolicModel
17+
18+
19+
model = SymbolicModel("partial.dyno")
20+
21+
dr = model.solve()
22+
23+
irfs = dr.irfs()
24+
25+
# sim = dyno.simulate(dr)
26+
27+
plt.figure()
28+
29+
plt.subplot(121)
30+
plt.plot(irfs['e_d'].index, irfs['e_d']['d']*0, color='black', linestyle='--')
31+
plt.plot(irfs['e_d'].index, irfs['e_d']['d'],label='Income')
32+
plt.xlim(0, 10)
33+
plt.subplot(122)
34+
plt.plot(irfs['e_d'].index, irfs['e_d']['b_τ'],label='Debt')
35+
plt.xlim(0, 10)
36+
# plt.ylim(0, 0.02)
37+
38+
39+
40+
plt.plot(irfs['e_d'].index, irfs['e_d']['d'],label='Income')
41+
plt.plot(irfs['e_d'].index, irfs['e_d']['b_τ'],label='Debt')
42+
plt.xlim(0, 10)
43+
# plt.ylim(0, 0.02)
44+
45+
46+
plt.plot(irfs['e_d'].index, irfs['e_d']['b_τ']/irfs['e_d']['d'],label='MPS')
47+
plt.xlim(0,10)

dev_dynare.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import os
2-
3-
42
import time
53

64
dir_path = os.path.dirname(os.path.realpath(__file__))
@@ -13,9 +11,6 @@
1311

1412
t1 = time.time()
1513
model = SymbolicModel(f_o)
16-
17-
18-
1914
t2 = time.time()
2015
dr1 = model.solve()
2116
print("Model parsing time: ", t2 - t1)

0 commit comments

Comments
 (0)