{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f492a5b5",
   "metadata": {},
   "source": [
    "# Present Values"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c8f25bd0",
   "metadata": {},
   "source": [
    "## Overview\n",
    "\n",
    "This lecture describes the  **present value model** that is a starting point\n",
    "of much asset pricing theory.\n",
    "\n",
    "Asset pricing theory is a component of theories about many economic decisions including\n",
    "\n",
    "- consumption  \n",
    "- labor supply  \n",
    "- education choice  \n",
    "- demand for money  \n",
    "\n",
    "\n",
    "In asset pricing theory, and in economic dynamics more generally, a basic topic is the relationship\n",
    "among different **time series**.\n",
    "\n",
    "A **time series** is a **sequence** indexed by time.\n",
    "\n",
    "In this lecture, we’ll represent  a sequence as a vector.\n",
    "\n",
    "So our analysis will typically boil down to studying relationships among vectors.\n",
    "\n",
    "Our main  tools in this lecture will be\n",
    "\n",
    "- matrix multiplication,  and  \n",
    "- matrix inversion.  \n",
    "\n",
    "\n",
    "We’ll use the calculations described here in  subsequent lectures, including [consumption smoothing](https://intro.quantecon.org/cons_smooth.html), [equalizing difference model](https://intro.quantecon.org/equalizing_difference.html), and\n",
    "[monetarist theory of price levels](https://intro.quantecon.org/cagan_ree.html).\n",
    "\n",
    "Let’s dive in."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2248ac2b",
   "metadata": {},
   "source": [
    "## Analysis\n",
    "\n",
    "Let\n",
    "\n",
    "- $ \\{d_t\\}_{t=0}^T $ be a sequence of dividends or “payouts”  \n",
    "- $ \\{p_t\\}_{t=0}^T $ be a sequence of prices of a claim on the continuation of\n",
    "  the asset’s payout  stream from date $ t $ on, namely, $ \\{d_s\\}_{s=t}^T $  \n",
    "- $ \\delta  \\in (0,1) $ be a one-period “discount factor”  \n",
    "- $ p_{T+1}^* $ be a terminal price of the asset at time $ T+1 $  \n",
    "\n",
    "\n",
    "We  assume that the dividend stream $ \\{d_t\\}_{t=0}^T $ and the terminal price\n",
    "$ p_{T+1}^* $ are both exogenous.\n",
    "\n",
    "This means that they are determined outside the model.\n",
    "\n",
    "Assume the sequence of asset pricing equations\n",
    "\n",
    "\n",
    "<a id='equation-eq-euler1'></a>\n",
    "$$\n",
    "p_t = d_t + \\delta p_{t+1}, \\quad t = 0, 1, \\ldots , T \\tag{11.1}\n",
    "$$\n",
    "\n",
    "We say equation**s**, plural, because there are $ T+1 $ equations, one for each $ t =0, 1, \\ldots, T $.\n",
    "\n",
    "Equations [(11.1)](#equation-eq-euler1) assert that price paid to purchase  the asset at time $ t $  equals the payout $ d_t $  plus the price at time  $ t+1 $ multiplied by a time discount factor $ \\delta $.\n",
    "\n",
    "Discounting tomorrow’s price  by multiplying it by  $ \\delta $ accounts for the “value of waiting one period”.\n",
    "\n",
    "We want to solve the system of $ T+1 $ equations [(11.1)](#equation-eq-euler1) for the asset price sequence  $ \\{p_t\\}_{t=0}^T $ as a function of the dividend sequence $ \\{d_t\\}_{t=0}^T $ and the exogenous terminal\n",
    "price  $ p_{T+1}^* $.\n",
    "\n",
    "A system of equations like [(11.1)](#equation-eq-euler1) is an example of a linear  **difference equation**.\n",
    "\n",
    "There are powerful mathematical  methods available for solving such systems and they are well worth\n",
    "studying in their own right, being the foundation for the analysis of many interesting economic models.\n",
    "\n",
    "For an example, see [Samuelson multiplier-accelerator](https://dynamics.quantecon.org/samuelson.html)\n",
    "\n",
    "In this lecture, we’ll  solve system [(11.1)](#equation-eq-euler1) using matrix multiplication and matrix inversion, basic tools from linear algebra introduced in  [linear equations and matrix algebra](https://intro.quantecon.org/linear_equations.html).\n",
    "\n",
    "We will use the following imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "04099fd8",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2ad94550",
   "metadata": {},
   "source": [
    "## Representing sequences as vectors\n",
    "\n",
    "The equations in system [(11.1)](#equation-eq-euler1) can be arranged as follows:\n",
    "\n",
    "\n",
    "<a id='equation-eq-euler-stack'></a>\n",
    "$$\n",
    "\\begin{aligned}\n",
    "    p_0 & = d_0 + \\delta p_1 \\\\\n",
    "    p_1 & = d_1 + \\delta p_2 \\\\\n",
    "    \\vdots \\\\\n",
    "    p_{T-1} & = d_{T-1} + \\delta p_T \\\\\n",
    "    p_T & = d_T + \\delta p^*_{T+1}\n",
    "\\end{aligned} \\tag{11.2}\n",
    "$$\n",
    "\n",
    "Write the system [(11.2)](#equation-eq-euler-stack) of $ T+1 $ asset pricing  equations as the single matrix equation\n",
    "\n",
    "\n",
    "<a id='equation-eq-pvpieq'></a>\n",
    "$$\n",
    "\\begin{bmatrix} 1 & -\\delta & 0 & 0 & \\cdots & 0 & 0 \\cr\n",
    "                    0 & 1 & -\\delta & 0 & \\cdots & 0 & 0 \\cr\n",
    "                    0 & 0 & 1 & -\\delta & \\cdots & 0 & 0 \\cr\n",
    "                    \\vdots & \\vdots & \\vdots & \\vdots & \\vdots & 0 & 0 \\cr\n",
    "                    0 & 0 & 0 & 0 & \\cdots & 1 & -\\delta \\cr\n",
    "                    0 & 0 & 0 & 0 & \\cdots & 0 & 1 \\end{bmatrix}\n",
    "    \\begin{bmatrix} p_0 \\cr p_1 \\cr p_2 \\cr \\vdots \\cr p_{T-1} \\cr p_T \n",
    "    \\end{bmatrix} \n",
    "    =  \\begin{bmatrix}  \n",
    "    d_0 \\cr d_1 \\cr d_2 \\cr \\vdots \\cr d_{T-1} \\cr d_T\n",
    "    \\end{bmatrix}\n",
    "    + \\begin{bmatrix} \n",
    "    0 \\cr 0 \\cr 0 \\cr \\vdots \\cr 0 \\cr \\delta p_{T+1}^*\n",
    "    \\end{bmatrix} \\tag{11.3}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a8c7eeb",
   "metadata": {},
   "source": [
    "## Exercise 11.1\n",
    "\n",
    "Carry out the matrix multiplication in [(11.3)](#equation-eq-pvpieq) by hand and confirm that you\n",
    "recover the equations in [(11.2)](#equation-eq-euler-stack).\n",
    "\n",
    "In vector-matrix notation, we can write  system [(11.3)](#equation-eq-pvpieq) as\n",
    "\n",
    "\n",
    "<a id='equation-eq-apdb'></a>\n",
    "$$\n",
    "A p = d + b \\tag{11.4}\n",
    "$$\n",
    "\n",
    "Here $ A $ is the matrix on the left side of equation [(11.3)](#equation-eq-pvpieq), while\n",
    "\n",
    "$$\n",
    "p = \n",
    "    \\begin{bmatrix}\n",
    "        p_0 \\\\\n",
    "        p_1 \\\\\n",
    "        \\vdots \\\\\n",
    "        p_T\n",
    "    \\end{bmatrix},\n",
    "    \\quad\n",
    "    d = \n",
    "    \\begin{bmatrix}\n",
    "        d_0 \\\\\n",
    "        d_1 \\\\\n",
    "        \\vdots \\\\\n",
    "        d_T\n",
    "    \\end{bmatrix},\n",
    "    \\quad \\text{and} \\quad\n",
    "    b = \n",
    "    \\begin{bmatrix}\n",
    "        0 \\\\\n",
    "        0 \\\\\n",
    "        \\vdots \\\\\n",
    "        \\delta p^*_{T+1}\n",
    "    \\end{bmatrix}\n",
    "$$\n",
    "\n",
    "The solution for the vector of  prices is\n",
    "\n",
    "\n",
    "<a id='equation-eq-apdb-sol'></a>\n",
    "$$\n",
    "p = A^{-1}(d + b) \\tag{11.5}\n",
    "$$\n",
    "\n",
    "For example, suppose that  the dividend stream is\n",
    "\n",
    "$$\n",
    "d_{t+1} = 1.05 d_t, \\quad t = 0, 1, \\ldots , T-1.\n",
    "$$\n",
    "\n",
    "Let’s write Python code to compute and plot the dividend stream."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6c75c4d7",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "T = 6\n",
    "current_d = 1.0\n",
    "d = []\n",
    "for t in range(T+1):\n",
    "    d.append(current_d)\n",
    "    current_d = current_d * 1.05 \n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "ax.plot(d, 'o', label='dividends')\n",
    "ax.legend()\n",
    "ax.set_xlabel('time')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "356058ac",
   "metadata": {},
   "source": [
    "Now let’s compute and plot the asset price.\n",
    "\n",
    "We set $ \\delta $ and $ p_{T+1}^* $ to"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7568626a",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "δ = 0.99\n",
    "p_star = 10.0"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a96f7ac9",
   "metadata": {},
   "source": [
    "Let’s build the matrix $ A $"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5599cce7",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "A = np.zeros((T+1, T+1))\n",
    "for i in range(T+1):\n",
    "    for j in range(T+1):\n",
    "        if i == j:\n",
    "            A[i, j] = 1\n",
    "            if j < T:\n",
    "                A[i, j+1] = -δ"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0b8a3dd",
   "metadata": {},
   "source": [
    "Let’s inspect $ A $"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3496465b",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "A"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "331e5c6e",
   "metadata": {},
   "source": [
    "Now let’s solve for prices using [(11.5)](#equation-eq-apdb-sol)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fe7c662d",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "b = np.zeros(T+1)\n",
    "b[-1] = δ * p_star\n",
    "p = np.linalg.solve(A, d + b)\n",
    "fig, ax = plt.subplots()\n",
    "ax.plot(p, 'o', label='asset price')\n",
    "ax.legend()\n",
    "ax.set_xlabel('time')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "561913a9",
   "metadata": {},
   "source": [
    "Now let’s consider  a cyclically growing dividend sequence:\n",
    "\n",
    "$$\n",
    "d_{t+1} = 1.01 d_t + 0.1 \\sin t, \\quad t = 0, 1, \\ldots , T-1.\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3ad0107a",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "T = 100\n",
    "current_d = 1.0\n",
    "d = []\n",
    "for t in range(T+1):\n",
    "    d.append(current_d)\n",
    "    current_d = current_d * 1.01 + 0.1 * np.sin(t)\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "ax.plot(d, 'o-', ms=4, alpha=0.8, label='dividends')\n",
    "ax.legend()\n",
    "ax.set_xlabel('time')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c23242dc",
   "metadata": {},
   "source": [
    "## Exercise 11.2\n",
    "\n",
    "Compute the corresponding asset price sequence when $ p^*_{T+1} = 0 $ and $ \\delta\n",
    "= 0.98 $."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f41dbe2",
   "metadata": {},
   "source": [
    "## Solution to[ Exercise 11.2](https://intro.quantecon.org/#pv_ex_cyc)\n",
    "\n",
    "We proceed as above after modifying parameters and consequently the matrix $ A $."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b6e16fb",
   "metadata": {
    "hide-output": false
   },
   "outputs": [],
   "source": [
    "δ = 0.98\n",
    "p_star = 0.0\n",
    "A = np.zeros((T+1, T+1))\n",
    "for i in range(T+1):\n",
    "    for j in range(T+1):\n",
    "        if i == j:\n",
    "            A[i, j] = 1\n",
    "            if j < T:\n",
    "                A[i, j+1] = -δ\n",
    "\n",
    "b = np.zeros(T+1)\n",
    "b[-1] = δ * p_star\n",
    "p = np.linalg.solve(A, d + b)\n",
    "fig, ax = plt.subplots()\n",
    "ax.plot(p, 'o-', ms=4, alpha=0.8, label='asset price')\n",
    "ax.legend()\n",
    "ax.set_xlabel('time')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bdfbaf86",
   "metadata": {},
   "source": [
    "The weighted averaging associated with the present value calculation largely\n",
    "eliminates the cycles."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f035f66",
   "metadata": {},
   "source": [
    "## Analytical expressions\n",
    "\n",
    "By the [inverse matrix theorem](https://en.wikipedia.org/wiki/Invertible_matrix), a matrix $ B $ is the inverse of $ A $ whenever $ A B $ is the identity.\n",
    "\n",
    "It can be verified that the  inverse of the matrix $ A $ in [(11.3)](#equation-eq-pvpieq) is\n",
    "\n",
    "\n",
    "<a id='equation-eq-ainv'></a>\n",
    "$$\n",
    "A^{-1} = \n",
    "    \\begin{bmatrix}\n",
    "        1 & \\delta & \\delta^2 & \\cdots & \\delta^{T-1} & \\delta^T \\cr\n",
    "        0 & 1 & \\delta & \\cdots & \\delta^{T-2} & \\delta^{T-1} \\cr\n",
    "        \\vdots & \\vdots & \\vdots & \\cdots & \\vdots & \\vdots \\cr\n",
    "        0 & 0 & 0 & \\cdots & 1  & \\delta \\cr\n",
    "        0 & 0 & 0 & \\cdots & 0 & 1 \\cr\n",
    "    \\end{bmatrix} \\tag{11.6}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f8f5854",
   "metadata": {},
   "source": [
    "## Exercise 11.3\n",
    "\n",
    "Check this by showing that $ A A^{-1} $ is equal to the identity matrix.\n",
    "\n",
    "If we use the expression [(11.6)](#equation-eq-ainv) in [(11.5)](#equation-eq-apdb-sol) and perform the indicated matrix multiplication, we shall find  that\n",
    "\n",
    "\n",
    "<a id='equation-eq-ptpveq'></a>\n",
    "$$\n",
    "p_t =  \\sum_{s=t}^T \\delta^{s-t} d_s +  \\delta^{T+1-t} p_{T+1}^* \\tag{11.7}\n",
    "$$\n",
    "\n",
    "Pricing formula [(11.7)](#equation-eq-ptpveq) asserts that  two components sum to the asset price\n",
    "$ p_t $:\n",
    "\n",
    "- a **fundamental component** $ \\sum_{s=t}^T \\delta^{s-t} d_s $ that equals the **discounted present value** of prospective dividends  \n",
    "- a **bubble component** $ \\delta^{T+1-t} p_{T+1}^* $  \n",
    "\n",
    "\n",
    "The fundamental component is pinned down by the discount factor $ \\delta $ and the\n",
    "payout of the asset (in this case,  dividends).\n",
    "\n",
    "The bubble component is the part of the price that is not pinned down by\n",
    "fundamentals.\n",
    "\n",
    "It is sometimes convenient to rewrite the bubble component as\n",
    "\n",
    "$$\n",
    "c \\delta^{-t}\n",
    "$$\n",
    "\n",
    "where\n",
    "\n",
    "$$\n",
    "c \\equiv \\delta^{T+1}p_{T+1}^*\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b17fed97",
   "metadata": {},
   "source": [
    "## More about bubbles\n",
    "\n",
    "For a few moments, let’s focus on  the special case of an asset that   never pays dividends, in which case\n",
    "\n",
    "$$\n",
    "\\begin{bmatrix}  \n",
    "d_0 \\cr d_1 \\cr d_2 \\cr \\vdots \\cr d_{T-1} \\cr d_T\n",
    "\\end{bmatrix} = \n",
    "\\begin{bmatrix}  \n",
    "0 \\cr 0 \\cr 0 \\cr \\vdots \\cr 0 \\cr 0\n",
    "\\end{bmatrix}\n",
    "$$\n",
    "\n",
    "In this case  system [(11.1)](#equation-eq-euler1) of our $ T+1 $ asset pricing  equations takes the\n",
    "form of the single matrix equation\n",
    "\n",
    "\n",
    "<a id='equation-eq-pieq2'></a>\n",
    "$$\n",
    "\\begin{bmatrix} 1 & -\\delta & 0 & 0 & \\cdots & 0 & 0 \\cr\n",
    "                0 & 1 & -\\delta & 0 & \\cdots & 0 & 0 \\cr\n",
    "                0 & 0 & 1 & -\\delta & \\cdots & 0 & 0 \\cr\n",
    "                \\vdots & \\vdots & \\vdots & \\vdots & \\vdots & 0 & 0 \\cr\n",
    "                0 & 0 & 0 & 0 & \\cdots & 1 & -\\delta \\cr\n",
    "                0 & 0 & 0 & 0 & \\cdots & 0 & 1 \\end{bmatrix}\n",
    "\\begin{bmatrix} p_0 \\cr p_1 \\cr p_2 \\cr \\vdots \\cr p_{T-1} \\cr p_T \n",
    "\\end{bmatrix}  =\n",
    "\\begin{bmatrix} \n",
    "0 \\cr 0 \\cr 0 \\cr \\vdots \\cr 0 \\cr \\delta p_{T+1}^*\n",
    "\\end{bmatrix} \\tag{11.8}\n",
    "$$\n",
    "\n",
    "Evidently, if $ p_{T+1}^* = 0 $, a price vector $ p $ of all entries zero\n",
    "solves this equation and the only the **fundamental** component of our pricing\n",
    "formula [(11.7)](#equation-eq-ptpveq) is present.\n",
    "\n",
    "But let’s activate the **bubble**  component by setting\n",
    "\n",
    "\n",
    "<a id='equation-eq-eqbubbleterm'></a>\n",
    "$$\n",
    "p_{T+1}^* = c \\delta^{-(T+1)} \\tag{11.9}\n",
    "$$\n",
    "\n",
    "for some positive constant $ c $.\n",
    "\n",
    "In this case,  when we multiply both sides of [(11.8)](#equation-eq-pieq2) by\n",
    "the matrix $ A^{-1} $ presented in equation [(11.6)](#equation-eq-ainv), we\n",
    "find that\n",
    "\n",
    "\n",
    "<a id='equation-eq-bubble'></a>\n",
    "$$\n",
    "p_t = c \\delta^{-t} \\tag{11.10}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9d594f46",
   "metadata": {},
   "source": [
    "## Gross rate of return\n",
    "\n",
    "Define the gross rate of return on holding the asset from period $ t $ to period $ t+1 $\n",
    "as\n",
    "\n",
    "\n",
    "<a id='equation-eq-rateofreturn'></a>\n",
    "$$\n",
    "R_t = \\frac{p_{t+1}}{p_t} \\tag{11.11}\n",
    "$$\n",
    "\n",
    "Substituting equation [(11.10)](#equation-eq-bubble) into equation [(11.11)](#equation-eq-rateofreturn) confirms that an asset whose  sole source of value is a bubble  earns a  gross rate of return\n",
    "\n",
    "$$\n",
    "R_t = \\delta^{-1} > 1 , t = 0, 1, \\ldots, T\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f1ef248",
   "metadata": {},
   "source": [
    "## Exercises"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2448402a",
   "metadata": {},
   "source": [
    "## Exercise 11.4\n",
    "\n",
    "Assume that $ g >1 $ and that $ \\delta g \\in (0,1) $. Give analytical expressions for an asset price $ p_t $ under the\n",
    "following settings for $ d $ and $ p_{T+1}^* $:\n",
    "\n",
    "1. $ p_{T+1}^* = 0, d_t = g^t d_0 $ (a modified version of the Gordon growth formula)  \n",
    "1. $ p_{T+1}^* = \\frac{g^{T+1} d_0}{1- \\delta g},  d_t = g^t d_0 $ (the plain vanilla  Gordon growth formula)  \n",
    "1. $ p_{T+1}^* = 0, d_t = 0 $ (price of a worthless stock)  \n",
    "1. $ p_{T+1}^* = c \\delta^{-(T+1)}, d_t = 0 $ (price of a pure bubble stock)  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "75815fd2",
   "metadata": {},
   "source": [
    "## Solution to[ Exercise 11.4](https://intro.quantecon.org/#pv_ex_a)\n",
    "\n",
    "Plugging each of the above $ p_{T+1}^*, d_t $  pairs into Equation [(11.7)](#equation-eq-ptpveq) yields:\n",
    "\n",
    "1. $ p_t = \\sum^T_{s=t} \\delta^{s-t} g^s d_0     = d_t \\frac{1 - (\\delta g)^{T+1-t}}{1 - \\delta g} $  \n",
    "1. $ p_t = \\sum^T_{s=t} \\delta^{s-t} g^s d_0 + \\frac{\\delta^{T+1-t} g^{T+1} d_0}{1 - \\delta g} =  \\frac{d_t}{1 - \\delta g} $  \n",
    "1. $ p_t = 0 $  \n",
    "1. $ p_t = c \\delta^{-t} $  "
   ]
  }
 ],
 "metadata": {
  "date": 1750038457.5964725,
  "filename": "pv.md",
  "kernelspec": {
   "display_name": "Python",
   "language": "python3",
   "name": "python3"
  },
  "title": "Present Values"
 },
 "nbformat": 4,
 "nbformat_minor": 5
}