{
"cells": [
{
"cell_type": "markdown",
"id": "6272d452",
"metadata": {},
"source": [
"\n",
""
]
},
{
"cell_type": "markdown",
"id": "e43c2b23",
"metadata": {},
"source": [
"# Consumption Smoothing with Complete and Incomplete Markets\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"id": "135bcb38",
"metadata": {},
"source": [
"## Contents\n",
"\n",
"- [Consumption Smoothing with Complete and Incomplete Markets](#Consumption-Smoothing-with-Complete-and-Incomplete-Markets) \n",
" - [Overview](#Overview) \n",
" - [Background](#Background) \n",
" - [Linear State Space Version of Complete Markets Model](#Linear-State-Space-Version-of-Complete-Markets-Model) \n",
" - [Model 1 (Complete Markets)](#Model-1-%28Complete-Markets%29) \n",
" - [Model 2 (One-Period Risk-Free Debt Only)](#Model-2-%28One-Period-Risk-Free-Debt-Only%29) "
]
},
{
"cell_type": "markdown",
"id": "a777fd51",
"metadata": {},
"source": [
"In addition to what’s in Anaconda, this lecture uses the library:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db7d6628",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"!pip install --upgrade quantecon"
]
},
{
"cell_type": "markdown",
"id": "586df49c",
"metadata": {},
"source": [
"## Overview\n",
"\n",
"This lecture describes two types of consumption-smoothing models.\n",
"\n",
"- one is in the **complete markets** tradition of [Kenneth Arrow](https://en.wikipedia.org/wiki/Kenneth_Arrow) \n",
"- the other is in the **incomplete markets** tradition of Hall [[Hal78](https://python-advanced.quantecon.org/zreferences.html#id152)] \n",
"\n",
"\n",
"*Complete markets* allow a consumer to buy and sell claims contingent on all possible states of the world.\n",
"\n",
"*Incomplete markets* allow a consumer to buy and sell a limited set of securities, often only a single risk-free security.\n",
"\n",
"Hall [[Hal78](https://python-advanced.quantecon.org/zreferences.html#id152)] worked in an incomplete markets tradition by assuming\n",
"that the only asset that can be traded is a risk-free one-period bond.\n",
"\n",
"Hall assumed an exogenous stochastic process of nonfinancial income and\n",
"an exogenous and time-invariant gross interest rate on one-period risk-free debt that equals\n",
"$ \\beta^{-1} $, where $ \\beta \\in (0,1) $ is also a consumer’s\n",
"intertemporal discount factor.\n",
"\n",
"This is equivalent to saying that it costs $ \\beta $ of time $ t $ consumption to buy one unit of\n",
"consumption at time $ t+1 $ for sure.\n",
"\n",
"So $ \\beta $ is the price of a one-period risk-free claim to consumption next period.\n",
"\n",
"We preserve Hall’s assumption about the interest rate when we describe an\n",
"incomplete markets version of our model.\n",
"\n",
"In addition, we extend Hall’s assumption about the risk-free interest rate to an appropriate counterpart when we create another model in which there are markets\n",
"in a complete array of one-period Arrow state-contingent securities.\n",
"\n",
"We’ll consider two closely related alternative assumptions about the consumer’s\n",
"exogenous nonfinancial income process:\n",
"\n",
"- that it is generated by a finite $ N $ state Markov chain (setting $ N=2 $ most of the time in this lecture) \n",
"- that it is described by a linear state space model with a continuous\n",
" state vector in $ {\\mathbb R}^n $ driven by a Gaussian vector IID shock\n",
" process \n",
"\n",
"\n",
"We’ll spend most of this lecture studying the finite-state Markov specification, but will begin by studying the linear state space specification because it\n",
"is so closely linked to earlier lectures.\n",
"\n",
"Let’s start with some imports:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c840910",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"import numpy as np\n",
"import quantecon as qe\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"import scipy.linalg as la"
]
},
{
"cell_type": "markdown",
"id": "1cd67cce",
"metadata": {},
"source": [
"### Relationship to Other Lectures\n",
"\n",
"This lecture can be viewed as a followup to [Optimal Savings II: LQ Techniques](https://python-intro.quantecon.org/perm_income_cons.html)\n",
"\n",
"This lecture is also a prologomenon to a lecture on tax-smoothing [Tax Smoothing with Complete and Incomplete Markets](https://python-advanced.quantecon.org/smoothing_tax.html)"
]
},
{
"cell_type": "markdown",
"id": "98d20540",
"metadata": {},
"source": [
"## Background\n",
"\n",
"Outcomes in consumption-smoothing models emerge from two\n",
"sources:\n",
"\n",
"- a consumer who wants to maximize an\n",
" intertemporal objective function that expresses its preference for\n",
" paths of consumption that are *smooth* in the\n",
" sense of varying as little as possible both across time and across realized Markov states \n",
"- opportunities that allow the consumer to transform\n",
" an erratic nonfinancial income\n",
" process into a smoother consumption process by\n",
" buying and selling one or more financial securities \n",
"\n",
"\n",
"In the **complete markets version**, each period the consumer\n",
"can buy or sell a complete set of one-period ahead state-contingent securities whose\n",
"payoffs depend on next period’s realization of the Markov state.\n",
"\n",
"- In the two-state Markov chain case, two such securities are traded each period. \n",
"- In an $ N $ state Markov state version, $ N $ such securities are traded each period. \n",
"- In a continuous state Markov state version, a continuum of such securities is traded each period. \n",
"\n",
"\n",
"These state-contingent securities are commonly called Arrow securities, after [Kenneth Arrow](https://en.wikipedia.org/wiki/Kenneth_Arrow).\n",
"\n",
"In the **incomplete markets version**, the consumer can buy and sell only one security each period, a risk-free one-period bond with gross\n",
"one-period return $ \\beta^{-1} $."
]
},
{
"cell_type": "markdown",
"id": "cd34a0c3",
"metadata": {},
"source": [
"## Linear State Space Version of Complete Markets Model\n",
"\n",
"We’ll study a complete markets model adapted to a setting with a continuous Markov state like that\n",
"in the [first lecture on the permanent income model](https://python-intro.quantecon.org/perm_income.html).\n",
"\n",
"In that model\n",
"\n",
"- a consumer can trade only a single risk-free one-period bond bearing gross one-period risk-free interest rate equal to $ \\beta^{-1} $. \n",
"- a consumer’s exogenous nonfinancial income is governed by a linear state space model driven by Gaussian shocks, the kind of model studied in an earlier lecture about [linear state space models](https://python-intro.quantecon.org/linear_models.html). \n",
"\n",
"\n",
"Let’s write down a complete markets counterpart of that model.\n",
"\n",
"Suppose that nonfinancial income is governed by the state\n",
"space system\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
" x_{t+1} & = A x_t + C w_{t+1} \\cr\n",
" y_t & = S_y x_t\n",
"\\end{aligned}\n",
"$$\n",
"\n",
"where $ x_t $ is an $ n \\times 1 $ vector and $ w_{t+1} \\sim {\\cal N}(0,I) $ is IID over time.\n",
"\n",
"We want a natural counterpart of the Hall assumption that the one-period risk-free\n",
"gross interest rate is $ \\beta^{-1} $.\n",
"\n",
"We make the good guess that prices\n",
"of one-period ahead Arrow securities are described by the **pricing kernel**\n",
"\n",
"\n",
"\n",
"$$\n",
"q_{t+1}(x_{t+1} \\,|\\, x_t) = \\beta \\phi(x_{t+1} \\,|\\, A x_t, CC') \\tag{6.1}\n",
"$$\n",
"\n",
"where $ \\phi(\\cdot \\,|\\, \\mu, \\Sigma) $ is a multivariate Gaussian\n",
"distribution with mean vector $ \\mu $ and covariance matrix\n",
"$ \\Sigma $.\n",
"\n",
"With the pricing kernel $ q_{t+1}(x_{t+1} \\,|\\, x_t) $ in hand, we can price claims to consumption at time $ t+1 $ consumption that pay off when\n",
"$ x_{t+1} \\in S $ at time $ t+1 $:\n",
"\n",
"$$\n",
"\\int_S q_{t+1}(x_{t+1} \\,|\\, x_t) d x_{t+1}\n",
"$$\n",
"\n",
"where $ S $ is a subset of $ \\mathbb R^n $.\n",
"\n",
"The price $ \\int_S q_{t+1}(x_{t+1} \\,|\\, x_t) d x_{t+1} $ of such a claim depends on state $ x_t $ because the prices of the $ x_{t+1} $-contingent\n",
"securities depend on $ x_t $ through the pricing kernel $ q(x_{t+1} \\,|\\, x_t) $.\n",
"\n",
"Let $ b(x_{t+1}) $ be a vector of state-contingent debt due at $ t+1 $\n",
"as a function of the $ t+1 $ state $ x_{t+1} $.\n",
"\n",
"Using the pricing kernel assumed in [(6.1)](#equation-cs-14), the value at\n",
"$ t $ of $ b(x_{t+1}) $ is evidently\n",
"\n",
"$$\n",
"\\beta \\int b(x_{t+1}) \\phi(x_{t+1} \\,|\\, A x_t, CC') d x_{t+1} = \\beta \\mathbb E_t b_{t+1}\n",
"$$\n",
"\n",
"In our complete markets setting, the consumer faces a sequence of budget\n",
"constraints\n",
"\n",
"$$\n",
"c_t + b_t = y_t + \\beta \\mathbb E_t b_{t+1}, \\quad t \\geq 0\n",
"$$\n",
"\n",
"Please note that\n",
"\n",
"$$\n",
"\\beta E_t b_{t+1} = \\beta \\int \\phi_{t+1}(x_{t+1} | A x_t, C C') b_{t+1}(x_{t+1}) d x_{t+1}\n",
"$$\n",
"\n",
"or\n",
"\n",
"$$\n",
"\\beta E_t b_{t+1} = \\int q_{t+1}(x_{t+1}| x_t) b_{t+1}(x_{t+1}) d x_{t+1}\n",
"$$\n",
"\n",
"which verifies that $ \\beta E_t b_{t+1} $ is the **value** of time $ t+1 $ state-contingent claims on time $ t+1 $ consumption issued by the consumer at time $ t $\n",
"\n",
"We can solve the time $ t $ budget constraint forward to obtain\n",
"\n",
"$$\n",
"b_t = \\mathbb E_t \\sum_{j=0}^\\infty \\beta^j (y_{t+j} - c_{t+j} )\n",
"$$\n",
"\n",
"The consumer cares about the expected value\n",
"of\n",
"\n",
"$$\n",
"\\sum_{t=0}^\\infty \\beta^t u(c_t), \\quad 0 < \\beta < 1\n",
"$$\n",
"\n",
"In the incomplete markets version of the model, we assumed that\n",
"$ u(c_t) = - (c_t -\\gamma)^2 $, so that the above utility functional\n",
"became\n",
"\n",
"$$\n",
"-\\sum_{t=0}^\\infty \\beta^t ( c_t - \\gamma)^2, \\quad 0 < \\beta < 1\n",
"$$\n",
"\n",
"But in the complete markets version, it is tractable to assume a more general utility function that satisfies $ u' > 0 $ and $ u'' < 0 $.\n",
"\n",
"First-order conditions for the consumer’s problem with complete\n",
"markets and our assumption about Arrow securities prices are\n",
"\n",
"$$\n",
"u'(c_{t+1}) = u'(c_t) \\quad \\text{for all } t\\geq 0\n",
"$$\n",
"\n",
"which implies $ c_t = \\bar c $ for some $ \\bar c $.\n",
"\n",
"So it follows that\n",
"\n",
"$$\n",
"b_t = \\mathbb E_t \\sum_{j=0}^\\infty \\beta^j (y_{t+j} - \\bar c)\n",
"$$\n",
"\n",
"or\n",
"\n",
"\n",
"\n",
"$$\n",
"b_t = S_y (I - \\beta A)^{-1} x_t - \\frac{1}{1-\\beta} \\bar c \\tag{6.2}\n",
"$$\n",
"\n",
"where $ \\bar c $ satisfies\n",
"\n",
"\n",
"\n",
"$$\n",
"\\bar b_0 = S_y (I - \\beta A)^{-1} x_0 - \\frac{1}{1 - \\beta } \\bar c \\tag{6.3}\n",
"$$\n",
"\n",
"where $ \\bar b_0 $ is an initial level of the consumer’s debt due at time $ t=0 $, specified\n",
"as a parameter of the problem.\n",
"\n",
"Thus, in the complete markets version of the consumption-smoothing\n",
"model, $ c_t = \\bar c, \\forall t \\geq 0 $ is determined by [(6.3)](#equation-cs-16)\n",
"and the consumer’s debt is the fixed function of\n",
"the state $ x_t $ described by [(6.2)](#equation-cs-15).\n",
"\n",
"Please recall that in the LQ permanent income model studied in [permanent income model](https://python-intro.quantecon.org/perm_income.html), the state is\n",
"$ x_t, b_t $, where $ b_t $ is a complicated function of past state vectors $ x_{t-j} $.\n",
"\n",
"Notice that in contrast to that incomplete markets model, at time $ t $ the state vector is $ x_t $ alone in our complete markets model.\n",
"\n",
"Here’s an example that shows how in this setting the availability of insurance against fluctuating nonfinancial income\n",
"allows the consumer completely to smooth consumption across time and across states of the world"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0f45ad17",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"def complete_ss(β, b0, x0, A, C, S_y, T=12):\n",
" \"\"\"\n",
" Computes the path of consumption and debt for the previously described\n",
" complete markets model where exogenous income follows a linear\n",
" state space\n",
" \"\"\"\n",
" # Create a linear state space for simulation purposes\n",
" # This adds \"b\" as a state to the linear state space system\n",
" # so that setting the seed places shocks in same place for\n",
" # both the complete and incomplete markets economy\n",
" # Atilde = np.vstack([np.hstack([A, np.zeros((A.shape[0], 1))]),\n",
" # np.zeros((1, A.shape[1] + 1))])\n",
" # Ctilde = np.vstack([C, np.zeros((1, 1))])\n",
" # S_ytilde = np.hstack([S_y, np.zeros((1, 1))])\n",
"\n",
" lss = qe.LinearStateSpace(A, C, S_y, mu_0=x0)\n",
"\n",
" # Add extra state to initial condition\n",
" # x0 = np.hstack([x0, np.zeros(1)])\n",
"\n",
" # Compute the (I - β * A)^{-1}\n",
" rm = la.inv(np.eye(A.shape[0]) - β * A)\n",
"\n",
" # Constant level of consumption\n",
" cbar = (1 - β) * (S_y @ rm @ x0 - b0)\n",
" c_hist = np.full(T, cbar)\n",
"\n",
" # Debt\n",
" x_hist, y_hist = lss.simulate(T)\n",
" b_hist = np.squeeze(S_y @ rm @ x_hist - cbar / (1 - β))\n",
"\n",
"\n",
" return c_hist, b_hist, np.squeeze(y_hist), x_hist\n",
"\n",
"\n",
"# Define parameters\n",
"N_simul = 80\n",
"α, ρ1, ρ2 = 10.0, 0.9, 0.0\n",
"σ = 1.0\n",
"\n",
"A = np.array([[1., 0., 0.],\n",
" [α, ρ1, ρ2],\n",
" [0., 1., 0.]])\n",
"C = np.array([[0.], [σ], [0.]])\n",
"S_y = np.array([[1, 1.0, 0.]])\n",
"β, b0 = 0.95, -10.0\n",
"x0 = np.array([1.0, α / (1 - ρ1), α / (1 - ρ1)])\n",
"\n",
"# Do simulation for complete markets\n",
"s = np.random.randint(0, 10000)\n",
"np.random.seed(s) # Seeds get set the same for both economies\n",
"out = complete_ss(β, b0, x0, A, C, S_y, 80)\n",
"c_hist_com, b_hist_com, y_hist_com, x_hist_com = out\n",
"\n",
"fig, ax = plt.subplots(1, 2, figsize=(14, 4))\n",
"\n",
"# Consumption plots\n",
"ax[0].set_title('Consumption and income')\n",
"ax[0].plot(np.arange(N_simul), c_hist_com, label='consumption')\n",
"ax[0].plot(np.arange(N_simul), y_hist_com, label='income', alpha=.6, linestyle='--')\n",
"ax[0].legend()\n",
"ax[0].set_xlabel('Periods')\n",
"ax[0].set_ylim([80, 120])\n",
"\n",
"# Debt plots\n",
"ax[1].set_title('Debt and income')\n",
"ax[1].plot(np.arange(N_simul), b_hist_com, label='debt')\n",
"ax[1].plot(np.arange(N_simul), y_hist_com, label='Income', alpha=.6, linestyle='--')\n",
"ax[1].legend()\n",
"ax[1].axhline(0, color='k')\n",
"ax[1].set_xlabel('Periods')\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "35071159",
"metadata": {},
"source": [
"### Interpretation of Graph\n",
"\n",
"In the above graph, please note that:\n",
"\n",
"- nonfinancial income fluctuates in a stationary manner. \n",
"- consumption is completely constant. \n",
"- the consumer’s debt fluctuates in a stationary manner; in fact, in\n",
" this case, because nonfinancial income is a first-order\n",
" autoregressive process, the consumer’s debt is an exact affine function\n",
" (meaning linear plus a constant) of the consumer’s nonfinancial\n",
" income. "
]
},
{
"cell_type": "markdown",
"id": "b4b6ea0f",
"metadata": {},
"source": [
"### Incomplete Markets Version\n",
"\n",
"The incomplete markets version of the model with nonfinancial income being governed by a linear state space system\n",
"is described in [permanent income model](https://python-intro.quantecon.org/perm_income_cons.html).\n",
"\n",
"In that incomplete markerts setting, consumption follows a random walk and the consumer’s debt follows a process with a unit root."
]
},
{
"cell_type": "markdown",
"id": "22faa112",
"metadata": {},
"source": [
"### Finite State Markov Income Process\n",
"\n",
"We now turn to a finite-state Markov version of the model in which the consumer’s nonfinancial income is an exact function of a Markov state that\n",
"takes one of $ N $ values.\n",
"\n",
"We’ll start with a setting in which in each version of our consumption-smoothing model, nonfinancial income is governed by a two-state Markov chain\n",
"(it’s easy to generalize this to an $ N $ state Markov chain).\n",
"\n",
"In particular, the *state* $ s_t \\in \\{1, 2\\} $ follows\n",
"a Markov chain with transition probability matrix\n",
"\n",
"$$\n",
"P_{ij} = \\mathbb P \\{s_{t+1} = j \\,|\\, s_t = i \\}\n",
"$$\n",
"\n",
"where $ \\mathbb P $ means conditional probability\n",
"\n",
"Nonfinancial income $ \\{y_t\\} $ obeys\n",
"\n",
"$$\n",
"y_t =\n",
"\\begin{cases}\n",
" \\bar y_1 & \\quad \\text{if } s_t = 1 \\\\\n",
" \\bar y_2 & \\quad \\text{if } s_t = 2\n",
"\\end{cases}\n",
"$$\n",
"\n",
"A consumer wishes to maximize\n",
"\n",
"\n",
"\n",
"$$\n",
"\\mathbb E\n",
"\\left[\n",
" \\sum_{t=0}^\\infty \\beta^t u(c_t)\n",
"\\right]\n",
"\\quad\n",
"\\text{where} \\quad\n",
"u(c_t) = - (c_t -\\gamma)^2\n",
"\\quad \\text{and} \\quad\n",
" 0 < \\beta < 1 \\tag{6.4}\n",
"$$\n",
"\n",
"Here $ \\gamma >0 $ is a bliss level of consumption"
]
},
{
"cell_type": "markdown",
"id": "4bea102f",
"metadata": {},
"source": [
"### Market Structure\n",
"\n",
"Our complete and incomplete markets models differ in how thoroughly the market structure allows a\n",
"consumer to transfer resources across time and Markov states, there\n",
"being more transfer opportunities in the complete markets setting than\n",
"in the incomplete markets setting.\n",
"\n",
"Watch how these differences in opportunities affect\n",
"\n",
"- how smooth consumption is across time and Markov states \n",
"- how the consumer chooses to make his levels of indebtedness behave\n",
" over time and across Markov states "
]
},
{
"cell_type": "markdown",
"id": "17be6195",
"metadata": {},
"source": [
"## Model 1 (Complete Markets)\n",
"\n",
"At each date $ t \\geq 0 $, the consumer trades a full array of **one-period ahead\n",
"Arrow securities**.\n",
"\n",
"We assume that prices of these securities are exogenous to the consumer.\n",
"\n",
"*Exogenous* means that they are unaffected by the consumer’s decisions.\n",
"\n",
"In Markov state $ s_t $ at time $ t $, one unit of consumption\n",
"in state $ s_{t+1} $ at time $ t+1 $ costs $ q(s_{t+1} \\,|\\, s_t) $ units of the time $ t $ consumption good.\n",
"\n",
"The prices $ q(s_{t+1} \\,|\\, s_t) $ are given and can be organized into a matrix $ Q $ with $ Q_{ij} = q(j | i) $\n",
"\n",
"At time $ t=0 $, the consumer starts with an inherited level of debt\n",
"due at time $ 0 $ of $ b_0 $ units of time $ 0 $ consumption\n",
"goods.\n",
"\n",
"The consumer’s budget constraint at $ t \\geq 0 $ in Markov\n",
"state $ s_t $ is\n",
"\n",
"\n",
"\n",
"$$\n",
"c_t + b_t\n",
"\\leq y(s_t) +\n",
"\\sum_j q(j \\,|\\, s_t ) \\, b_{t+1}( j \\,|\\, s_t) \\tag{6.5}\n",
"$$\n",
"\n",
"where $ b_t $ is the consumer’s one-period debt that falls due at time $ t $ and $ b_{t+1}(j\\,|\\, s_t) $ are the consumer’s time\n",
"$ t $ sales of the time $ t+1 $ consumption good in Markov state $ j $.\n",
"\n",
"Thus\n",
"\n",
"- $ q(j\\,|\\, s_t) b_{t+1}(j \\, |\\, s_t) $ is a source of time $ t $ **financial income** for the consumer in Markov state $ s_t $ \n",
"- $ b_t \\equiv b_t(j \\, |\\, s_{t-1}) $ is a source of time $ t $ **expenditures** for the consumer when $ s_t = j $ \n",
"\n",
"\n",
"**Remark:** We are ignoring an important technicality here, namely, that the consumer’s choice of $ b_{t+1}(j | \\, s_t) $ must\n",
"respect so-called *natural debt limits* that assure that it is feasible for the consumer to repay debts due even if he consumers zero forevermore.\n",
"We shall discuss such debt limits in another lecture.\n",
"\n",
"A natural analog of Hall’s assumption that the one-period risk-free gross\n",
"interest rate is $ \\beta^{-1} $ is\n",
"\n",
"\n",
"\n",
"$$\n",
"q(j \\,|\\, i) = \\beta P_{ij} \\tag{6.6}\n",
"$$\n",
"\n",
"To understand how this is a natural analogue, observe that in state $ i $ it costs $ \\sum_j q(j \\,|\\, i) $ to purchase one unit of consumption next period *for sure*, i.e., meaning no matter what\n",
"Markov state $ j $ occurs at $ t+1 $.\n",
"\n",
"Hence the **implied price** of a risk-free claim on one unit of consumption next\n",
"period is\n",
"\n",
"$$\n",
"\\sum_j q(j \\,|\\, i) = \\sum_j \\beta P_{ij} = \\beta\n",
"$$\n",
"\n",
"This confirms the sense in which [(6.6)](#equation-cs-2) is a natural counterpart to Hall’s assumption that the\n",
"risk-free one-period gross interest rate is $ R = \\beta^{-1} $.\n",
"\n",
"It is timely please to recall that the gross one-period risk-free interest rate is the reciprocal of the price at time $ t $ of a risk-free claim on\n",
"one unit of consumption tomorrow.\n",
"\n",
"First-order necessary conditions for maximizing the consumer’s expected utility subject to the sequence of budget constraints [(6.5)](#equation-cs-budget1) are\n",
"\n",
"$$\n",
"\\beta \\frac{u'(c_{t+1})}{u'(c_t) } \\mathbb P\\{s_{t+1}\\,|\\, s_t \\}\n",
" = q(s_{t+1} \\,|\\, s_t)\n",
"$$\n",
"\n",
"for all $ s_t, s_{t+1} $ or, under our assumption [(6.6)](#equation-cs-2) about Arrow security prices,\n",
"\n",
"\n",
"\n",
"$$\n",
"c_{t+1} = c_t \\tag{6.7}\n",
"$$\n",
"\n",
"Thus, our consumer sets $ c_t = \\bar c $ for all $ t \\geq 0 $ for some value $ \\bar c $ that it is our job now to determine along with\n",
"values for $ b_{t+1}(j | s_t = i) $ for $ i=1,2 $ and $ j = 1,2 $.\n",
"\n",
"We’ll use a *guess and verify* method to determine these objects\n",
"\n",
"**Guess:** We’ll make the plausible guess that\n",
"\n",
"\n",
"\n",
"$$\n",
"b_{t+1}(s_{t+1} = j \\,|\\, s_t = i) = b(j) ,\n",
" \\quad i=1,2; \\;\\; j= 1,2 \\tag{6.8}\n",
"$$\n",
"\n",
"so that the amount borrowed today depends only on *tomorrow’s* Markov state. (Why is this is a plausible guess?)\n",
"\n",
"To determine $ \\bar c $, we shall deduce implications of the consumer’s budget constraints in each Markov state today and our guess [(6.8)](#equation-eq-guess) about the consumer’s debt level choices.\n",
"\n",
"For $ t \\geq 1 $, these imply\n",
"\n",
"\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
" \\bar c + b(1) & = y(1) + q(1\\,|\\, 1) b(1) + q(2 \\,|\\, 1) b(2) \\cr\n",
" \\bar c + b(2) & = y(2) + q(1\\,|\\, 2) b(1) + q(2 \\,|\\, 2) b(2)\n",
"\\end{aligned} \\tag{6.9}\n",
"$$\n",
"\n",
"or\n",
"\n",
"$$\n",
"\\begin{bmatrix}\n",
" b(1) \\cr b(2)\n",
"\\end{bmatrix} +\n",
"\\begin{bmatrix}\n",
"\\bar c \\cr \\bar c\n",
"\\end{bmatrix} =\n",
"\\begin{bmatrix}\n",
" y(1) \\cr y(2)\n",
"\\end{bmatrix} +\n",
"\\beta\n",
"\\begin{bmatrix}\n",
" P_{11} & P_{12} \\cr P_{21} & P_{22}\n",
"\\end{bmatrix}\n",
"\\begin{bmatrix}\n",
" b(1) \\cr b(2)\n",
"\\end{bmatrix}\n",
"$$\n",
"\n",
"These are $ 2 $ equations in the $ 3 $ unknowns\n",
"$ \\bar c, b(1), b(2) $\n",
"\n",
"To get a third equation, we assume that at time $ t=0, $ $ b_0 $\n",
"is debt due; and we assume that at time $ t=0, $ the Markov\n",
"state $ s_0 =1 $\n",
"\n",
"(We could instead have assumed that at time $ t=0 $ the Markov state $ s_0 = 2 $, which would affect our answer as we shall see)\n",
"\n",
"Since we have assumed that $ s_0 = 1 $, the budget constraint at time $ t=0 $ is\n",
"\n",
"\n",
"\n",
"$$\n",
"\\bar c + b_0 = y(1) + q(1 \\,|\\, 1) b(1) + q(2\\,|\\,1) b(2) \\tag{6.10}\n",
"$$\n",
"\n",
"where $ b_0 $ is the (exogenous) debt the consumer is assumed to bring into period $ 0 $\n",
"\n",
"If we substitute [(6.10)](#equation-cs-5) into the first equation of [(6.9)](#equation-cs-4a) and rearrange, we\n",
"discover that\n",
"\n",
"\n",
"\n",
"$$\n",
"b(1) = b_0 \\tag{6.11}\n",
"$$\n",
"\n",
"We can then use the second equation of [(6.9)](#equation-cs-4a) to deduce the restriction\n",
"\n",
"\n",
"\n",
"$$\n",
"y(1) - y(2) + [q(1\\,|\\, 1) - q(1\\,|\\, 2) - 1 ] b_0 +\n",
"[q(2\\,|\\,1) + 1 - q(2 \\,|\\, 2) ] b(2) = 0 , \\tag{6.12}\n",
"$$\n",
"\n",
"an equation that we can solve for the unknown $ b(2) $.\n",
"\n",
"Knowing $ b(1) $ and $ b(2) $, we can solve equation [(6.10)](#equation-cs-5) for the constant level of consumption $ \\bar c $."
]
},
{
"cell_type": "markdown",
"id": "acb77aa2",
"metadata": {},
"source": [
"### Key Outcomes\n",
"\n",
"The preceding calculations indicate that in the complete markets version\n",
"of our model, we obtain the following striking results:\n",
"\n",
"- The consumer chooses to make consumption perfectly constant across\n",
" time and across Markov states. \n",
"- State-contingent debt purchases $ b_{t+1}(s_{t+1} = j | s_t = i) $ depend only on $ j $ \n",
"- If the initial Markov state is $ s_0 =j $ and initial consumer debt is $ b_0 $, then debt in Markov state $ j $ satisfies $ b(j) = b_0 $ \n",
"\n",
"\n",
"To summarize what we have achieved up to now, we have computed the constant level of\n",
"consumption $ \\bar c $ and indicated how that level depends on the underlying specifications of preferences, Arrow securities prices, the stochastic process of exogenous nonfinancial income, and the initial debt level $ b_0 $\n",
"\n",
"- The consumer’s debt neither accumulates, nor decumulates, nor drifts –\n",
" instead, the debt level each period is an exact function of the Markov\n",
" state, so in the two-state Markov case, it switches between two\n",
" values. \n",
"- We have verified guess [(6.8)](#equation-eq-guess). \n",
"- When the state $ s_t $ returns to the initial state $ s_0 $, debt returns to the initial debt level. \n",
"- Debt levels in all other states depend on virtually all remaining parameters of the model. "
]
},
{
"cell_type": "markdown",
"id": "afe554fe",
"metadata": {},
"source": [
"### Code\n",
"\n",
"Here’s some code that, among other things, contains a function called `consumption_complete()`.\n",
"\n",
"This function computes $ \\{ b(i) \\}_{i=1}^{N}, \\bar c $ as outcomes given a set of parameters for the general case with $ N $ Markov states\n",
"under the assumption of complete markets"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d4a229d9",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"class ConsumptionProblem:\n",
" \"\"\"\n",
" The data for a consumption problem, including some default values.\n",
" \"\"\"\n",
"\n",
" def __init__(self,\n",
" β=.96,\n",
" y=[2, 1.5],\n",
" b0=3,\n",
" P=[[.8, .2],\n",
" [.4, .6]],\n",
" init=0):\n",
" \"\"\"\n",
" Parameters\n",
" ----------\n",
"\n",
" β : discount factor\n",
" y : list containing the two income levels\n",
" b0 : debt in period 0 (= initial state debt level)\n",
" P : 2x2 transition matrix\n",
" init : index of initial state s0\n",
" \"\"\"\n",
" self.β = β\n",
" self.y = np.asarray(y)\n",
" self.b0 = b0\n",
" self.P = np.asarray(P)\n",
" self.init = init\n",
"\n",
" def simulate(self, N_simul=80, random_state=1):\n",
" \"\"\"\n",
" Parameters\n",
" ----------\n",
"\n",
" N_simul : number of periods for simulation\n",
" random_state : random state for simulating Markov chain\n",
" \"\"\"\n",
" # For the simulation define a quantecon MC class\n",
" mc = qe.MarkovChain(self.P)\n",
" s_path = mc.simulate(N_simul, init=self.init, random_state=random_state)\n",
"\n",
" return s_path\n",
"\n",
"\n",
"def consumption_complete(cp):\n",
" \"\"\"\n",
" Computes endogenous values for the complete market case.\n",
"\n",
" Parameters\n",
" ----------\n",
"\n",
" cp : instance of ConsumptionProblem\n",
"\n",
" Returns\n",
" -------\n",
"\n",
" c_bar : constant consumption\n",
" b : optimal debt in each state\n",
"\n",
" associated with the price system\n",
"\n",
" Q = β * P\n",
" \"\"\"\n",
" β, P, y, b0, init = cp.β, cp.P, cp.y, cp.b0, cp.init # Unpack\n",
"\n",
" Q = β * P # assumed price system\n",
"\n",
" # construct matrices of augmented equation system\n",
" n = P.shape[0] + 1\n",
"\n",
" y_aug = np.empty((n, 1))\n",
" y_aug[0, 0] = y[init] - b0\n",
" y_aug[1:, 0] = y\n",
"\n",
" Q_aug = np.zeros((n, n))\n",
" Q_aug[0, 1:] = Q[init, :]\n",
" Q_aug[1:, 1:] = Q\n",
"\n",
" A = np.zeros((n, n))\n",
" A[:, 0] = 1\n",
" A[1:, 1:] = np.eye(n-1)\n",
"\n",
" x = np.linalg.inv(A - Q_aug) @ y_aug\n",
"\n",
" c_bar = x[0, 0]\n",
" b = x[1:, 0]\n",
"\n",
" return c_bar, b\n",
"\n",
"\n",
"def consumption_incomplete(cp, s_path):\n",
" \"\"\"\n",
" Computes endogenous values for the incomplete market case.\n",
"\n",
" Parameters\n",
" ----------\n",
"\n",
" cp : instance of ConsumptionProblem\n",
" s_path : the path of states\n",
" \"\"\"\n",
" β, P, y, b0 = cp.β, cp.P, cp.y, cp.b0 # Unpack\n",
"\n",
" N_simul = len(s_path)\n",
"\n",
" # Useful variables\n",
" n = len(y)\n",
" y.shape = (n, 1)\n",
" v = np.linalg.inv(np.eye(n) - β * P) @ y\n",
"\n",
" # Store consumption and debt path\n",
" b_path, c_path = np.ones(N_simul+1), np.ones(N_simul)\n",
" b_path[0] = b0\n",
"\n",
" # Optimal decisions from (12) and (13)\n",
" db = ((1 - β) * v - y) / β\n",
"\n",
" for i, s in enumerate(s_path):\n",
" c_path[i] = (1 - β) * (v - np.full((n, 1), b_path[i]))[s, 0]\n",
" b_path[i + 1] = b_path[i] + db[s, 0]\n",
"\n",
" return c_path, b_path[:-1], y[s_path]"
]
},
{
"cell_type": "markdown",
"id": "9847690e",
"metadata": {},
"source": [
"Let’s test by checking that $ \\bar c $ and $ b_2 $ satisfy the budget constraint"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "06b7e0c5",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"cp = ConsumptionProblem()\n",
"c_bar, b = consumption_complete(cp)\n",
"np.isclose(c_bar + b[1] - cp.y[1] - (cp.β * cp.P)[1, :] @ b, 0)"
]
},
{
"cell_type": "markdown",
"id": "7dcb8dae",
"metadata": {},
"source": [
"Below, we’ll take the outcomes produced by this code – in particular the implied\n",
"consumption and debt paths – and compare them with outcomes\n",
"from an incomplete markets model in the spirit of Hall [[Hal78](https://python-advanced.quantecon.org/zreferences.html#id152)]"
]
},
{
"cell_type": "markdown",
"id": "862dec01",
"metadata": {},
"source": [
"## Model 2 (One-Period Risk-Free Debt Only)\n",
"\n",
"This is a version of the original model of Hall (1978)\n",
"in which the consumer’s ability to substitute intertemporally is\n",
"constrained by his ability to buy or sell only one security, a risk-free\n",
"one-period bond bearing a constant gross interest rate that equals\n",
"$ \\beta^{-1} $.\n",
"\n",
"Given an initial debt $ b_0 $ at time $ 0 $, the\n",
"consumer faces a sequence of budget constraints\n",
"\n",
"$$\n",
"c_t + b_t = y_t + \\beta b_{t+1}, \\quad t \\geq 0\n",
"$$\n",
"\n",
"where $ \\beta $ is the price at time $ t $ of a risk-free claim\n",
"on one unit of time consumption at time $ t+1 $.\n",
"\n",
"First-order conditions for the consumer’s problem are\n",
"\n",
"$$\n",
"\\sum_{j} u'(c_{t+1,j}) P_{ij} = u'(c_{t, i})\n",
"$$\n",
"\n",
"For our assumed quadratic utility function this implies\n",
"\n",
"\n",
"\n",
"$$\n",
"\\sum_j c_{t+1,j} P_{ij} = c_{t,i} \\tag{6.13}\n",
"$$\n",
"\n",
"which for our finite-state Markov setting is Hall’s (1978) conclusion that consumption follows a random walk.\n",
"\n",
"As we saw in our [first lecture on the permanent income model](https://python-intro.quantecon.org/perm_income.html),\n",
"this leads to\n",
"\n",
"\n",
"\n",
"$$\n",
"b_t = \\mathbb E_t \\sum_{j=0}^\\infty \\beta^j y_{t+j} - (1 -\\beta)^{-1} c_t \\tag{6.14}\n",
"$$\n",
"\n",
"and\n",
"\n",
"\n",
"\n",
"$$\n",
"c_t = (1-\\beta)\n",
" \\left[\n",
" \\mathbb E_t \\sum_{j=0}^\\infty \\beta^j y_{t+j} - b_t\n",
" \\right] \\tag{6.15}\n",
"$$\n",
"\n",
"Equation [(6.15)](#equation-cs-10) expresses $ c_t $ as a net interest rate factor $ 1 - \\beta $ times the sum\n",
"of the expected present value of nonfinancial income $ \\mathbb E_t \\sum_{j=0}^\\infty \\beta^j y_{t+j} $ and financial wealth $ -b_t $.\n",
"\n",
"Substituting [(6.15)](#equation-cs-10) into the one-period budget constraint and rearranging leads to\n",
"\n",
"\n",
"\n",
"$$\n",
"b_{t+1} - b_t\n",
"= \\beta^{-1} \\left[ (1-\\beta)\n",
"\\mathbb E_t \\sum_{j=0}^\\infty\\beta^j y_{t+j} - y_t \\right] \\tag{6.16}\n",
"$$\n",
"\n",
"Now let’s calculate the key term $ \\mathbb E_t \\sum_{j=0}^\\infty\\beta^j y_{t+j} $ in our finite Markov chain setting.\n",
"\n",
"Define the expected discounted present value of non-financial income\n",
"\n",
"$$\n",
"v_t := \\mathbb E_t \\sum_{j=0}^\\infty \\beta^j y_{t+j}\n",
"$$\n",
"\n",
"which in the spirit of dynamic programming we can write as a *Bellman equation*\n",
"\n",
"$$\n",
"v_t := y_t + \\beta \\mathbb E_t v_{t+1}\n",
"$$\n",
"\n",
"In our two-state Markov chain setting, $ v_t = v(1) $ when $ s_t= 1 $ and $ v_t = v(2) $ when $ s_t=2 $.\n",
"\n",
"Therefore, we can write our Bellman equation as\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
" v(1) & = y(1) + \\beta P_{11} v(1) + \\beta P_{12} v(2)\n",
" \\\\\n",
" v(2) & = y(2) + \\beta P_{21} v(1) + \\beta P_{22} v(2)\n",
"\\end{aligned}\n",
"$$\n",
"\n",
"or\n",
"\n",
"$$\n",
"\\vec v = \\vec y + \\beta P \\vec v\n",
"$$\n",
"\n",
"where $ \\vec v = \\begin{bmatrix} v(1) \\cr v(2) \\end{bmatrix} $ and $ \\vec y = \\begin{bmatrix} y(1) \\cr y(2) \\end{bmatrix} $.\n",
"\n",
"We can also write the last expression as\n",
"\n",
"$$\n",
"\\vec v = (I - \\beta P)^{-1} \\vec y\n",
"$$\n",
"\n",
"In our finite Markov chain setting, from expression [(6.15)](#equation-cs-10), consumption at date $ t $ when debt is $ b_t $ and the Markov state today is $ s_t = i $ is evidently\n",
"\n",
"\n",
"\n",
"$$\n",
"c(b_t, i) = (1 - \\beta) \\left( [(I - \\beta P)^{-1} \\vec y]_i - b_t \\right) \\tag{6.17}\n",
"$$\n",
"\n",
"and the increment to debt is\n",
"\n",
"\n",
"\n",
"$$\n",
"b_{t+1} - b_t = \\beta^{-1} [ (1- \\beta) v(i) - y(i) ] \\tag{6.18}\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "11411cb0",
"metadata": {},
"source": [
"### Summary of Outcomes\n",
"\n",
"In contrast to outcomes in the complete markets model, in the incomplete\n",
"markets model\n",
"\n",
"- consumption drifts over time as a random walk; the level of\n",
" consumption at time $ t $ depends on the level of debt that the\n",
" consumer brings into the period as well as the expected discounted\n",
" present value of nonfinancial income at $ t $. \n",
"- the consumer’s debt drifts upward over time in response to low\n",
" realizations of nonfinancial income and drifts downward over time in\n",
" response to high realizations of nonfinancial income. \n",
"- the drift over time in the consumer’s debt and the dependence of\n",
" current consumption on today’s debt level account for the drift over\n",
" time in consumption. "
]
},
{
"cell_type": "markdown",
"id": "3d02e856",
"metadata": {},
"source": [
"### The Incomplete Markets Model\n",
"\n",
"The code above also contains a function called `consumption_incomplete()` that uses [(6.17)](#equation-cs-12) and [(6.18)](#equation-cs-13) to\n",
"\n",
"- simulate paths of $ y_t, c_t, b_{t+1} $ \n",
"- plot these against values of $ \\bar c, b(s_1), b(s_2) $ found in a corresponding complete markets economy \n",
"\n",
"\n",
"Let’s try this, using the same parameters in both complete and incomplete markets economies"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cc61b77e",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"cp = ConsumptionProblem()\n",
"s_path = cp.simulate()\n",
"N_simul = len(s_path)\n",
"\n",
"c_bar, debt_complete = consumption_complete(cp)\n",
"\n",
"c_path, debt_path, y_path = consumption_incomplete(cp, s_path)\n",
"\n",
"fig, ax = plt.subplots(1, 2, figsize=(14, 4))\n",
"\n",
"ax[0].set_title('Consumption paths')\n",
"ax[0].plot(np.arange(N_simul), c_path, label='incomplete market')\n",
"ax[0].plot(np.arange(N_simul), np.full(N_simul, c_bar),\n",
" label='complete market')\n",
"ax[0].plot(np.arange(N_simul), y_path, label='income', alpha=.6, ls='--')\n",
"ax[0].legend()\n",
"ax[0].set_xlabel('Periods')\n",
"\n",
"ax[1].set_title('Debt paths')\n",
"ax[1].plot(np.arange(N_simul), debt_path, label='incomplete market')\n",
"ax[1].plot(np.arange(N_simul), debt_complete[s_path],\n",
" label='complete market')\n",
"ax[1].plot(np.arange(N_simul), y_path, label='income', alpha=.6, ls='--')\n",
"ax[1].legend()\n",
"ax[1].axhline(0, color='k', ls='--')\n",
"ax[1].set_xlabel('Periods')\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "ceed0903",
"metadata": {},
"source": [
"In the graph on the left, for the same sample path of nonfinancial\n",
"income $ y_t $, notice that\n",
"\n",
"- consumption is constant when there are complete markets, but takes a random walk in the incomplete markets version of the model. \n",
"- the consumer’s debt oscillates between two values that are functions\n",
" of the Markov state in the complete markets model, while the\n",
" consumer’s debt drifts in a “unit root” fashion in the incomplete\n",
" markets economy. "
]
},
{
"cell_type": "markdown",
"id": "1d03c9cd",
"metadata": {},
"source": [
"### A sequel\n",
"\n",
"In [tax smoothing with complete and incomplete markets](https://python-advanced.quantecon.org/smoothing_tax.html), we reinterpret the mathematics and Python code presented in this lecture in order\n",
"to construct tax-smoothing models in the incomplete markets tradition of Barro [[Bar79](https://python-advanced.quantecon.org/zreferences.html#id136)] as well as in the complete markets tradition of Lucas and Stokey [[LS83](https://python-advanced.quantecon.org/zreferences.html#id176)]."
]
}
],
"metadata": {
"date": 1699230685.18526,
"filename": "smoothing.md",
"kernelspec": {
"display_name": "Python",
"language": "python3",
"name": "python3"
},
"title": "Consumption Smoothing with Complete and Incomplete Markets"
},
"nbformat": 4,
"nbformat_minor": 5
}