In [112]:
from dolo import *
In [113]:
model = yaml_import("../models/consumption_savings.yaml")
In [114]:
dr = time_iteration(model)
One can also try the faster version
In [115]:
# Shocks are discretized as a markov chain by default:
dp = model.exogenous.discretize()
sim_shock = dp.simulate(10, 100, i0=1)
for i in range(10):
plt.plot(sim_shock[:,i,0], color='red', alpha=0.5)
In [116]:
sim = simulate(model, dr, i0=1, N=100)
In [117]:
plt.subplot(121)
for i in range(10):
plt.plot(sim.sel(N=i,V='c'), color='red', alpha=0.5)
plt.ylabel("$c_t$")
plt.xlabel("$t$")
plt.subplot(122)
for i in range(10):
plt.plot(sim.sel(N=i,V='w'), color='red', alpha=0.5)
plt.xlabel("$t$")
plt.ylabel("$w_t$")
plt.tight_layout()
In [118]:
sim_long = simulate(model, dr, i0=1, N=1000, T=200)
In [119]:
import seaborn
seaborn.distplot(sim_long.sel(T=199, V='w'))
plt.xlabel("$w$")
Out[119]:
In [120]:
tab = tabulate(model, dr,'w')
In [121]:
from matplotlib import pyplot as plt
In [122]:
stable_wealth = model.eval_formula('1/r+(1-1/r)*w(0)', tab)
plt.plot(tab['w'], tab['w'],color='black', linestyle='--')
plt.plot(tab['w'], stable_wealth,color='black', linestyle='--')
plt.plot(tab['w'], tab['c'])
plt.xlabel("w_t")
plt.ylabel("c_t")
plt.grid()
In [ ]:
In [ ]: