bins = [] for w, eq in eq2: bins.append(w * sum(s.ravel() * eq.μ.sum(axis=0))) from dolark.shocks import discretize_idiosyncratic_shocks dist = discretize_idiosyncratic_shocks(hmodel2.distribution) plt.plot([e[1]["β"] for e in dist], bins, "-o") plt.xlabel("β") # %% # Steady-state equilibrium: graphic resolution from tqdm import tqdm # %% # Aiyagari dr0 = hmodel1.get_starting_rule() m0 = hmodel1.calibration["exogenous"] kvec = np.linspace(30, 50, 20) hmodel1.model.set_calibration({}) eqs = [ equilibrium(hmodel1, m0, np.array([k]), dr0=dr0, return_equilibrium=False) for k in tqdm(kvec) ] eqs = [e[0] for e in eqs] # %% from matplotlib import pyplot as plt plt.plot(kvec, kvec - eqs, color="black") # %%
plt.plot([e[1]['β'] for e in dist], bins, '-o') plt.xlabel('β') y0 = eqss[0][1].y #%% # by hand from dolark.shocks import discretize_idiosyncratic_shocks dist = discretize_idiosyncratic_shocks(hmodel2.distribution) from tqdm import tqdm dr0 = hmodel2.get_starting_rule() m0 = hmodel2.calibration['exogenous'] kvec = np.linspace(20, 40, 20) eqs = [] for w, kwargs in tqdm(dist): hmodel2.model.set_calibration(**kwargs) res = [ equilibrium(hmodel2, m0, np.array([k]), dr0=dr0, return_equilibrium=False) for k in kvec ] eqs.append(res)