!pip install --upgrade quantecon import numpy as np import matplotlib.pyplot as plt from collections import namedtuple from quantecon import DLE %matplotlib inline Information = namedtuple('Information', ['a22', 'c2','ub','ud']) Technology = namedtuple('Technology', ['ϕ_c', 'ϕ_g', 'ϕ_i', 'γ', 'δ_k', 'θ_k']) Preferences = namedtuple('Preferences', ['β', 'l_λ', 'π_h', 'δ_h', 'θ_h']) k = 4 # Number of periods of schooling required to become an engineer β = np.array([[1 / 1.05]]) α_d = np.array([[0.1]]) α_s = 1 ε_1 = 1e-7 λ_1 = np.full((1, k), ε_1) # Use of ε_1 is trick to aquire detectability, see HS2013 p. 228 footnote 4 l_λ = np.hstack((α_d, λ_1)) π_h = np.array([[0]]) δ_n = np.array([[0.95]]) d1 = np.vstack((δ_n, np.zeros((k - 1, 1)))) d2 = np.hstack((d1, np.eye(k))) δ_h = np.vstack((d2, np.zeros((1, k + 1)))) θ_h = np.vstack((np.zeros((k, 1)), np.ones((1, 1)))) ψ_1 = 1 / α_s ϕ_c = np.array([[1], [0]]) ϕ_g = np.array([[0], [-1]]) ϕ_i = np.array([[-1], [ψ_1]]) γ = np.array([[0], [0]]) δ_k = np.array([[0]]) θ_k = np.array([[0]]) ρ_s = 0.8 ρ_d = 0.8 a22 = np.array([[1, 0, 0], [0, ρ_s, 0], [0, 0, ρ_d]]) c2 = np.array([[0, 0], [10, 0], [0, 10]]) ub = np.array([[30, 0, 1]]) ud = np.array([[10, 1, 0], [0, 0, 0]]) info1 = Information(a22, c2, ub, ud) tech1 = Technology(ϕ_c, ϕ_g, ϕ_i, γ, δ_k, θ_k) pref1 = Preferences(β, l_λ, π_h, δ_h, θ_h) econ1 = DLE(info1, tech1, pref1) α_d = np.array([[2]]) l_λ = np.hstack((α_d, λ_1)) pref2 = Preferences(β, l_λ, π_h, δ_h, θ_h) econ2 = DLE(info1, tech1, pref2) α_d = np.array([[0.1]]) k = 7 λ_1 = np.full((1, k), ε_1) l_λ = np.hstack((α_d, λ_1)) d1 = np.vstack((δ_n, np.zeros((k - 1, 1)))) d2 = np.hstack((d1, np.eye(k))) δ_h = np.vstack((d2, np.zeros((1, k+1)))) θ_h = np.vstack((np.zeros((k, 1)), np.ones((1, 1)))) Pref3 = Preferences(β, l_λ, π_h, δ_h, θ_h) econ3 = DLE(info1, tech1, Pref3) k = 10 λ_1 = np.full((1, k), ε_1) l_λ = np.hstack((α_d, λ_1)) d1 = np.vstack((δ_n, np.zeros((k - 1, 1)))) d2 = np.hstack((d1, np.eye(k))) δ_h = np.vstack((d2, np.zeros((1, k + 1)))) θ_h = np.vstack((np.zeros((k, 1)), np.ones((1, 1)))) pref4 = Preferences(β, l_λ, π_h, δ_h, θ_h) econ4 = DLE(info1, tech1, pref4) shock_demand = np.array([[0], [1]]) econ1.irf(ts_length=25, shock=shock_demand) econ2.irf(ts_length=25, shock=shock_demand) econ3.irf(ts_length=25, shock=shock_demand) econ4.irf(ts_length=25, shock=shock_demand) fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4)) ax1.plot(econ1.c_irf,label='$\\alpha_d = 0.1$') ax1.plot(econ2.c_irf,label='$\\alpha_d = 2$') ax1.legend() ax1.set_title('Response of $n_t$ to a demand shock') ax2.plot(econ1.h_irf[:, 0], label='$\\alpha_d = 0.1$') ax2.plot(econ2.h_irf[:, 0], label='$\\alpha_d = 24$') ax2.legend() ax2.set_title('Response of $N_t$ to a demand shock') plt.show() fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4)) ax1.plot(econ1.c_irf, label='$k=4$') ax1.plot(econ3.c_irf, label='$k=7$') ax1.plot(econ4.c_irf, label='$k=10$') ax1.legend() ax1.set_title('Response of $n_t$ to a demand shock') ax2.plot(econ1.h_irf[:,0], label='$k=4$') ax2.plot(econ3.h_irf[:,0], label='$k=7$') ax2.plot(econ4.h_irf[:,0], label='$k=10$') ax2.legend() ax2.set_title('Response of $N_t$ to a demand shock') plt.show()