{ "cells": [ { "cell_type": "markdown", "id": "f1cf0fee", "metadata": {}, "source": [ "\n", "" ] }, { "cell_type": "markdown", "id": "a6efe602", "metadata": {}, "source": [ "# Rational Expectations Equilibrium" ] }, { "cell_type": "markdown", "id": "3976008a", "metadata": {}, "source": [ "## Contents\n", "\n", "- [Rational Expectations Equilibrium](#Rational-Expectations-Equilibrium) \n", " - [Overview](#Overview) \n", " - [Rational Expectations Equilibrium](#Rational-Expectations-Equilibrium) \n", " - [Computing an Equilibrium](#Computing--an-Equilibrium) \n", " - [Exercises](#Exercises) " ] }, { "cell_type": "markdown", "id": "64f9fcef", "metadata": {}, "source": [ "> “If you’re so smart, why aren’t you rich?”\n", "\n", "\n", "In addition to what’s in Anaconda, this lecture will need the following libraries:" ] }, { "cell_type": "code", "execution_count": null, "id": "f0c4c588", "metadata": { "hide-output": false }, "outputs": [], "source": [ "!pip install quantecon" ] }, { "cell_type": "markdown", "id": "38ea0988", "metadata": {}, "source": [ "## Overview\n", "\n", "This lecture introduces the concept of a *rational expectations equilibrium*.\n", "\n", "To illustrate it, we describe a linear quadratic version of a model\n", "due to Lucas and Prescott [[LP71](https://python.quantecon.org/zreferences.html#id185)].\n", "\n", "That 1971 paper is one of a small number of research articles that ignited a *rational expectations revolution*.\n", "\n", "We follow Lucas and Prescott by employing a setting that is readily “Bellmanized” (i.e., susceptible to being formulated as a dynamic programming problems.\n", "\n", "Because we use linear quadratic setups for demand and costs, we can deploy the LQ programming techniques described in [this lecture](https://python.quantecon.org/lqcontrol.html).\n", "\n", "We will learn about how a representative agent’s problem differs from a planner’s, and how a planning problem can be used to compute quantities and prices in a rational expectations\n", "equilibrium.\n", "\n", "We will also learn about how a rational expectations equilibrium can be characterized as a [fixed point](https://en.wikipedia.org/wiki/Fixed_point_%28mathematics%29) of a mapping from a *perceived law of motion* to an *actual law of motion*.\n", "\n", "Equality between a perceived and an actual law of motion for endogenous market-wide objects captures in a nutshell what the rational expectations equilibrium concept is all about.\n", "\n", "Finally, we will learn about the important “Big $K$, little $k$” trick, a modeling device widely used in macroeconomics.\n", "\n", "Except that for us\n", "\n", "- Instead of “Big $K$” it will be “Big $Y$”. \n", "- Instead of “little $k$” it will be “little $y$”. \n", "\n", "\n", "Let’s start with some standard imports:" ] }, { "cell_type": "code", "execution_count": null, "id": "96cbdd24", "metadata": { "hide-output": false }, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "plt.rcParams[\"figure.figsize\"] = (11, 5) #set default figure size\n", "import numpy as np" ] }, { "cell_type": "markdown", "id": "dc456430", "metadata": {}, "source": [ "We’ll also use the LQ class from QuantEcon.py." ] }, { "cell_type": "code", "execution_count": null, "id": "712a2d5a", "metadata": { "hide-output": false }, "outputs": [], "source": [ "from quantecon import LQ" ] }, { "cell_type": "markdown", "id": "1f430d97", "metadata": {}, "source": [ "### The Big Y, little y Trick\n", "\n", "This widely used method applies in contexts in which a **representative firm** or agent is a “price taker” operating within a competitive equilibrium.\n", "\n", "The following setting justifies the concept of a representative firm that stands in for a large number of other firms too.\n", "\n", "There is a uniform unit measure of identical firms named $\\omega \\in \\Omega = [0,1]$.\n", "\n", "The output of firm $\\omega$ is $y(\\omega)$.\n", "\n", "The output of all firms is $Y = \\int_{0}^1 y(\\omega) d \\, \\omega$.\n", "\n", "All firms end up choosing to produce the same output, so that at the end of the day $y(\\omega) = y$ and $Y =y = \\int_{0}^1 y(\\omega) d \\, \\omega$.\n", "\n", "This setting allows us to speak of a representative firm that chooses to produce $y$.\n", "\n", "We want to impose that\n", "\n", "- The representative firm or individual firm takes *aggregate* $Y$ as given when it chooses individual $y(\\omega)$, but $\\ldots$. \n", "- At the end of the day, $Y = y(\\omega) = y$, so that the representative firm is indeed representative. \n", "\n", "\n", "The Big $Y$, little $y$ trick accomplishes these two goals by\n", "\n", "- Taking $Y$ as beyond control when posing the choice problem of who chooses $y$; but $\\ldots$. \n", "- Imposing $Y = y$ *after* having solved the individual’s optimization problem. \n", "\n", "\n", "Please watch for how this strategy is applied as the lecture unfolds.\n", "\n", "We begin by applying the Big $Y$, little $y$ trick in a very simple static context." ] }, { "cell_type": "markdown", "id": "c1bb8085", "metadata": {}, "source": [ "#### A Simple Static Example of the Big Y, little y Trick\n", "\n", "Consider a static model in which a unit measure of firms produce a homogeneous good that is sold in a competitive market.\n", "\n", "Each of these firms ends up producing and selling output $y (\\omega) = y$.\n", "\n", "The price $p$ of the good lies on an inverse demand curve\n", "\n", "\n", "\n", "$$\n", "p = a_0 - a_1 Y \\tag{70.1}\n", "$$\n", "\n", "where\n", "\n", "- $a_i > 0$ for $i = 0, 1$ \n", "- $Y = \\int_0^1 y(\\omega) d \\omega$ is the market-wide level of output \n", "\n", "\n", "For convenience, we’ll often just write $y$ instead of $y(\\omega)$ when we are describing the choice problem of an individual firm $\\omega \\in \\Omega$.\n", "\n", "Each firm has a total cost function\n", "\n", "$$\n", "c(y) = c_1 y + 0.5 c_2 y^2,\n", "\\qquad c_i > 0 \\text{ for } i = 1,2\n", "$$\n", "\n", "The profits of a representative firm are $p y - c(y)$.\n", "\n", "Using [(70.1)](#equation-ree-comp3d-static), we can express the problem of the representative firm as\n", "\n", "\n", "\n", "$$\n", "\\max_{y} \\Bigl[ (a_0 - a_1 Y) y - c_1 y - 0.5 c_2 y^2 \\Bigr] \\tag{70.2}\n", "$$\n", "\n", "In posing problem [(70.2)](#equation-max-problem-static), we want the firm to be a *price taker*.\n", "\n", "We do that by regarding $p$ and therefore $Y$ as exogenous to the firm.\n", "\n", "The essence of the Big $Y$, little $y$ trick is *not* to set $Y = n y$ *before* taking the first-order condition with respect\n", "to $y$ in problem [(70.2)](#equation-max-problem-static).\n", "\n", "This assures that the firm is a price taker.\n", "\n", "The first-order condition for problem [(70.2)](#equation-max-problem-static) is\n", "\n", "\n", "\n", "$$\n", "a_0 - a_1 Y - c_1 - c_2 y = 0 \\tag{70.3}\n", "$$\n", "\n", "At this point, *but not before*, we substitute $Y = y$ into [(70.3)](#equation-bigysimplefonc)\n", "to obtain the following linear equation\n", "\n", "\n", "\n", "$$\n", "a_0 - c_1 - (a_1 + c_2) Y = 0 \\tag{70.4}\n", "$$\n", "\n", "to be solved for the competitive equilibrium market-wide output $Y$.\n", "\n", "After solving for $Y$, we can compute the competitive equilibrium price $p$ from the inverse demand curve [(70.1)](#equation-ree-comp3d-static)." ] }, { "cell_type": "markdown", "id": "0ed25cfc", "metadata": {}, "source": [ "### Related Planning Problem\n", "\n", "Define **consumer surplus** as the area under the inverse demand curve:\n", "\n", "$$\n", "S_c (Y)= \\int_0^Y (a_0 - a_1 s) ds = a_o Y - \\frac{a_1}{2} Y^2 .\n", "$$\n", "\n", "Define the social cost of production as\n", "\n", "$$\n", "S_p (Y) = c_1 Y + \\frac{c_2}{2} Y^2\n", "$$\n", "\n", "Consider the planning problem\n", "\n", "$$\n", "\\max_{Y} [ S_c(Y) - S_p(Y) ]\n", "$$\n", "\n", "The first-order necessary condition for the planning problem is equation [(70.4)](#equation-staticy).\n", "\n", "Thus, a $Y$ that solves [(70.4)](#equation-staticy) is a competitive equilibrium output as well as an output that solves the planning problem.\n", "\n", "This type of outcome provides an intellectual justification for liking a competitive equilibrium." ] }, { "cell_type": "markdown", "id": "64ea0150", "metadata": {}, "source": [ "### Further Reading\n", "\n", "References for this lecture include\n", "\n", "- [[LP71](https://python.quantecon.org/zreferences.html#id185)] \n", "- [[Sar87](https://python.quantecon.org/zreferences.html#id207)], chapter XIV \n", "- [[LS18](https://python.quantecon.org/zreferences.html#id183)], chapter 7 " ] }, { "cell_type": "markdown", "id": "a1282978", "metadata": {}, "source": [ "## Rational Expectations Equilibrium\n", "\n", "\n", "\n", "Our first illustration of a rational expectations equilibrium involves a market with a unit measure of identical firms, each of which seeks to maximize the discounted present value of profits in the face of adjustment costs.\n", "\n", "The adjustment costs induce the firms to make gradual adjustments, which in turn requires consideration of future prices.\n", "\n", "Individual firms understand that, via the inverse demand curve, the price is determined by the amounts supplied by other firms.\n", "\n", "Hence each firm wants to forecast future total industry output.\n", "\n", "In our context, a forecast is generated by a belief about the law of motion for the aggregate state.\n", "\n", "Rational expectations equilibrium prevails when this belief coincides with the actual\n", "law of motion generated by production choices induced by this belief.\n", "\n", "We formulate a rational expectations equilibrium in terms of a fixed point of an operator that maps beliefs into optimal beliefs.\n", "\n", "\n", "" ] }, { "cell_type": "markdown", "id": "31104d14", "metadata": {}, "source": [ "### Competitive Equilibrium with Adjustment Costs\n", "\n", "\n", "\n", "To illustrate, consider a collection of $n$ firms producing a homogeneous good that is sold in a competitive market.\n", "\n", "Each firm sell output $y_t(\\omega) = y_t$.\n", "\n", "The price $p_t$ of the good lies on the inverse demand curve\n", "\n", "\n", "\n", "$$\n", "p_t = a_0 - a_1 Y_t \\tag{70.5}\n", "$$\n", "\n", "where\n", "\n", "- $a_i > 0$ for $i = 0, 1$ \n", "- $Y_t = \\int_0^1 y_t(\\omega) d \\omega = y_t$ is the market-wide level of output \n", "\n", "\n", "\n", "" ] }, { "cell_type": "markdown", "id": "7f1069b3", "metadata": {}, "source": [ "#### The Firm’s Problem\n", "\n", "Each firm is a price taker.\n", "\n", "While it faces no uncertainty, it does face adjustment costs\n", "\n", "In particular, it chooses a production plan to maximize\n", "\n", "\n", "\n", "$$\n", "\\sum_{t=0}^\\infty \\beta^t r_t \\tag{70.6}\n", "$$\n", "\n", "where\n", "\n", "\n", "\n", "$$\n", "r_t := p_t y_t - \\frac{ \\gamma (y_{t+1} - y_t )^2 }{2},\n", "\\qquad y_0 \\text{ given} \\tag{70.7}\n", "$$\n", "\n", "Regarding the parameters,\n", "\n", "- $\\beta \\in (0,1)$ is a discount factor \n", "- $\\gamma > 0$ measures the cost of adjusting the rate of output \n", "\n", "\n", "Regarding timing, the firm observes $p_t$ and $y_t$ when it chooses $y_{t+1}$ at time $t$.\n", "\n", "To state the firm’s optimization problem completely requires that we specify dynamics for all state variables.\n", "\n", "This includes ones that the firm cares about but does not control like $p_t$.\n", "\n", "We turn to this problem now." ] }, { "cell_type": "markdown", "id": "fe9ca7a2", "metadata": {}, "source": [ "#### Prices and Aggregate Output\n", "\n", "In view of [(70.5)](#equation-ree-comp3d), the firm’s incentive to forecast the market price translates into an incentive to forecast aggregate output $Y_t$.\n", "\n", "Aggregate output depends on the choices of other firms.\n", "\n", "The output $y_t(\\omega)$ of a single firm $\\omega$ has a negligible effect on aggregate output $\\int_0^1 y_t(\\omega) d \\omega$.\n", "\n", "That justifies firms in regarding their forecasts of aggregate output as being unaffected by their own output decisions." ] }, { "cell_type": "markdown", "id": "e2037613", "metadata": {}, "source": [ "#### Representative Firm’s Beliefs\n", "\n", "We suppose the firm believes that market-wide output $Y_t$ follows the law of motion\n", "\n", "\n", "\n", "$$\n", "Y_{t+1} = H(Y_t) \\tag{70.8}\n", "$$\n", "\n", "where $Y_0$ is a known initial condition.\n", "\n", "The *belief function* $H$ is an equilibrium object, and hence remains to be determined." ] }, { "cell_type": "markdown", "id": "4c293c28", "metadata": {}, "source": [ "#### Optimal Behavior Given Beliefs\n", "\n", "For now, let’s fix a particular belief $H$ in [(70.8)](#equation-ree-hlom) and investigate the firm’s response to it.\n", "\n", "Let $v$ be the optimal value function for the firm’s problem given $H$.\n", "\n", "The value function satisfies the Bellman equation\n", "\n", "\n", "\n", "$$\n", "v(y,Y) = \\max_{y'} \\left\\{ a_0 y - a_1 y Y - \\frac{ \\gamma (y' - y)^2}{2} + \\beta v(y', H(Y))\\right\\} \\tag{70.9}\n", "$$\n", "\n", "Let’s denote the firm’s optimal policy function by $h$, so that\n", "\n", "\n", "\n", "$$\n", "y_{t+1} = h(y_t, Y_t) \\tag{70.10}\n", "$$\n", "\n", "where\n", "\n", "\n", "\n", "$$\n", "h(y, Y) := \\textrm{argmax}_{y'}\n", "\\left\\{ a_0 y - a_1 y Y - \\frac{ \\gamma (y' - y)^2}{2} + \\beta v(y', H(Y))\\right\\} \\tag{70.11}\n", "$$\n", "\n", "Evidently $v$ and $h$ both depend on $H$." ] }, { "cell_type": "markdown", "id": "6cd8c351", "metadata": {}, "source": [ "#### Characterization with First-Order Necessary Conditions\n", "\n", "In what follows it will be helpful to have a second characterization of $h$, based on first-order conditions.\n", "\n", "The first-order necessary condition for choosing $y'$ is\n", "\n", "\n", "\n", "$$\n", "-\\gamma (y' - y) + \\beta v_y(y', H(Y) ) = 0 \\tag{70.12}\n", "$$\n", "\n", "An important useful envelope result of Benveniste-Scheinkman [[BS79](https://python.quantecon.org/zreferences.html#id147)] implies that to\n", "differentiate $v$ with respect to $y$ we can naively differentiate\n", "the right side of [(70.9)](#equation-comp4), giving\n", "\n", "$$\n", "v_y(y,Y) = a_0 - a_1 Y + \\gamma (y' - y)\n", "$$\n", "\n", "Substituting this equation into [(70.12)](#equation-comp5) gives the *Euler equation*\n", "\n", "\n", "\n", "$$\n", "-\\gamma (y_{t+1} - y_t) + \\beta [a_0 - a_1 Y_{t+1} + \\gamma (y_{t+2} - y_{t+1} )] =0 \\tag{70.13}\n", "$$\n", "\n", "The firm optimally sets an output path that satisfies [(70.13)](#equation-ree-comp7), taking [(70.8)](#equation-ree-hlom) as given, and subject to\n", "\n", "- the initial conditions for $(y_0, Y_0)$. \n", "- the terminal condition $\\lim_{t \\rightarrow \\infty } \\beta^t y_t v_y(y_{t}, Y_t) = 0$. \n", "\n", "\n", "This last condition is called the *transversality condition*, and acts as a first-order necessary condition “at infinity”.\n", "\n", "A representative firm’s decision rule solves the difference equation [(70.13)](#equation-ree-comp7) subject to the given initial condition $y_0$ and the transversality condition.\n", "\n", "Note that solving the Bellman equation [(70.9)](#equation-comp4) for $v$ and then $h$ in [(70.11)](#equation-ree-opbe) yields\n", "a decision rule that automatically imposes both the Euler equation [(70.13)](#equation-ree-comp7) and the transversality condition." ] }, { "cell_type": "markdown", "id": "a4656f0f", "metadata": {}, "source": [ "#### The Actual Law of Motion for Output\n", "\n", "As we’ve seen, a given belief translates into a particular decision rule $h$.\n", "\n", "Recalling that in equilbrium $Y_t = y_t$, the *actual law of motion* for market-wide output is then\n", "\n", "\n", "\n", "$$\n", "Y_{t+1} = h(Y_t, Y_t) \\tag{70.14}\n", "$$\n", "\n", "Thus, when firms believe that the law of motion for market-wide output is [(70.8)](#equation-ree-hlom), their optimizing behavior makes the actual law of motion be [(70.14)](#equation-ree-comp9a).\n", "\n", "\n", "" ] }, { "cell_type": "markdown", "id": "52274fd8", "metadata": {}, "source": [ "### Definition of Rational Expectations Equilibrium\n", "\n", "A *rational expectations equilibrium* or *recursive competitive equilibrium* of the model with adjustment costs is a decision rule $h$ and an aggregate law of motion $H$ such that\n", "\n", "1. Given belief $H$, the map $h$ is the firm’s optimal policy function. \n", "1. The law of motion $H$ satisfies $H(Y)= h(Y,Y)$ for all\n", " $Y$. \n", "\n", "\n", "Thus, a rational expectations equilibrium equates the perceived and actual laws of motion [(70.8)](#equation-ree-hlom) and [(70.14)](#equation-ree-comp9a)." ] }, { "cell_type": "markdown", "id": "6b14db72", "metadata": {}, "source": [ "#### Fixed Point Characterization\n", "\n", "As we’ve seen, the firm’s optimum problem induces a mapping $\\Phi$ from a perceived law of motion $H$ for market-wide output to an actual law of motion $\\Phi(H)$.\n", "\n", "The mapping $\\Phi$ is the composition of two mappings, the first of which maps a perceived law of motion into a decision rule via [(70.9)](#equation-comp4)–[(70.11)](#equation-ree-opbe), the second of which maps a decision rule into an actual law via [(70.14)](#equation-ree-comp9a).\n", "\n", "The $H$ component of a rational expectations equilibrium is a fixed point of $\\Phi$." ] }, { "cell_type": "markdown", "id": "c809822a", "metadata": {}, "source": [ "## Computing an Equilibrium\n", "\n", "\n", "\n", "Now let’s compute a rational expectations equilibrium." ] }, { "cell_type": "markdown", "id": "b3ca0cc5", "metadata": {}, "source": [ "### Failure of Contractivity\n", "\n", "Readers accustomed to dynamic programming arguments might try to address this problem by choosing some guess $H_0$ for the aggregate law of motion and then iterating with $\\Phi$.\n", "\n", "Unfortunately, the mapping $\\Phi$ is not a contraction.\n", "\n", "Indeed, there is no guarantee that direct iterations on $\\Phi$ converge .\n", "\n", "There are examples in which these iterations diverge.\n", "\n", "Fortunately, another method works here.\n", "\n", "The method exploits a connection between equilibrium and Pareto optimality expressed in\n", "the fundamental theorems of welfare economics (see, e.g, [[MCWG95](https://python.quantecon.org/zreferences.html#id190)]).\n", "\n", "Lucas and Prescott [[LP71](https://python.quantecon.org/zreferences.html#id185)] used this method to construct a rational expectations equilibrium.\n", "\n", "Some details follow.\n", "\n", "\n", "" ] }, { "cell_type": "markdown", "id": "6f9e528f", "metadata": {}, "source": [ "### A Planning Problem Approach\n", "\n", "\n", "\n", "Our plan of attack is to match the Euler equations of the market problem with those for a single-agent choice problem.\n", "\n", "As we’ll see, this planning problem can be solved by LQ control ([linear regulator](https://python.quantecon.org/lqcontrol.html)).\n", "\n", "Optimal quantities from the planning problem are rational expectations equilibrium quantities.\n", "\n", "The rational expectations equilibrium price can be obtained as a shadow price in the planning problem.\n", "\n", "We first compute a sum of consumer and producer surplus at time $t$\n", "\n", "\n", "\n", "$$\n", "s(Y_t, Y_{t+1})\n", ":= \\int_0^{Y_t} (a_0 - a_1 x) \\, dx - \\frac{ \\gamma (Y_{t+1} - Y_t)^2}{2} \\tag{70.15}\n", "$$\n", "\n", "The first term is the area under the demand curve, while the second measures the social costs of changing output.\n", "\n", "The *planning problem* is to choose a production plan $\\{Y_t\\}$ to maximize\n", "\n", "$$\n", "\\sum_{t=0}^\\infty \\beta^t s(Y_t, Y_{t+1})\n", "$$\n", "\n", "subject to an initial condition for $Y_0$." ] }, { "cell_type": "markdown", "id": "0ce66662", "metadata": {}, "source": [ "### Solution of Planning Problem\n", "\n", "Evaluating the integral in [(70.15)](#equation-comp10) yields the quadratic form $a_0\n", "Y_t - a_1 Y_t^2 / 2$.\n", "\n", "As a result, the Bellman equation for the planning problem is\n", "\n", "\n", "\n", "$$\n", "V(Y) = \\max_{Y'}\n", "\\left\\{a_0 Y - {a_1 \\over 2} Y^2 - \\frac{ \\gamma (Y' - Y)^2}{2} + \\beta V(Y') \\right\\} \\tag{70.16}\n", "$$\n", "\n", "The associated first-order condition is\n", "\n", "\n", "\n", "$$\n", "-\\gamma (Y' - Y) + \\beta V'(Y') = 0 \\tag{70.17}\n", "$$\n", "\n", "Applying the same Benveniste-Scheinkman formula gives\n", "\n", "$$\n", "V'(Y) = a_0 - a_1 Y + \\gamma (Y' - Y)\n", "$$\n", "\n", "Substituting this into equation [(70.17)](#equation-comp14) and rearranging leads to the Euler\n", "equation\n", "\n", "\n", "\n", "$$\n", "\\beta a_0 + \\gamma Y_t - [\\beta a_1 + \\gamma (1+ \\beta)]Y_{t+1} + \\gamma \\beta Y_{t+2} =0 \\tag{70.18}\n", "$$" ] }, { "cell_type": "markdown", "id": "728a1532", "metadata": {}, "source": [ "### Key Insight\n", "\n", "Return to equation [(70.13)](#equation-ree-comp7) and set $y_t = Y_t$ for all $t$.\n", "\n", "A small amount of algebra will convince you that when $y_t=Y_t$, equations [(70.18)](#equation-comp16) and [(70.13)](#equation-ree-comp7) are identical.\n", "\n", "Thus, the Euler equation for the planning problem matches the second-order difference equation\n", "that we derived by\n", "\n", "1. finding the Euler equation of the representative firm and \n", "1. substituting into it the expression $Y_t = y_t$ that “makes the representative firm be representative”. \n", "\n", "\n", "If it is appropriate to apply the same terminal conditions for these two difference equations, which it is, then we have verified that a solution of the planning problem is also a rational expectations equilibrium quantity sequence.\n", "\n", "It follows that for this example we can compute equilibrium quantities by forming the optimal linear regulator problem corresponding to the Bellman equation [(70.16)](#equation-comp12).\n", "\n", "The optimal policy function for the planning problem is the aggregate law of motion\n", "$H$ that the representative firm faces within a rational expectations equilibrium." ] }, { "cell_type": "markdown", "id": "febc5a69", "metadata": {}, "source": [ "#### Structure of the Law of Motion\n", "\n", "As you are asked to show in the exercises, the fact that the planner’s\n", "problem is an LQ control problem implies an optimal policy — and hence aggregate law\n", "of motion — taking the form\n", "\n", "\n", "\n", "$$\n", "Y_{t+1}\n", "= \\kappa_0 + \\kappa_1 Y_t \\tag{70.19}\n", "$$\n", "\n", "for some parameter pair $\\kappa_0, \\kappa_1$.\n", "\n", "Now that we know the aggregate law of motion is linear, we can see from the\n", "firm’s Bellman equation [(70.9)](#equation-comp4) that the firm’s problem can also be framed as\n", "an LQ problem.\n", "\n", "As you’re asked to show in the exercises, the LQ formulation of the firm’s\n", "problem implies a law of motion that looks as follows\n", "\n", "\n", "\n", "$$\n", "y_{t+1} = h_0 + h_1 y_t + h_2 Y_t \\tag{70.20}\n", "$$\n", "\n", "Hence a rational expectations equilibrium will be defined by the parameters\n", "$(\\kappa_0, \\kappa_1, h_0, h_1, h_2)$ in [(70.19)](#equation-ree-hlom2)–[(70.20)](#equation-ree-ex5)." ] }, { "cell_type": "markdown", "id": "9cbeddf3", "metadata": {}, "source": [ "## Exercises" ] }, { "cell_type": "markdown", "id": "1b7b5d15", "metadata": {}, "source": [ "## Exercise 70.1\n", "\n", "Consider the firm problem [described above](#ree-fp).\n", "\n", "Let the firm’s belief function $H$ be as given in [(70.19)](#equation-ree-hlom2).\n", "\n", "Formulate the firm’s problem as a discounted optimal linear regulator problem, being careful to describe all of the objects needed.\n", "\n", "Use the class LQ from the [QuantEcon.py](http://quantecon.org/quantecon-py) package to solve the firm’s problem for the following parameter values:\n", "\n", "$$\n", "a_0= 100, a_1= 0.05, \\beta = 0.95, \\gamma=10, \\kappa_0 = 95.5, \\kappa_1 = 0.95\n", "$$\n", "\n", "Express the solution of the firm’s problem in the form [(70.20)](#equation-ree-ex5) and give the values for each $h_j$.\n", "\n", "If there were a unit measure of identical competitive firms all behaving according to [(70.20)](#equation-ree-ex5), what would [(70.20)](#equation-ree-ex5) imply for the *actual* law of motion [(70.8)](#equation-ree-hlom) for market supply." ] }, { "cell_type": "markdown", "id": "fdebe06b", "metadata": {}, "source": [ "## Solution to[ Exercise 70.1](https://python.quantecon.org/#ree_ex1)\n", "\n", "To map a problem into a [discounted optimal linear control\n", "problem](https://python.quantecon.org/lqcontrol.html), we need to define\n", "\n", "- state vector $x_t$ and control vector $u_t$ \n", "- matrices $A, B, Q, R$ that define preferences and the law of\n", " motion for the state \n", "\n", "\n", "For the state and control vectors, we choose\n", "\n", "$$\n", "x_t = \\begin{bmatrix} y_t \\\\ Y_t \\\\ 1 \\end{bmatrix},\n", "\\qquad\n", "u_t = y_{t+1} - y_{t}\n", "$$\n", "\n", "For $B, Q, R$ we set\n", "\n", "$$\n", "A =\n", "\\begin{bmatrix}\n", " 1 & 0 & 0 \\\\\n", " 0 & \\kappa_1 & \\kappa_0 \\\\\n", " 0 & 0 & 1\n", "\\end{bmatrix},\n", "\\quad\n", "B = \\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\end{bmatrix} ,\n", "\\quad\n", "R =\n", "\\begin{bmatrix}\n", " 0 & a_1/2 & -a_0/2 \\\\\n", " a_1/2 & 0 & 0 \\\\\n", " -a_0/2 & 0 & 0\n", "\\end{bmatrix},\n", "\\quad\n", "Q = \\gamma / 2\n", "$$\n", "\n", "By multiplying out you can confirm that\n", "\n", "- $x_t' R x_t + u_t' Q u_t = - r_t$ \n", "- $x_{t+1} = A x_t + B u_t$ \n", "\n", "\n", "We’ll use the module lqcontrol.py to solve the firm’s problem at the\n", "stated parameter values.\n", "\n", "This will return an LQ policy $F$ with the interpretation\n", "$u_t = - F x_t$, or\n", "\n", "$$\n", "y_{t+1} - y_t = - F_0 y_t - F_1 Y_t - F_2\n", "$$\n", "\n", "Matching parameters with $y_{t+1} = h_0 + h_1 y_t + h_2 Y_t$ leads\n", "to\n", "\n", "$$\n", "h_0 = -F_2, \\quad h_1 = 1 - F_0, \\quad h_2 = -F_1\n", "$$\n", "\n", "Here’s our solution" ] }, { "cell_type": "code", "execution_count": null, "id": "8f106bb3", "metadata": { "hide-output": false }, "outputs": [], "source": [ "# Model parameters\n", "\n", "a0 = 100\n", "a1 = 0.05\n", "β = 0.95\n", "γ = 10.0\n", "\n", "# Beliefs\n", "\n", "κ0 = 95.5\n", "κ1 = 0.95\n", "\n", "# Formulate the LQ problem\n", "\n", "A = np.array([[1, 0, 0], [0, κ1, κ0], [0, 0, 1]])\n", "B = np.array([1, 0, 0])\n", "B.shape = 3, 1\n", "R = np.array([[0, a1/2, -a0/2], [a1/2, 0, 0], [-a0/2, 0, 0]])\n", "Q = 0.5 * γ\n", "\n", "# Solve for the optimal policy\n", "\n", "lq = LQ(Q, R, A, B, beta=β)\n", "P, F, d = lq.stationary_values()\n", "F = F.flatten()\n", "out1 = f\"F = [{F:.3f}, {F:.3f}, {F:.3f}]\"\n", "h0, h1, h2 = -F, 1 - F, -F\n", "out2 = f\"(h0, h1, h2) = ({h0:.3f}, {h1:.3f}, {h2:.3f})\"\n", "\n", "print(out1)\n", "print(out2)" ] }, { "cell_type": "markdown", "id": "9ee4c195", "metadata": {}, "source": [ "The implication is that\n", "\n", "$$\n", "y_{t+1} = 96.949 + y_t - 0.046 \\, Y_t\n", "$$\n", "\n", "For the case $n > 1$, recall that $Y_t = n y_t$, which,\n", "combined with the previous equation, yields\n", "\n", "$$\n", "Y_{t+1}\n", "= n \\left( 96.949 + y_t - 0.046 \\, Y_t \\right)\n", "= n 96.949 + (1 - n 0.046) Y_t\n", "$$" ] }, { "cell_type": "markdown", "id": "bd7b0ff2", "metadata": {}, "source": [ "## Exercise 70.2\n", "\n", "Consider the following $\\kappa_0, \\kappa_1$ pairs as candidates for the\n", "aggregate law of motion component of a rational expectations equilibrium (see\n", "[(70.19)](#equation-ree-hlom2)).\n", "\n", "Extending the program that you wrote for Exercise 70.1, determine which if any\n", "satisfy [the definition](#ree-def) of a rational expectations equilibrium\n", "\n", "- (94.0886298678, 0.923409232937) \n", "- (93.2119845412, 0.984323478873) \n", "- (95.0818452486, 0.952459076301) \n", "\n", "\n", "Describe an iterative algorithm that uses the program that you wrote for Exercise 70.1 to compute a rational expectations equilibrium.\n", "\n", "(You are not being asked actually to use the algorithm you are suggesting)" ] }, { "cell_type": "markdown", "id": "7ccb2cfe", "metadata": {}, "source": [ "## Solution to[ Exercise 70.2](https://python.quantecon.org/#ree_ex2)\n", "\n", "To determine whether a $\\kappa_0, \\kappa_1$ pair forms the\n", "aggregate law of motion component of a rational expectations\n", "equilibrium, we can proceed as follows:\n", "\n", "- Determine the corresponding firm law of motion\n", " $y_{t+1} = h_0 + h_1 y_t + h_2 Y_t$. \n", "- Test whether the associated aggregate law\n", " :$Y_{t+1} = n h(Y_t/n, Y_t)$ evaluates to\n", " $Y_{t+1} = \\kappa_0 + \\kappa_1 Y_t$. \n", "\n", "\n", "In the second step, we can use $Y_t = n y_t = y_t$, so that\n", "$Y_{t+1} = n h(Y_t/n, Y_t)$ becomes\n", "\n", "$$\n", "Y_{t+1} = h(Y_t, Y_t) = h_0 + (h_1 + h_2) Y_t\n", "$$\n", "\n", "Hence to test the second step we can test $\\kappa_0 = h_0$ and\n", "$\\kappa_1 = h_1 + h_2$.\n", "\n", "The following code implements this test" ] }, { "cell_type": "code", "execution_count": null, "id": "484703be", "metadata": { "hide-output": false }, "outputs": [], "source": [ "candidates = ((94.0886298678, 0.923409232937),\n", " (93.2119845412, 0.984323478873),\n", " (95.0818452486, 0.952459076301))\n", "\n", "for κ0, κ1 in candidates:\n", "\n", " # Form the associated law of motion\n", " A = np.array([[1, 0, 0], [0, κ1, κ0], [0, 0, 1]])\n", "\n", " # Solve the LQ problem for the firm\n", " lq = LQ(Q, R, A, B, beta=β)\n", " P, F, d = lq.stationary_values()\n", " F = F.flatten()\n", " h0, h1, h2 = -F, 1 - F, -F\n", "\n", " # Test the equilibrium condition\n", " if np.allclose((κ0, κ1), (h0, h1 + h2)):\n", " print(f'Equilibrium pair = {κ0}, {κ1}')\n", " print('f(h0, h1, h2) = {h0}, {h1}, {h2}')\n", " break" ] }, { "cell_type": "markdown", "id": "97ebe9b9", "metadata": {}, "source": [ "The output tells us that the answer is pair (iii), which implies\n", "$(h_0, h_1, h_2) = (95.0819, 1.0000, -.0475)$.\n", "\n", "(Notice we use np.allclose to test equality of floating-point\n", "numbers, since exact equality is too strict).\n", "\n", "Regarding the iterative algorithm, one could loop from a given\n", "$(\\kappa_0, \\kappa_1)$ pair to the associated firm law and then to\n", "a new $(\\kappa_0, \\kappa_1)$ pair.\n", "\n", "This amounts to implementing the operator $\\Phi$ described in the\n", "lecture.\n", "\n", "(There is in general no guarantee that this iterative process will\n", "converge to a rational expectations equilibrium)" ] }, { "cell_type": "markdown", "id": "6eddb44a", "metadata": {}, "source": [ "## Exercise 70.3\n", "\n", "Recall the planner’s problem [described above](#ree-pp)\n", "\n", "1. Formulate the planner’s problem as an LQ problem. \n", "1. Solve it using the same parameter values in exercise 1 \n", " - $a_0= 100, a_1= 0.05, \\beta = 0.95, \\gamma=10$ \n", "1. Represent the solution in the form $Y_{t+1} = \\kappa_0 + \\kappa_1 Y_t$. \n", "1. Compare your answer with the results from exercise 2. " ] }, { "cell_type": "markdown", "id": "da9ce541", "metadata": {}, "source": [ "## Solution to[ Exercise 70.3](https://python.quantecon.org/#ree_ex3)\n", "\n", "We are asked to write the planner problem as an LQ problem.\n", "\n", "For the state and control vectors, we choose\n", "\n", "$$\n", "x_t = \\begin{bmatrix} Y_t \\\\ 1 \\end{bmatrix},\n", "\\quad\n", "u_t = Y_{t+1} - Y_{t}\n", "$$\n", "\n", "For the LQ matrices, we set\n", "\n", "$$\n", "A = \\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix},\n", "\\quad\n", "B = \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix},\n", "\\quad\n", "R = \\begin{bmatrix} a_1/2 & -a_0/2 \\\\ -a_0/2 & 0 \\end{bmatrix},\n", "\\quad\n", "Q = \\gamma / 2\n", "$$\n", "\n", "By multiplying out you can confirm that\n", "\n", "- $x_t' R x_t + u_t' Q u_t = - s(Y_t, Y_{t+1})$ \n", "- $x_{t+1} = A x_t + B u_t$ \n", "\n", "\n", "By obtaining the optimal policy and using $u_t = - F x_t$ or\n", "\n", "$$\n", "Y_{t+1} - Y_t = -F_0 Y_t - F_1\n", "$$\n", "\n", "we can obtain the implied aggregate law of motion via\n", "$\\kappa_0 = -F_1$ and $\\kappa_1 = 1-F_0$.\n", "\n", "The Python code to solve this problem is below:" ] }, { "cell_type": "code", "execution_count": null, "id": "eba0a37d", "metadata": { "hide-output": false }, "outputs": [], "source": [ "# Formulate the planner's LQ problem\n", "\n", "A = np.array([[1, 0], [0, 1]])\n", "B = np.array([, ])\n", "R = np.array([[a1 / 2, -a0 / 2], [-a0 / 2, 0]])\n", "Q = γ / 2\n", "\n", "# Solve for the optimal policy\n", "\n", "lq = LQ(Q, R, A, B, beta=β)\n", "P, F, d = lq.stationary_values()\n", "\n", "# Print the results\n", "\n", "F = F.flatten()\n", "κ0, κ1 = -F, 1 - F\n", "print(κ0, κ1)" ] }, { "cell_type": "markdown", "id": "8e6362af", "metadata": {}, "source": [ "The output yields the same $(\\kappa_0, \\kappa_1)$ pair obtained as\n", "an equilibrium from the previous exercise." ] }, { "cell_type": "markdown", "id": "ef058d14", "metadata": {}, "source": [ "## Exercise 70.4\n", "\n", "A monopolist faces the industry demand curve [(70.5)](#equation-ree-comp3d) and chooses $\\{Y_t\\}$ to maximize $\\sum_{t=0}^{\\infty} \\beta^t r_t$ where\n", "\n", "$$\n", "r_t = p_t Y_t - \\frac{\\gamma (Y_{t+1} - Y_t)^2 }{2}\n", "$$\n", "\n", "Formulate this problem as an LQ problem.\n", "\n", "Compute the optimal policy using the same parameters as Exercise 70.2.\n", "\n", "In particular, solve for the parameters in\n", "\n", "$$\n", "Y_{t+1} = m_0 + m_1 Y_t\n", "$$\n", "\n", "Compare your results with Exercise 70.2 – comment." ] }, { "cell_type": "markdown", "id": "0a7e52f1", "metadata": {}, "source": [ "## Solution to[ Exercise 70.4](https://python.quantecon.org/#ree_ex4)\n", "\n", "The monopolist’s LQ problem is almost identical to the planner’s problem\n", "from the previous exercise, except that\n", "\n", "$$\n", "R = \\begin{bmatrix}\n", " a_1 & -a_0/2 \\\\\n", " -a_0/2 & 0\n", "\\end{bmatrix}\n", "$$\n", "\n", "The problem can be solved as follows" ] }, { "cell_type": "code", "execution_count": null, "id": "f0a73d6a", "metadata": { "hide-output": false }, "outputs": [], "source": [ "A = np.array([[1, 0], [0, 1]])\n", "B = np.array([, ])\n", "R = np.array([[a1, -a0 / 2], [-a0 / 2, 0]])\n", "Q = γ / 2\n", "\n", "lq = LQ(Q, R, A, B, beta=β)\n", "P, F, d = lq.stationary_values()\n", "\n", "F = F.flatten()\n", "m0, m1 = -F, 1 - F\n", "print(m0, m1)" ] }, { "cell_type": "markdown", "id": "d5c1bff2", "metadata": {}, "source": [ "We see that the law of motion for the monopolist is approximately\n", "$Y_{t+1} = 73.4729 + 0.9265 Y_t$.\n", "\n", "In the rational expectations case, the law of motion was approximately\n", "$Y_{t+1} = 95.0818 + 0.9525 Y_t$.\n", "\n", "One way to compare these two laws of motion is by their fixed points,\n", "which give long-run equilibrium output in each case.\n", "\n", "For laws of the form $Y_{t+1} = c_0 + c_1 Y_t$, the fixed point is\n", "$c_0 / (1 - c_1)$.\n", "\n", "If you crunch the numbers, you will see that the monopolist adopts a\n", "lower long-run quantity than obtained by the competitive market,\n", "implying a higher market price.\n", "\n", "This is analogous to the elementary static-case results\n", "\n", "

 A literature that studies whether models populated with agents\n", "who learn can converge to rational expectations equilibria features\n", "iterations on a modification of the mapping $\\Phi$ that can be\n", "approximated as $\\gamma \\Phi + (1-\\gamma)I$. Here $I$ is the\n", "identity operator and $\\gamma \\in (0,1)$ is a *relaxation parameter*.\n", "See [[MS89](https://python.quantecon.org/zreferences.html#id188)] and [[EH01](https://python.quantecon.org/zreferences.html#id160)] for statements\n", "and applications of this approach to establish conditions under which\n", "collections of adaptive agents who use least squares learning to converge to a\n", "rational expectations equilibrium." ] } ], "metadata": { "date": 1680677906.3236096, "filename": "rational_expectations.md", "kernelspec": { "display_name": "Python", "language": "python3", "name": "python3" }, "title": "Rational Expectations Equilibrium" }, "nbformat": 4, "nbformat_minor": 5 }