!pip install --upgrade quantecon import numpy as np import matplotlib.pyplot as plt from quantecon import LQ from quantecon import DLE %matplotlib inline gam = 0 γ = np.array([[gam], [0]]) ϕ_c = np.array([[1], [0]]) ϕ_g = np.array([[0], [1]]) ϕ_1 = 1e-4 ϕ_i = np.array([[0], [-ϕ_1]]) δ_k = np.array([[.95]]) θ_k = np.array([[1]]) β = np.array([[1 / 1.05]]) ud = np.array([[5, 1, 0], [0, 0, 0]]) a22 = np.array([[1, 0, 0], [0, 0.8, 0], [0, 0, 0.5]]) c2 = np.array([[0, 1, 0], [0, 0, 1]]).T l_λ = np.array([[0]]) π_h = np.array([[1]]) δ_h = np.array([[.9]]) θ_h = np.array([[1]]) - δ_h ub = np.array([[30, 0, 0]]) x0 = np.array([[5, 150, 1, 0, 0]]).T info1 = (a22, c2, ub, ud) tech1 = (ϕ_c, ϕ_g, ϕ_i, γ, δ_k, θ_k) pref1 = (β, l_λ, π_h, δ_h, θ_h) econ1 = DLE(info1, tech1, pref1) econ1.compute_sequence(x0, ts_length=100, Pay=np.array([econ1.Sd[0, :]])) ### Fig 7.12.1 from p.147 of HS2013 plt.plot(econ1.Pay_Price, label='Price of Tree') plt.legend() plt.show() ### Left panel of Fig 7.12.2 from p.148 of HS2013 plt.plot(econ1.Pay_Gross, label='Tree') plt.plot(econ1.R1_Gross, label='Risk-Free') plt.legend() plt.show() np.corrcoef(econ1.Pay_Gross[1:, 0], econ1.R1_Gross[1:, 0]) ### Right panel of Fig 7.12.2 from p.148 of HS2013 plt.plot(econ1.R1_Net, label='One-Period') plt.plot(econ1.R5_Net, label='Five-Period') plt.legend() plt.show() a22_2 = np.array([[1, 0, 0], [0, 0.4, 0], [0, 0, 0.5]]) info2 = (a22_2, c2, ub, ud) econ2 = DLE(info2, tech1, pref1) econ2.compute_sequence(x0, ts_length=100, Pay=np.array([econ2.Sd[0, :]])) ### Left panel of Fig 7.12.3 from p.148 of HS2013 plt.plot(econ2.Pay_Gross, label='Tree') plt.plot(econ2.R1_Gross, label='Risk-Free') plt.legend() plt.show() np.corrcoef(econ2.Pay_Gross[1:, 0], econ2.R1_Gross[1:, 0]) ### Right panel of Fig 7.12.3 from p.148 of HS2013 plt.plot(econ2.R1_Net, label='One-Period') plt.plot(econ2.R5_Net, label='Five-Period') plt.legend() plt.show()