In [31]:
from numpy import *
from matplotlib import pyplot as plt
In [32]:
from dolo import *
In [37]:
filename =  '../models/rbc_taxes.yaml'
In [38]:
model = yaml_import(filename)

The model defined in rbc_taxes.yaml is the rbc model, with an agregate tax g that is proportional to income.

In [39]:
model.calibration
Out[39]:
{'states': array([1.        , 9.35497829, 0.        ]),
 'controls': array([0.23387446, 0.33      ]),
 'exogenous': array([0.]),
 'parameters': array([0.99      , 1.        , 1.        , 8.04277482, 0.025     ,
        0.33      , 0.8       , 1.        ]),
 'auxiliaries': array([0.03510101, 2.02026956, 0.99505814, 0.76118369])}
In [40]:
model.residuals()
Out[40]:
{'transition': array([0., 0., 0.]),
 'arbitrage': array([ 0.0000000e+00, -8.8817842e-16])}

We want to compute the adjustment of the economy when this tax, goes back progressively from 10% to 0%, over 10 periods.

In [41]:
exo_g = linspace(0.1,0,10) # this is a vector of size 10
exo_g = atleast_2d(exo_g).T # the solver expects a 1x10 vector
print(exo_g.shape)
(10, 1)
In [42]:
exo_g
Out[42]:
array([[0.1       ],
       [0.08888889],
       [0.07777778],
       [0.06666667],
       [0.05555556],
       [0.04444444],
       [0.03333333],
       [0.02222222],
       [0.01111111],
       [0.        ]])
In [44]:
# Let's solve for the optimal adjustment by assuming that the
# economy returns to steady-state after T=50 periods.
from dolo.algos.perfect_foresight import deterministic_solve
sim = deterministic_solve(model, shocks=exo_g, T=50)
display(sim) # it returns a timeseries object
	> 1 | 0.03282645604591261 | 0
	> 2 | 0.0013560969381939403 | 0
	> 3 | 2.8228642349192867e-06 | 0
	> 4 | 1.2459810960763207e-11 | 0
> System was solved after iteration 4. Residual=1.2459810960763207e-11
z k g i n rk w y c e_g
0 1.0 9.917135 8.888889e-02 0.247928 0.349830 0.035101 2.020270 1.054853 0.718036 0.088889
1 1.0 9.917135 7.777778e-02 0.163656 0.330581 0.033795 2.058356 1.015603 0.774170 0.077778
2 1.0 9.832863 6.666667e-02 0.171925 0.330163 0.033960 2.053426 1.011887 0.773295 0.066667
3 1.0 9.758967 5.555556e-02 0.180518 0.329789 0.034106 2.049085 1.008607 0.772533 0.055556
4 1.0 9.695510 4.444444e-02 0.189468 0.329469 0.034233 2.045334 1.005782 0.771870 0.044444
5 1.0 9.642591 3.333333e-02 0.198813 0.329208 0.034341 2.042177 1.003435 0.771289 0.033333
6 1.0 9.600339 2.222222e-02 0.208590 0.329014 0.034428 2.039616 1.001587 0.770775 0.022222
7 1.0 9.568920 1.111111e-02 0.218837 0.328895 0.034496 2.037655 1.000261 0.770313 0.011111
8 1.0 9.548534 -2.025942e-23 0.229594 0.328858 0.034542 2.036297 0.999481 0.769887 0.000000
9 1.0 9.539415 -3.669557e-23 0.229792 0.328910 0.034568 2.035548 0.999273 0.769481 0.000000
10 1.0 9.530722 1.292794e-23 0.229981 0.328960 0.034593 2.034834 0.999074 0.769094 0.000000
11 1.0 9.522434 1.117870e-23 0.230160 0.329008 0.034616 2.034152 0.998885 0.768725 0.000000
12 1.0 9.514533 -2.339772e-23 0.230330 0.329054 0.034639 2.033502 0.998703 0.768373 0.000000
13 1.0 9.507000 9.378626e-24 0.230493 0.329097 0.034660 2.032883 0.998531 0.768038 0.000000
14 1.0 9.499818 9.140817e-24 0.230647 0.329138 0.034681 2.032292 0.998365 0.767718 0.000000
15 1.0 9.492970 -1.608033e-23 0.230794 0.329178 0.034700 2.031728 0.998208 0.767414 0.000000
16 1.0 9.486440 -3.803112e-24 0.230934 0.329215 0.034719 2.031190 0.998057 0.767123 0.000000
17 1.0 9.480213 -1.001228e-23 0.231067 0.329251 0.034737 2.030678 0.997913 0.766847 0.000000
18 1.0 9.474274 1.200720e-23 0.231193 0.329285 0.034754 2.030189 0.997776 0.766583 0.000000
19 1.0 9.468610 1.296622e-24 0.231313 0.329317 0.034770 2.029722 0.997645 0.766332 0.000000
20 1.0 9.463208 -4.818116e-25 0.231427 0.329348 0.034785 2.029278 0.997519 0.766092 0.000000
21 1.0 9.458055 4.403594e-24 0.231535 0.329377 0.034800 2.028853 0.997399 0.765864 0.000000
22 1.0 9.453139 2.871224e-25 0.231638 0.329405 0.034814 2.028449 0.997284 0.765647 0.000000
23 1.0 9.448448 2.336608e-24 0.231735 0.329431 0.034828 2.028063 0.997175 0.765439 0.000000
24 1.0 9.443972 6.177175e-25 0.231828 0.329456 0.034841 2.027695 0.997070 0.765242 0.000000
25 1.0 9.439701 -3.972373e-24 0.231916 0.329480 0.034853 2.027343 0.996970 0.765054 0.000000
26 1.0 9.435624 4.396449e-24 0.231999 0.329503 0.034864 2.027008 0.996873 0.764875 0.000000
27 1.0 9.431732 -2.850504e-24 0.232077 0.329524 0.034876 2.026689 0.996781 0.764704 0.000000
28 1.0 9.428016 9.104032e-25 0.232152 0.329545 0.034886 2.026384 0.996693 0.764542 0.000000
29 1.0 9.424467 3.843539e-24 0.232222 0.329564 0.034896 2.026093 0.996609 0.764387 0.000000
30 1.0 9.421077 -1.857197e-24 0.232288 0.329583 0.034906 2.025815 0.996528 0.764239 0.000000
31 1.0 9.417838 -6.793508e-24 0.232351 0.329600 0.034915 2.025550 0.996450 0.764099 0.000000
32 1.0 9.414743 -5.467372e-24 0.232410 0.329617 0.034924 2.025297 0.996375 0.763965 0.000000
33 1.0 9.411784 2.024085e-24 0.232465 0.329632 0.034933 2.025055 0.996303 0.763838 0.000000
34 1.0 9.408955 1.058702e-24 0.232517 0.329647 0.034941 2.024824 0.996234 0.763717 0.000000
35 1.0 9.406248 -4.566884e-26 0.232566 0.329661 0.034949 2.024604 0.996168 0.763602 0.000000
36 1.0 9.403657 -4.728241e-24 0.232611 0.329674 0.034956 2.024393 0.996103 0.763492 0.000000
37 1.0 9.401177 -1.553064e-24 0.232654 0.329686 0.034963 2.024192 0.996042 0.763388 0.000000
38 1.0 9.398801 3.405749e-24 0.232693 0.329698 0.034970 2.024000 0.995982 0.763289 0.000000
39 1.0 9.396524 2.583974e-24 0.232730 0.329708 0.034976 2.023816 0.995924 0.763195 0.000000
40 1.0 9.394341 -3.028504e-24 0.232763 0.329718 0.034982 2.023641 0.995868 0.763105 0.000000
41 1.0 9.392246 -3.214116e-24 0.232794 0.329728 0.034988 2.023473 0.995814 0.763020 0.000000
42 1.0 9.390234 5.476225e-24 0.232822 0.329737 0.034994 2.023312 0.995761 0.762939 0.000000
43 1.0 9.388300 2.264607e-24 0.232848 0.329745 0.034999 2.023158 0.995710 0.762862 0.000000
44 1.0 9.386441 2.304774e-24 0.232871 0.329752 0.035005 2.023011 0.995660 0.762789 0.000000
45 1.0 9.384651 -8.279587e-25 0.232891 0.329759 0.035009 2.022869 0.995611 0.762720 0.000000
46 1.0 9.382926 3.825730e-24 0.232909 0.329765 0.035014 2.022734 0.995564 0.762655 0.000000
47 1.0 9.381261 -1.385624e-24 0.232924 0.329771 0.035019 2.022604 0.995517 0.762592 0.000000
48 1.0 9.379654 2.241539e-26 0.232937 0.329776 0.035023 2.022480 0.995471 0.762534 0.000000
49 1.0 9.378100 -4.563827e-25 0.232947 0.329781 0.035027 2.022360 0.995425 0.762478 0.000000
50 1.0 9.376595 -7.297820e-25 0.232947 0.329781 0.035031 2.022253 0.995373 0.762425 0.000000
In [45]:
model
Out[45]:
Model
name taxes
type dtcc
filename ../models/rbc_taxes.yaml
TypeEquationResidual
arbitrage$1 - \beta \; \left(\frac{c_{t}}{c_{t+1}}\right)^{\sigma} \; \left(1 - \delta + rk_{t+1}\right)$0.000
$\chi \; n_{t}^{\eta} \; c_{t}^{\sigma} - w_{t}$-0.000
transition$z_{t} = \left(1 - \rho\right) \; \overline{z} + \rho \; z_{t-1}$0.000
$k_{t} = \left(1 - \delta\right) \; k_{t-1} + i_{t-1}$0.000
$g_{t} = e_{g,t}$0.000
controls_lb$0$
$0$
controls_ub$inf$
$inf$
definitions$rk_{t} = \alpha \; z_{t} \; \left(\frac{n_{t}}{k_{t}}\right)^{1 - \alpha}$
$w_{t} = \left(1 - \alpha\right) \; z_{t} \; \left(\frac{k_{t}}{n_{t}}\right)^{\alpha}$
$y_{t} = z_{t} \; k_{t}^{\alpha} \; n_{t}^{1 - \alpha}$
$c_{t} = k_{t} \; rk_{t} + w_{t} \; n_{t} - i_{t} - g_{t}$
In [47]:
plt.plot(figsize=(10,10))
plt.subplot(221)
plt.plot(sim['k'], label='capital')
plt.plot(sim['y'], label='production')
plt.legend()
plt.subplot(222)
plt.plot(sim['g'], label='gvt. spending')
plt.plot(sim['c'], label='consumption')
plt.legend()
plt.subplot(223)
plt.plot(sim['n'], label='work')
plt.plot(sim['i'], label='investment')
plt.legend()
plt.subplot(224)
plt.plot(sim['w'], label='wages')
plt.legend()
Out[47]:
<matplotlib.legend.Legend at 0x7fa610d79d68>
In [ ]: