!pip install --upgrade quantecon import numpy as np import matplotlib.pyplot as plt %matplotlib inline from quantecon import LQ, DLE # Parameter Matrices γ_1 = 0.1 ϕ_1 = 1e-5 ϕ_c, ϕ_g, ϕ_i, γ, δ_k, θ_k = (np.array([[1], [0]]), np.array([[0], [1]]), np.array([[1], [-ϕ_1]]), np.array([[γ_1], [0]]), np.array([[.95]]), np.array([[1]])) β, l_λ, π_h, δ_h, θ_h = (np.array([[1 / 1.05]]), np.array([[0]]), np.array([[1]]), np.array([[.9]]), np.array([[1]]) - np.array([[.9]])) a22, c2, ub, ud = (np.array([[1, 0, 0], [0, 0.8, 0], [0, 0, 0.5]]), np.array([[0, 0], [1, 0], [0, 1]]), np.array([[30, 0, 0]]), np.array([[5, 1, 0], [0, 0, 0]])) # Initial condition x0 = np.array([[5], [150], [1], [0], [0]]) 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=300) # This is the right panel of Fig 5.7.1 from p.105 of HS2013 plt.plot(econ1.c[0], label='Cons.') plt.plot(econ1.i[0], label='Inv.') plt.legend() plt.show() econ1.endo, econ1.exo econ1.endo[1] econ1.compute_steadystate() np.set_printoptions(precision=3, suppress=True) print(econ1.css, econ1.iss, econ1.kss) γ2 = 0.15 γ22 = np.array([[γ2], [0]]) ϕ_12 = 1 ϕ_i2 = np.array([[1], [-ϕ_12]]) tech2 = (ϕ_c, ϕ_g, ϕ_i2, γ22, δ_k, θ_k) x02 = np.array([[5], [20], [1], [0], [0]]) econ2 = DLE(info1, tech2, pref1) econ2.compute_sequence(x02, ts_length=300) plt.plot(econ2.c[0], label='Cons.') plt.plot(econ2.i[0], label='Inv.') plt.legend() plt.show() econ2.compute_steadystate() print(econ2.css, econ2.iss, econ2.kss) econ2.endo, econ2.exo l_λ2 = np.array([[-1]]) pref2 = (β, l_λ2, π_h, δ_h, θ_h) econ3 = DLE(info1, tech1, pref2) econ3.compute_sequence(x0, ts_length=300) # This is the right panel of Fig 5.10.1 from p.110 of HS2013 plt.plot(econ3.c[0], label='Cons.') plt.plot(econ3.i[0], label='Inv.') plt.legend() plt.show() econ3.endo, econ3.exo l_λ3 = np.array([[-0.7]]) pref3 = (β, l_λ3, π_h, δ_h, θ_h) econ4 = DLE(info1, tech1, pref3) econ4.compute_sequence(x0, ts_length=300) plt.plot(econ4.c[0], label='Cons.') plt.plot(econ4.i[0], label='Inv.') plt.legend() plt.show() econ4.endo, econ4.exo β_2 = np.array([[0.94]]) pref4 = (β_2, l_λ, π_h, δ_h, θ_h) econ5 = DLE(info1, tech1, pref4) econ5.compute_sequence(x0, ts_length=300) plt.plot(econ5.c[0], label='Cons.') plt.plot(econ5.i[0], label='Inv.') plt.legend() plt.show() econ5.endo, econ5.exo