In [13]:
include("src/utilities.jl")
include("src/bansal_yaron_discretized.jl")
Out[13]:
Default parameter values:
In [14]:
ez_by = EpsteinZinBY()
sv_by = StochasticVolatilityBY()
Out[14]:
In [15]:
K = compute_K_bansal_yaron(ez_by, sv_by);
In [16]:
compute_spec_rad(K)
Out[16]:
In [17]:
using PyPlot
plt = PyPlot
Out[17]:
In [18]:
J = 20 # grid size
R = Array{Float64}(J, J);
In [19]:
x_vals = linspace(1.25, 2.25, J) # ψ
y_vals = linspace(0.0005, 0.01, J) # μ
Out[19]:
In [20]:
for (i, x) in enumerate(x_vals)
for (j, y) in enumerate(y_vals)
ez = EpsteinZinBY(ψ=x)
@assert ez.θ < 0 "Detected non-negative theta value"
K = compute_K_bansal_yaron(ez, sv_by, μ=y)
R[i, j] = compute_spec_rad(K)
end
end
In [21]:
fig, ax = plt.subplots(figsize=(10, 5.7))
#lvs = [0.0, 0.8, 1.0, 1.4, 1.8, 2.2, 4.4]
#cls = [cm.jet(i) for i in np.linspace(0.4, 1, len(lvs))]
cs1 = ax[:contourf](x_vals,
y_vals,
R',
alpha=0.6)
#levels=lvs,
ctr1 = ax[:contour](x_vals,
y_vals,
R',
levels=[1.0])
plt.clabel(ctr1, inline=1, fontsize=13)
plt.colorbar(cs1, ax=ax)
ax[:set_title]("Spectral radius")
ax[:set_xlabel]("ψ", fontsize=16)
ax[:set_ylabel]("μ", fontsize=16)
ax[:annotate]("Bansal-Yaron",
xy=(1.5 + 0.024, 0.0015 - 0.0001),
xycoords="data",
xytext=(5, 40),
textcoords="offset points",
fontsize=12,
arrowprops=Dict("arrowstyle" => "->"))
ax[:plot]([1.5], [0.0015], "ko", alpha=0.6)
plt.savefig("by.pdf")
plt.show()
In [22]:
ez_bky = EpsteinZinBKY()
sv_bky = StochasticVolatilityBKY()
Out[22]:
In [23]:
for (i, x) in enumerate(x_vals)
for (j, y) in enumerate(y_vals)
ez = EpsteinZinBY(ψ=x)
@assert ez.θ < 0 "Detected non-negative theta value"
K = compute_K_bansal_yaron(ez, sv_bky, μ=y)
R[i, j] = compute_spec_rad(K)
end
end
In [24]:
fig, ax = plt.subplots(figsize=(10, 5.7))
#lvs = [0.0, 0.8, 1.0, 1.4, 1.8, 2.2, 4.4]
#cls = [cm.jet(i) for i in np.linspace(0.4, 1, len(lvs))]
cs1 = ax[:contourf](x_vals,
y_vals,
R',
alpha=0.6)
#levels=lvs,
ctr1 = ax[:contour](x_vals,
y_vals,
R',
levels=[1.0])
plt.clabel(ctr1, inline=1, fontsize=13)
plt.colorbar(cs1, ax=ax)
ax[:set_title]("Spectral radius")
ax[:set_xlabel]("ψ", fontsize=16)
ax[:set_ylabel]("μ", fontsize=16)
ax[:annotate]("Bansal-Kiku-Yaron",
xy=(1.5 + 0.024, 0.0015 - 0.0001),
xycoords="data",
xytext=(5, 40),
textcoords="offset points",
fontsize=12,
arrowprops=Dict("arrowstyle" => "->"))
ax[:plot]([1.5], [0.0015], "ko", alpha=0.6)
plt.savefig("bky.pdf")
plt.show()
In [ ]: