{
"cells": [
{
"cell_type": "markdown",
"id": "269d8713",
"metadata": {},
"source": [
"\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"id": "f16a2283",
"metadata": {},
"source": [
"# Shock Non Invertibility"
]
},
{
"cell_type": "markdown",
"id": "93e37fb6",
"metadata": {},
"source": [
"## Overview\n",
"\n",
"This is another member of a suite of lectures that use the quantecon DLE class to instantiate models within the\n",
"[[Hansen and Sargent, 2013](https://python-advanced.quantecon.org/zreferences.html#id72)] class of models described in [Recursive Models of Dynamic Linear Economies](https://python-advanced.quantecon.org/hs_recursive_models.html).\n",
"\n",
"In addition to what’s in Anaconda, this lecture uses the quantecon library."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "726f3fbc",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"!pip install --upgrade quantecon"
]
},
{
"cell_type": "markdown",
"id": "f687b075",
"metadata": {},
"source": [
"We’ll make these imports:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eb45b3a1",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"import numpy as np\n",
"import quantecon as qe\n",
"import matplotlib.pyplot as plt\n",
"from quantecon import DLE\n",
"from math import sqrt"
]
},
{
"cell_type": "markdown",
"id": "f602350c",
"metadata": {},
"source": [
"This lecture describes an early contribution to what is now often called\n",
"a **news and noise** issue.\n",
"\n",
"In particular, it analyzes a **shock-invertibility** issue that is\n",
"endemic within a class of permanent income models.\n",
"\n",
"Technically, the invertibility problem indicates a situation in which\n",
"histories of the shocks in an econometrician’s autoregressive or Wold\n",
"moving average representation span a smaller information space than do\n",
"the shocks that are seen by the agents inside the econometrician’s model.\n",
"\n",
"An econometrician who is unaware of the\n",
"problem would misinterpret shocks and likely responses to them.\n",
"\n",
"A shock-invertibility that is technically close to the one studied here is discussed by\n",
"Eric Leeper, Todd Walker, and Susan Yang [[Leeper *et al.*, 2013](https://python-advanced.quantecon.org/zreferences.html#id34)] in their analysis of **fiscal foresight**.\n",
"\n",
"A distinct shock-invertibility issue is present in the special LQ consumption smoothing model\n",
"in this quantecon lecture [Information and Consumption Smoothing](https://python-advanced.quantecon.org/cons_news.html)."
]
},
{
"cell_type": "markdown",
"id": "88f78ace",
"metadata": {},
"source": [
"## Model\n",
"\n",
"We consider the following modification of Robert Hall’s (1978) model [[Hall, 1978](https://python-advanced.quantecon.org/zreferences.html#id153)] in which the endowment process is the sum of two orthogonal autoregressive processes:\n",
"\n",
"**Preferences**\n",
"\n",
"$$\n",
"-\\frac{1}{2}\\mathbb{E}\\sum_{t=0}^\\infty \\beta^t[(c_t - b_t)^2 + l_t^2]|J_0\n",
"$$\n",
"\n",
"$$\n",
"s_t = c_t\n",
"$$\n",
"\n",
"$$\n",
"b_t = U_bz_t\n",
"$$\n",
"\n",
"**Technology**\n",
"\n",
"$$\n",
"c_t + i_t = \\gamma k_{t-1} + d_t\n",
"$$\n",
"\n",
"$$\n",
"k_t = \\delta_k k_{t-1} + i_t\n",
"$$\n",
"\n",
"$$\n",
"g_t = \\phi_1 i_t \\, , \\phi_1 > 0\n",
"$$\n",
"\n",
"$$\n",
"g_t \\cdot g_t = l_t^2\n",
"$$\n",
"\n",
"**Information**\n",
"\n",
"$$\n",
"z_{t+1} =\n",
"\\left[ {\\begin{array}{cccccc}\n",
" 1 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0.9 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 1 & 0\n",
" \\end{array} }\n",
" \\right]\n",
" z_t +\n",
" \\left[ {\\begin{array}{cc}\n",
" 0 & 0 \\\\ 1 & 0 \\\\ 0 & 4 \\\\ 0 & 0 \\\\ 0 & 0 \\\\ 0 & 0\n",
" \\end{array} }\n",
" \\right]\n",
" w_{t+1}\n",
"$$\n",
"\n",
"$$\n",
"U_b =\n",
" \\left[ {\\begin{array}{cccccc}\n",
" 30 & 0 & 0 & 0 & 0 & 0\n",
" \\end{array} }\n",
" \\right]\n",
"$$\n",
"\n",
"$$\n",
"U_d =\n",
" \\left[ {\\begin{array}{cccccc}\n",
" 5 & 1 & 1 & 0.8 & 0.6 & 0.4 \\\\ 0 & 0 & 0 & 0 & 0 & 0\n",
" \\end{array} }\n",
" \\right]\n",
"$$\n",
"\n",
"The preference shock is constant at 30, while the endowment process is\n",
"the sum of a constant and two orthogonal processes.\n",
"\n",
"Specifically:\n",
"\n",
"$$\n",
"d_t = 5 + d_{1t} + d_{2t}\n",
"$$\n",
"\n",
"$$\n",
"d_{1t} = 0.9d_{1t-1} + w_{1t}\n",
"$$\n",
"\n",
"$$\n",
"d_{2t} = 4w_{2t} + 0.8(4w_{2t-1})+ 0.6(4w_{2t-2})+ 0.4(4w_{2t-3})\n",
"$$\n",
"\n",
"$ d_{1t} $ is a first-order AR process, while $ d_{2t} $ is a\n",
"third-order pure moving average process."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3d1eab81",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"γ_1 = 0.05\n",
"γ = np.array([[γ_1], [0]])\n",
"ϕ_c = np.array([[1], [0]])\n",
"ϕ_g = np.array([[0], [1]])\n",
"ϕ_1 = 0.00001\n",
"ϕ_i = np.array([[1], [-ϕ_1]])\n",
"δ_k = np.array([[1]])\n",
"θ_k = np.array([[1]])\n",
"β = np.array([[1 / 1.05]])\n",
"l_λ = np.array([[0]])\n",
"π_h = np.array([[1]])\n",
"δ_h = np.array([[.9]])\n",
"θ_h = np.array([[1]]) - δ_h\n",
"ud = np.array([[5, 1, 1, 0.8, 0.6, 0.4],\n",
" [0, 0, 0, 0, 0, 0]])\n",
"a22 = np.zeros((6, 6))\n",
"# Chase's great trick\n",
"a22[[0, 1, 3, 4, 5], [0, 1, 2, 3, 4]] = np.array([1.0, 0.9, 1.0, 1.0, 1.0])\n",
"c2 = np.zeros((6, 2))\n",
"c2[[1, 2], [0, 1]] = np.array([1.0, 4.0])\n",
"ub = np.array([[30, 0, 0, 0, 0, 0]])\n",
"x0 = np.array([[5], [150], [1], [0], [0], [0], [0], [0]])\n",
"\n",
"info1 = (a22, c2, ub, ud)\n",
"tech1 = (ϕ_c, ϕ_g, ϕ_i, γ, δ_k, θ_k)\n",
"pref1 = (β, l_λ, π_h, δ_h, θ_h)\n",
"\n",
"econ1 = DLE(info1, tech1, pref1)"
]
},
{
"cell_type": "markdown",
"id": "e866ad81",
"metadata": {},
"source": [
"We define the household’s net of interest deficit as $ c_t - d_t $.\n",
"\n",
"Hall’s model imposes “expected present-value budget balance” in the\n",
"sense that\n",
"\n",
"$$\n",
"\\mathbb{E}\\sum_{j=0}^\\infty \\beta^j (c_{t+j} - d_{t+j})|J_t = \\beta^{-1}k_{t-1} \\, \\forall t\n",
"$$\n",
"\n",
"Define a moving average representation of\n",
"$ (c_t, c_t - d_t) $ in terms of the $ w_t $s to be:\n",
"\n",
"$$\n",
"\\left[ {\\begin{array}{c}\n",
" c_t \\\\ c_t - d_t\n",
" \\end{array} }\n",
" \\right] = \\left[ {\\begin{array}{c}\n",
" \\sigma_1(L) \\\\ \\sigma_2(L)\n",
" \\end{array} }\n",
" \\right] w_t\n",
"$$\n",
"\n",
"Hall’s model imposes the restriction\n",
"$ \\sigma_2(\\beta) = [0\\,\\,\\,0] $.\n",
"\n",
"- The consumer who lives inside this model observes histories of both components of the\n",
" endowment process $ d_{1t} $ and $ d_{2t} $. \n",
"- The econometrician has data on the history of the pair\n",
" $ [c_t,d_t] $, but not directly on the history of $ w_t $’s. \n",
"- The econometrician obtains a Wold representation for the process\n",
" $ [c_t,c_t-d_t] $: \n",
"\n",
"\n",
"$$\n",
"\\left[ {\\begin{array}{c}\n",
" c_t \\\\ c_t - d_t\n",
" \\end{array} }\n",
" \\right] = \\left[ {\\begin{array}{c}\n",
" \\sigma_1^*(L) \\\\ \\sigma_2^*(L)\n",
" \\end{array} }\n",
" \\right] u_t\n",
"$$\n",
"\n",
"A representation with equivalent shocks would be recovered by estimating a bivariate vector autoregression for $ c_t, c_t-d_t $.\n",
"\n",
"The Appendix of chapter 8 of [[Hansen and Sargent, 2013](https://python-advanced.quantecon.org/zreferences.html#id72)] explains why the impulse\n",
"response functions in the Wold representation estimated by the\n",
"econometrician do not resemble the impulse response functions that\n",
"depict the response of consumption and the net-of-interest deficit to innovations $ w_t $ to\n",
"the consumer’s information.\n",
"\n",
"Technically, $ \\sigma_2(\\beta) = [0\\,\\,\\,0] $ implies that the\n",
"history of $ u_t $s spans a *smaller* linear space than does the\n",
"history of $ w_t $s.\n",
"\n",
"This means that $ u_t $ will typically be a distributed lag of\n",
"$ w_t $ that is not concentrated at zero lag:\n",
"\n",
"$$\n",
"u_t = \\sum_{j=0}^\\infty \\alpha_j w_{t-j}\n",
"$$\n",
"\n",
"Thus, the econometrician’s news $ u_t $ typically responds\n",
"belatedly to the consumer’s news $ w_t $."
]
},
{
"cell_type": "markdown",
"id": "5e7c1cfc",
"metadata": {},
"source": [
"## Code\n",
"\n",
"We will construct Figures from Chapter 8 Appendix E of [[Hansen and Sargent, 2013](https://python-advanced.quantecon.org/zreferences.html#id72)] to\n",
"illustrate these ideas:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0b76de26",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"# This is Fig 8.E.1 from p.188 of HS2013\n",
"\n",
"econ1.irf(ts_length=40, shock=None)\n",
"\n",
"fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4))\n",
"ax1.plot(econ1.c_irf, label='Consumption')\n",
"ax1.plot(econ1.c_irf - econ1.d_irf[:,0].reshape(40,1), label='Deficit')\n",
"ax1.legend()\n",
"ax1.set_title('Response to $w_{1t}$')\n",
"\n",
"shock2 = np.array([[0], [1]])\n",
"econ1.irf(ts_length=40, shock=shock2)\n",
"\n",
"ax2.plot(econ1.c_irf, label='Consumption')\n",
"ax2.plot(econ1.c_irf - econ1.d_irf[:,0].reshape(40, 1), label='Deficit')\n",
"ax2.legend()\n",
"ax2.set_title('Response to $w_{2t}$')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "8b8edcc5",
"metadata": {},
"source": [
"The above figure displays the impulse response of consumption and the\n",
"net-of-interest deficit to the innovations $ w_t $ to the consumer’s non-financial income\n",
"or endowment process.\n",
"\n",
"Consumption displays the characteristic “random walk” response with\n",
"respect to each innovation.\n",
"\n",
"Each endowment innovation leads to a\n",
"temporary surplus followed by a permanent net-of-interest deficit.\n",
"\n",
"The temporary surplus just offsets the permanent deficit in terms of\n",
"expected present value."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a8d80421",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"G_HS = np.vstack([econ1.Sc, econ1.Sc-econ1.Sd[0, :].reshape(1, 8)])\n",
"H_HS = 1e-8 * np.eye(2) # Set very small so there is no measurement error\n",
"lss_hs = qe.LinearStateSpace(econ1.A0, econ1.C, G_HS, H_HS)\n",
"\n",
"hs_kal = qe.Kalman(lss_hs)\n",
"w_lss = hs_kal.whitener_lss()\n",
"ma_coefs = hs_kal.stationary_coefficients(50, 'ma')\n",
"\n",
"# This is Fig 8.E.2 from p.189 of HS2013\n",
"\n",
"ma_coefs = ma_coefs\n",
"jj = 50\n",
"y1_w1 = np.empty(jj)\n",
"y2_w1 = np.empty(jj)\n",
"y1_w2 = np.empty(jj)\n",
"y2_w2 = np.empty(jj)\n",
"\n",
"for t in range(jj):\n",
" y1_w1[t] = ma_coefs[t][0, 0]\n",
" y1_w2[t] = ma_coefs[t][0, 1]\n",
" y2_w1[t] = ma_coefs[t][1, 0]\n",
" y2_w2[t] = ma_coefs[t][1, 1]\n",
"\n",
"# This scales the impulse responses to match those in the book\n",
"y1_w1 = sqrt(hs_kal.stationary_innovation_covar()[0, 0]) * y1_w1\n",
"y2_w1 = sqrt(hs_kal.stationary_innovation_covar()[0, 0]) * y2_w1\n",
"y1_w2 = sqrt(hs_kal.stationary_innovation_covar()[1, 1]) * y1_w2\n",
"y2_w2 = sqrt(hs_kal.stationary_innovation_covar()[1, 1]) * y2_w2\n",
"\n",
"fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4))\n",
"ax1.plot(y1_w1, label='Consumption')\n",
"ax1.plot(y2_w1, label='Deficit')\n",
"ax1.legend()\n",
"ax1.set_title('Response to $u_{1t}$')\n",
"\n",
"ax2.plot(y1_w2, label='Consumption')\n",
"ax2.plot(y2_w2, label='Deficit')\n",
"ax2.legend()\n",
"ax2.set_title('Response to $u_{2t}$')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "2747d7dd",
"metadata": {},
"source": [
"The above figure displays the impulse response of consumption and the\n",
"deficit to the innovations in the econometrician’s Wold representation\n",
"\n",
"- this is the object that would be recovered from a high order vector\n",
" autoregression on the econometrician’s observations. \n",
"\n",
"\n",
"Consumption responds only to the first innovation\n",
"\n",
"- this is indicative of the Granger causality imposed on the\n",
" $ [c_t, c_t - d_t] $ process by Hall’s model: consumption Granger\n",
" causes $ c_t - d_t $, with no reverse causality. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2f6abe43",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"# This is Fig 8.E.3 from p.189 of HS2013\n",
"\n",
"jj = 20\n",
"irf_wlss = w_lss.impulse_response(jj)\n",
"ycoefs = irf_wlss[1]\n",
"# Pull out the shocks\n",
"a1_w1 = np.empty(jj)\n",
"a1_w2 = np.empty(jj)\n",
"a2_w1 = np.empty(jj)\n",
"a2_w2 = np.empty(jj)\n",
"\n",
"for t in range(jj):\n",
" a1_w1[t] = ycoefs[t][0, 0]\n",
" a1_w2[t] = ycoefs[t][0, 1]\n",
" a2_w1[t] = ycoefs[t][1, 0]\n",
" a2_w2[t] = ycoefs[t][1, 1]\n",
"\n",
"fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4))\n",
"ax1.plot(a1_w1, label='Consumption innov.')\n",
"ax1.plot(a2_w1, label='Deficit innov.')\n",
"ax1.set_title('Response to $w_{1t}$')\n",
"ax1.legend()\n",
"ax2.plot(a1_w2, label='Consumption innov.')\n",
"ax2.plot(a2_w2, label='Deficit innov.')\n",
"ax2.legend()\n",
"ax2.set_title('Response to $w_{2t}$')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "cac7ca41",
"metadata": {},
"source": [
"The above figure displays the impulse responses of $ u_t $ to\n",
"$ w_t $, as depicted in:\n",
"\n",
"$$\n",
"u_t = \\sum_{j=0}^\\infty \\alpha_j w_{t-j}\n",
"$$\n",
"\n",
"While the responses of the innovations to consumption are concentrated\n",
"at lag zero for both components of $ w_t $, the responses of the\n",
"innovations to $ (c_t - d_t) $ are spread over time (especially in\n",
"response to $ w_{1t} $).\n",
"\n",
"Thus, the innovations to $ (c_t - d_t) $ as revealed by the vector\n",
"autoregression depend on what the economic agent views as “old news”."
]
}
],
"metadata": {
"date": 1728369869.086332,
"filename": "hs_invertibility_example.md",
"kernelspec": {
"display_name": "Python",
"language": "python3",
"name": "python3"
},
"title": "Shock Non Invertibility"
},
"nbformat": 4,
"nbformat_minor": 5
}