Exemple #1
0
#%%

from dolark.equilibrium import find_steady_state
eqs = find_steady_state(hmodel, dr0=dr, verbose='full', return_fun=False)

#%%

m0 = hmodel.calibration['exogenous']
y0 = hmodel.calibration['aggregate']
p0 = hmodel.calibration['parameters']

(m0, y0, hmodel.projection(m0, y0, p0))

# %%

from matplotlib import pyplot as plt
from dolo import tabulate

tab = tabulate(hmodel.agent, dr, "m")

plt.plot(tab["m"], tab["m"])
plt.plot(tab["m"], tab["c"])
plt.grid(True)

# %%

from dolark.perturbation import perturb
sol = perturb(hmodel, eqs)
# %%
Exemple #2
0
print(hmodel3.features)
# print(hmodel3.distribution)

# # Identical Agents: autocorrelated procesess

# +
# the agent's problem has autocorrelated exogenous process
# it is discretized as an markov chain
# -

eq = find_steady_state(hmodel1)
eq

# a bit out of topic here:
from dolark.perturbation import perturb
peq = perturb(hmodel1, eq)
peq

# +
# cf reiter_example to see what to do with eq and peq
# -

# # Many Agents: autocorrelated procesess

# distribution of agent's parameters
hmodel2.distribution

from dolark.shocks import discretize_idiosyncratic_shocks
dist = discretize_idiosyncratic_shocks(hmodel2.distribution,
                                       options=[{
                                           'N': 6
            color=alt.condition(single, 'i_m:N',
                                alt.value('lightgray'))).add_selection(single)

# %%

# Resulting object can be saved to a file. (try to open this file in jupyterlab)
open('distrib.json', 'tw').write(spec.to_json())

# %%

# %%
import xarray

# %%
# now we compute the perturbation
peq = perturb(aggmodel, eq)

# %%
# and we simulate given initial value of aggregate shock
sim = peq.response([0.1])

# %%
plt.subplot(121)
for t, (m, μ, x, y) in enumerate(sim):
    plt.plot(μ.sum(axis=0), color='red', alpha=0.01)
plt.xlabel('a')
plt.ylabel('density')
plt.grid()
plt.subplot(122)
plt.plot([e[3][0] for e in sim])
plt.xlabel("t")
Exemple #4
0
            color=alt.condition(single, "i_m:N",
                                alt.value("lightgray"))).add_selection(single)

# %%

# Resulting object can be saved to a file. (try to open this file in jupyterlab)
open("distrib.json", "tw").write(spec.to_json())

# %%

# %%
import xarray

# %%
# now we compute the perturbation
peq = perturb(aggmodel, eq)

# %%
# and we simulate given initial value of aggregate shock
sim = peq.response([0.1])

# %%
plt.subplot(121)
for t, (m, μ, x, y) in enumerate(sim):
    plt.plot(μ.sum(axis=0), color="red", alpha=0.01)
plt.xlabel("a")
plt.ylabel("density")
plt.grid()
plt.subplot(122)
plt.plot([e[3][0] for e in sim])
plt.xlabel("t")