from dolark import HModel from dolo.algos import time_iteration, improved_time_iteration hmodel = HModel("bfs_2017_K.yaml") hmodel.features #%% #%% m0 = hmodel.calibration["exogenous"] s0 = hmodel.calibration["states"] y0 = hmodel.calibration["aggregate"] p0 = hmodel.calibration["parameters"] (m0, y0, hmodel.projection(m0, s0, y0, p0)) # %% dr = time_iteration(hmodel.agent, maxit=100, verbose=True) sol = improved_time_iteration(hmodel.agent, dr0=dr, verbose=True) dr = sol.dr # %% from dolo.algos.ergodic import ergodic_distribution μ = ergodic_distribution(hmodel.agent, dr)[1] from matplotlib import pyplot as plt
from dolo import time_iteration, improved_time_iteration dr = time_iteration(hmodel.agent) # # %time dr = improved_time_iteration(hmodel.model, dr0=dr, verbose=True, details=False) from dolo import tabulate tab = tabulate(hmodel.agent, dr, 'm') plt.plot(tab['m'], tab['c']) # ergodic distribution (premature) Π, μ = ergodic_distribution(hmodel.model, dr) df_μ = μ.to_dataframe('μ').reset_index() ch = alt.Chart(tab) g1 = ch.mark_line(color='black',strokeDash=[1,1]).encode(x='m', y='m') + \ ch.mark_line().encode(x='m', y='c') g2 = alt.Chart(df_μ).mark_line().encode(x='m:Q', y='mu:Q') g2 # There seem to be something wrong with the calibration at the aggregate level # here are the value of i.r. and w calibrated at the agent's level hmodel.agent.calibration['r', 'w'] # here are the values projected from market equilibrium, given default level of capital m0, y0, p = hmodel.calibration['exogenous', 'aggregate', 'parameters'] hmodel.projection(m0, y0, p) # values for r, w, ω (not the same at all)