{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Cass-Koopmans Competitive Equilibrium"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Contents\n",
"\n",
"- [Cass-Koopmans Competitive Equilibrium](#Cass-Koopmans-Competitive-Equilibrium) \n",
" - [Overview](#Overview) \n",
" - [Review of Cass-Koopmans Model](#Review-of-Cass-Koopmans-Model) \n",
" - [Competitive Equilibrium](#Competitive-Equilibrium) \n",
" - [Market Structure](#Market-Structure) \n",
" - [Firm Problem](#Firm-Problem) \n",
" - [Household Problem](#Household-Problem) \n",
" - [Computing a Competitive Equilibrium](#Computing-a-Competitive-Equilibrium) \n",
" - [Yield Curves and Hicks-Arrow Prices](#Yield-Curves-and-Hicks-Arrow-Prices) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overview\n",
"\n",
"This lecture continues our analysis in this lecture\n",
"[Cass-Koopmans Planning Model](https://python.quantecon.org/cass_koopmans_1.html) about the model that Tjalling Koopmans [[Koo65](https://python.quantecon.org/zreferences.html#id48)]\n",
"and David Cass [[Cas65](https://python.quantecon.org/zreferences.html#id49)] used to study optimal growth.\n",
"\n",
"This lecture illustrates what is, in fact, a\n",
"more general connection between a **planned economy** and an economy\n",
"organized as a **competitive equilibrium**.\n",
"\n",
"The earlier lecture [Cass-Koopmans Planning Model](https://python.quantecon.org/cass_koopmans_1.html) studied a planning problem and used ideas including\n",
"\n",
"- A min-max problem for solving the planning problem. \n",
"- A **shooting algorithm** for solving difference equations subject\n",
" to initial and terminal conditions. \n",
"- A **turnpike** property that describes optimal paths for\n",
" long-but-finite horizon economies. \n",
"\n",
"\n",
"The present lecture uses additional ideas including\n",
"\n",
"- Hicks-Arrow prices named after John R. Hicks and Kenneth Arrow. \n",
"- A connection between some Lagrange multipliers in the min-max\n",
" problem and the Hicks-Arrow prices. \n",
"- A **Big** $ K $ **, little** $ k $ trick widely used in\n",
" macroeconomic dynamics. \n",
" - We shall encounter this trick in [this lecture](https://lectures.quantecon.org/py/rational_expectations.html)\n",
" and also in [this lecture](https://lectures.quantecon.org/py/dyn_stack.html). \n",
"- A non-stochastic version of a theory of the **term structure of\n",
" interest rates**. \n",
"- An intimate connection between the cases for the optimality of two\n",
" competing visions of good ways to organize an economy, namely: \n",
" - **socialism** in which a central planner commands the\n",
" allocation of resources, and \n",
" - **capitalism** (also known as **a market economy**) in\n",
" which competitive equilibrium **prices** induce individual\n",
" consumers and producers to choose a socially optimal allocation\n",
" as an unintended consequence of their selfish\n",
" decisions \n",
"\n",
"\n",
"Let’s start with some standard imports:"
]
},
{
"cell_type": "code",
"execution_count": null,
"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",
"from numba import njit, float64\n",
"from numba.experimental import jitclass\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Review of Cass-Koopmans Model\n",
"\n",
"The physical setting is identical with that in [Cass-Koopmans Planning Model](https://python.quantecon.org/cass_koopmans_1.html).\n",
"\n",
"Time is discrete and takes values $ t = 0, 1 , \\ldots, T $.\n",
"\n",
"A single good can either be consumed or invested in physical capital.\n",
"\n",
"The consumption good is not durable and depreciates completely if not\n",
"consumed immediately.\n",
"\n",
"The capital good is durable but partially depreciates each period at a constant rate.\n",
"\n",
"We let $ C_t $ be a nondurable consumption good at time t.\n",
"\n",
"Let $ K_t $ be the stock of physical capital at time t.\n",
"\n",
"Let $ \\vec{C} $ = $ \\{C_0,\\dots, C_T\\} $ and\n",
"$ \\vec{K} $ = $ \\{K_0,\\dots,K_{T+1}\\} $.\n",
"\n",
"A representative household is endowed with one unit of labor at each\n",
"$ t $ and likes the consumption good at each $ t $.\n",
"\n",
"The representative household inelastically supplies a single unit of\n",
"labor $ N_t $ at each $ t $, so that\n",
"$ N_t =1 \\text{ for all } t \\in [0,T] $.\n",
"\n",
"The representative household has preferences over consumption bundles\n",
"ordered by the utility functional:\n",
"\n",
"$$\n",
"U(\\vec{C}) = \\sum_{t=0}^{T} \\beta^t \\frac{C_t^{1-\\gamma}}{1-\\gamma}\n",
"$$\n",
"\n",
"where $ \\beta \\in (0,1) $ is a discount factor and $ \\gamma >0 $\n",
"governs the curvature of the one-period utility function.\n",
"\n",
"We assume that $ K_0 > 0 $.\n",
"\n",
"There is an economy-wide production function\n",
"\n",
"$$\n",
"F(K_t,N_t) = A K_t^{\\alpha}N_t^{1-\\alpha}\n",
"$$\n",
"\n",
"with $ 0 < \\alpha<1 $, $ A > 0 $.\n",
"\n",
"A feasible allocation $ \\vec{C}, \\vec{K} $ satisfies\n",
"\n",
"$$\n",
"C_t + K_{t+1} \\leq F(K_t,N_t) + (1-\\delta) K_t, \\quad \\text{for all } t \\in [0, T]\n",
"$$\n",
"\n",
"where $ \\delta \\in (0,1) $ is a depreciation rate of capital."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Planning Problem\n",
"\n",
"In this lecture [Cass-Koopmans Planning Model](https://python.quantecon.org/cass_koopmans_1.html), we studied a problem in which a planner chooses an allocation $ \\{\\vec{C},\\vec{K}\\} $ to\n",
"maximize [(20.1)](https://python.quantecon.org/cass_koopmans_1.html#equation-utility-functional) subject to [(20.4)](https://python.quantecon.org/cass_koopmans_1.html#equation-allocation).\n",
"\n",
"The allocation that solves the planning problem plays an important role in a competitive equilibrium as we shall see below."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Competitive Equilibrium\n",
"\n",
"We now study a decentralized version of the economy.\n",
"\n",
"It shares the same\n",
"technology and preference structure as the planned economy studied in this lecture [Cass-Koopmans Planning Model](https://python.quantecon.org/cass_koopmans_1.html).\n",
"\n",
"But now there is no planner.\n",
"\n",
"Market prices adjust to reconcile distinct decisions that are made\n",
"separately by a representative household and a representative firm.\n",
"\n",
"There is a representative consumer who has the same preferences over\n",
"consumption plans as did the consumer in the planned economy.\n",
"\n",
"Instead of being told what to consume and save by a planner, the\n",
"household chooses for itself subject to a budget constraint\n",
"\n",
"- At each time $ t $, the household receives wages and rentals\n",
" of capital from a firm – these comprise its **income** at\n",
" time $ t $. \n",
"- The consumer decides how much income to allocate to consumption or\n",
" to savings. \n",
"- The household can save either by acquiring additional physical\n",
" capital (it trades one for one with time $ t $ consumption)\n",
" or by acquiring claims on consumption at dates other\n",
" than $ t $. \n",
"- The household owns all physical capital and labor\n",
" and rents them to the firm. \n",
"- The household consumes, supplies labor, and invests in physical\n",
" capital. \n",
"- A profit-maximizing representative firm operates the production\n",
" technology. \n",
"- The firm rents labor and capital each period from the\n",
" representative household and sells its output each period to the\n",
" household. \n",
"- The representative household and the representative firm are both\n",
" **price takers** who believe that prices are not affected by their choices \n",
"\n",
"\n",
"**Note:** We can think of there being a large number\n",
"$ M $ of identical representative consumers and $ M $\n",
"identical representative firms."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Market Structure\n",
"\n",
"The representative household and the representative firm are both price takers.\n",
"\n",
"The household owns both factors of production, namely, labor and physical capital.\n",
"\n",
"Each period, the firm rents both factors from the household.\n",
"\n",
"There is a **single** grand competitive market in which a\n",
"household can trade date $ 0 $ goods for goods at\n",
"all other dates $ t=1, 2, \\ldots, T $."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Prices\n",
"\n",
"There are sequences of prices\n",
"$ \\{w_t,\\eta_t\\}_{t=0}^T= \\{\\vec{w}, \\vec{\\eta} \\} $\n",
"where $ w_t $ is a wage or rental rate for labor at time $ t $ and\n",
"$ \\eta_t $ is a rental rate for capital at time $ t $.\n",
"\n",
"In addition there is are intertemporal prices that work as follows.\n",
"\n",
"Let $ q^0_t $ be the price of a good at date $ t $ relative\n",
"to a good at date $ 0 $.\n",
"\n",
"We call $ \\{q^0_t\\}_{t=0}^T $ a vector of **Hicks-Arrow prices**,\n",
"named after the 1972 economics Nobel prize winners.\n",
"\n",
"Evidently,\n",
"\n",
"$$\n",
"q^0_t=\\frac{\\text{number of time 0 goods}}{\\text{number of time t goods}}\n",
"$$\n",
"\n",
"Because $ q^0_t $ is a **relative price**, the units in terms of\n",
"which prices are quoted are arbitrary – we are free to normalize them."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Firm Problem\n",
"\n",
"At time $ t $ a representative firm hires labor\n",
"$ \\tilde n_t $ and capital $ \\tilde k_t $.\n",
"\n",
"The firm’s profits at time $ t $ are\n",
"\n",
"$$\n",
"F(\\tilde k_t, \\tilde n_t)-w_t \\tilde n_t -\\eta_t \\tilde k_t\n",
"$$\n",
"\n",
"where $ w_t $ is a wage rate at $ t $\n",
"and $ \\eta_t $ is the rental rate on capital at $ t $.\n",
"\n",
"As in the planned economy model\n",
"\n",
"$$\n",
"F(\\tilde k_t, \\tilde n_t) = A \\tilde k_t^\\alpha \\tilde n_t^{1-\\alpha}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Zero Profit Conditions\n",
"\n",
"Zero-profits condition for capital and labor are\n",
"\n",
"$$\n",
"F_k(\\tilde k_t, \\tilde n_t) =\\eta_t\n",
"$$\n",
"\n",
"and\n",
"\n",
"\n",
"\n",
"$$\n",
"F_n(\\tilde k_t, \\tilde n_t) =w_t \\tag{1}\n",
"$$\n",
"\n",
"These conditions emerge from a no-arbitrage requirement.\n",
"\n",
"To describe this no-arbitrage profits reasoning, we begin by applying a theorem of\n",
"Euler about linearly homogenous functions.\n",
"\n",
"The theorem applies to the Cobb-Douglas production function because\n",
"it assumed displays constant returns to scale:\n",
"\n",
"$$\n",
"\\alpha F(\\tilde k_t, \\tilde n_t) = F(\\alpha \\tilde k_t, \\alpha \\tilde n_t)\n",
"$$\n",
"\n",
"for $ \\alpha \\in (0,1) $.\n",
"\n",
"Taking the partial derivative\n",
"$ \\frac{\\partial F }{\\partial \\alpha} $ on both sides of the\n",
"above equation gives\n",
"\n",
"$$\n",
"F(\\tilde k_t,\\tilde n_t) =_\\text{chain rule} \\frac{\\partial F}{\\partial \\tilde k_t}\n",
"\\tilde k_t + \\frac{\\partial F}{\\partial \\tilde n_t} \\tilde n_t\n",
"$$\n",
"\n",
"Rewrite the firm’s profits as\n",
"\n",
"$$\n",
"\\frac{\\partial F}{\\partial \\tilde k_t} \\tilde k_t +\n",
"\\frac{\\partial F}{\\partial \\tilde n_t} \\tilde n_t-w_t \\tilde n_t -\\eta_t k_t\n",
"$$\n",
"\n",
"or\n",
"\n",
"$$\n",
"\\left(\\frac{\\partial F}{\\partial \\tilde k_t}-\\eta_t\\right) \\tilde k_t +\n",
"\\left(\\frac{\\partial F}{\\partial \\tilde n_t}-w_t\\right) \\tilde n_t\n",
"$$\n",
"\n",
"Because $ F $ is homogeneous of degree $ 1 $, it follows\n",
"that $ \\frac{\\partial F}{\\partial \\tilde k_t} $ and\n",
"$ \\frac{\\partial F}{\\partial \\tilde n_t} $ are homogeneous of\n",
"degree $ 0 $ and therefore fixed with respect to\n",
"$ \\tilde k_t $ and $ \\tilde n_t $.\n",
"\n",
"If $ \\frac{\\partial F}{\\partial \\tilde k_t}> \\eta_t $, then the\n",
"firm makes positive profits on each additional unit of\n",
"$ \\tilde k_t $, so it will want to make $ \\tilde k_t $\n",
"arbitrarily large.\n",
"\n",
"But setting $ \\tilde k_t = + \\infty $ is not physically feasible,\n",
"so presumably **equilibrium** prices will assume values that present\n",
"the firm with no such arbitrage opportunity.\n",
"\n",
"A similar argument applies if\n",
"$ \\frac{\\partial F}{\\partial \\tilde n_t}> w_t $.\n",
"\n",
"If $ \\frac{\\partial \\tilde k_t}{\\partial \\tilde k_t}< \\eta_t $,\n",
"the firm will set $ \\tilde k_t $ to zero, something that is not feasible.\n",
"\n",
"It is convenient to define\n",
"$ \\vec{w} =\\{w_0, \\dots,w_T\\} $and $ \\vec{\\eta}= \\{\\eta_0, \\dots, \\eta_T\\} $."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Household Problem\n",
"\n",
"A representative household lives at $ t=0,1,\\dots, T $.\n",
"\n",
"At $ t $, the household rents $ 1 $ unit of labor\n",
"and $ k_t $ units of capital to a firm and receives income\n",
"\n",
"$$\n",
"w_t 1+ \\eta_t k_t\n",
"$$\n",
"\n",
"At $ t $ the household allocates its income to the following\n",
"purchases\n",
"\n",
"$$\n",
"\\left(c_t + (k_{t+1} -(1-\\delta)k_t)\\right)\n",
"$$\n",
"\n",
"Here $ \\left(k_{t+1} -(1-\\delta)k_t\\right) $ is the household’s\n",
"net investment in physical capital and $ \\delta \\in (0,1) $ is\n",
"again a depreciation rate of capital.\n",
"\n",
"In period $ t $ is free to purchase more goods to be consumed and\n",
"invested in physical capital than its income from supplying capital\n",
"and labor to the firm, provided that in some other periods its income\n",
"exceeds its purchases.\n",
"\n",
"A household’s net excess demand for time $ t $ consumption goods\n",
"is the gap\n",
"\n",
"$$\n",
"e_t \\equiv \\left(c_t + (k_{t+1} -(1-\\delta)k_t)\\right)-(w_t 1 + \\eta_t k_t)\n",
"$$\n",
"\n",
"Let $ \\vec{c} = \\{c_0,\\dots,c_T\\} $ and let $ \\vec{k} = \\{k_1,\\dots,k_{T+1}\\} $.\n",
"\n",
"$ k_0 $ is given to the household.\n",
"\n",
"The household faces a **single** budget constraint.\n",
"that states that the present value of the household’s net excess\n",
"demands must be zero:\n",
"\n",
"$$\n",
"\\sum_{t=0}^T q^0_t e_t \\leq 0\n",
"$$\n",
"\n",
"or\n",
"\n",
"$$\n",
"\\sum_{t=0}^T q^0_t \\left(c_t + (k_{t+1} -(1-\\delta)k_t)-(w_t 1 + \\eta_t k_t) \\right) \\leq 0\n",
"$$\n",
"\n",
"The household chooses an allocation to solve the constrained optimization problem:\n",
"\n",
"$$\n",
"\\begin{aligned}& \\max_{\\vec{c}, \\vec{k} } \\sum_{t=0}^T \\beta^t u(c_t) \\\\ \\text{subject to} \\ \\ & \\sum_{t=0}^T q_t^0\\left(c_t +\\left(k_{t+1}-(1-\\delta) k_t\\right) -w_t -\\eta_t k_t\\right) \\leq 0 \\notag \\end{aligned}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Definitions\n",
"\n",
"- A **price system** is a sequence\n",
" $ \\{q_t^0,\\eta_t,w_t\\}_{t=0}^T= \\{\\vec{q}, \\vec{\\eta}, \\vec{w}\\} $. \n",
"- An **allocation** is a sequence\n",
" $ \\{c_t,k_{t+1},n_t=1\\}_{t=0}^T = \\{\\vec{c}, \\vec{k}, \\vec{n}\\} $. \n",
"- A **competitive equilibrium** is a price system and an allocation\n",
" for which \n",
" - Given the price system, the allocation solves the household’s\n",
" problem. \n",
" - Given the price system, the allocation solves the firm’s\n",
" problem. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Computing a Competitive Equilibrium\n",
"\n",
"We compute a competitive equilibrium by using a **guess and\n",
"verify** approach.\n",
"\n",
"- We **guess** equilibrium price sequences\n",
" $ \\{\\vec{q}, \\vec{\\eta}, \\vec{w}\\} $. \n",
"- We then **verify** that at those prices, the household and\n",
" the firm choose the same allocation. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Guess for Price System\n",
"\n",
"In this lecture [Cass-Koopmans Planning Model](https://python.quantecon.org/cass_koopmans_1.html), we computed an allocation $ \\{\\vec{C}, \\vec{K}, \\vec{N}\\} $\n",
"that solves the planning problem.\n",
"\n",
"(This allocation will constitute the **Big** $ K $ to be in the present instance of the **Big** $ K $ **, little** $ k $ trick\n",
"that we’ll apply to a competitive equilibrium in the spirit of [this lecture](https://lectures.quantecon.org/py/rational_expectations.html)\n",
"and [this lecture](https://lectures.quantecon.org/py/dyn_stack.html).)\n",
"\n",
"We use that allocation to construct a guess for the equilibrium\n",
"price system.\n",
"\n",
"In particular, we guess that for $ t=0,\\dots,T $:\n",
"\n",
"\n",
"\n",
"$$\n",
"\\lambda q_t^0 = \\beta^t u'(K_t) =\\beta^t \\mu_t \\tag{2}\n",
"$$\n",
"\n",
"\n",
"\n",
"$$\n",
"w_t = f(K_t) -K_t f'(K_t) \\tag{3}\n",
"$$\n",
"\n",
"\n",
"\n",
"$$\n",
"\\eta_t = f'(K_t) \\tag{4}\n",
"$$\n",
"\n",
"At these prices, let the capital chosen by the household be\n",
"\n",
"\n",
"\n",
"$$\n",
"k^*_t(\\vec {q}, \\vec{w}, \\vec{\\eta)} , \\quad t \\geq 0 \\tag{5}\n",
"$$\n",
"\n",
"and let the allocation chosen by the firm be\n",
"\n",
"$$\n",
"\\tilde k^*_t(\\vec{q}, \\vec{w}, \\vec{\\eta}), \\quad t \\geq 0\n",
"$$\n",
"\n",
"and so on.\n",
"\n",
"If our guess for the equilibrium price system is correct, then it\n",
"must occur that\n",
"\n",
"\n",
"\n",
"$$\n",
"k_t^* = \\tilde k_t^* \\tag{6}\n",
"$$\n",
"\n",
"\n",
"\n",
"$$\n",
"1 = \\tilde n_t^* \\tag{7}\n",
"$$\n",
"\n",
"$$\n",
"c_t^* + k_{t+1}^* - (1-\\delta) k_t^* = F(\\tilde k_t^*, \\tilde n_t^*)\n",
"$$\n",
"\n",
"We shall verify that for $ t=0,\\dots,T $ the allocations chosen\n",
"by the household and the firm both equal the allocation that solves\n",
"the planning problem:\n",
"\n",
"\n",
"\n",
"$$\n",
"k^*_t = \\tilde k^*_t=K_t, \\tilde n_t=1, c^*_t=C_t \\tag{8}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Verification Procedure\n",
"\n",
"Our approach is to stare at first-order necessary conditions for the\n",
"optimization problems of the household and the firm.\n",
"\n",
"At the price system we have guessed, we’ll then verify that both sets of first-order\n",
"conditions are satisfied at the allocation that solves the planning\n",
"problem."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Household’s Lagrangian\n",
"\n",
"To solve the household’s problem, we formulate the Lagrangian\n",
"\n",
"$$\n",
"\\mathcal{L}(\\vec{c},\\vec{k},\\lambda) = \\sum_{t=0}^T \\beta^t u(c_t)+ \\lambda \\left(\\sum_{t=0}^T q_t^0\\left(\\left((1-\\delta) k_t -w_t\\right)\n",
"+\\eta_t k_t -c_t - k_{t+1}\\right)\\right)\n",
"$$\n",
"\n",
"and attack the min-max problem:\n",
"\n",
"$$\n",
"\\min_{\\lambda} \\max_{\\vec{c},\\vec{k}} \\mathcal{L}(\\vec{c},\\vec{k},\\lambda)\n",
"$$\n",
"\n",
"First-order conditions are\n",
"\n",
"\n",
"\n",
"$$\n",
"c_t: \\quad \\beta^t u'(c_t)-\\lambda q_t^0=0 \\quad t=0,1,\\dots,T \\tag{9}\n",
"$$\n",
"\n",
"\n",
"\n",
"$$\n",
"k_t: \\quad -\\lambda q_t^0 \\left[(1-\\delta)+\\eta_t \\right]+\\lambda q^0_{t-1}=0 \\quad t=1,2,\\dots,T+1 \\tag{10}\n",
"$$\n",
"\n",
"\n",
"\n",
"$$\n",
"\\lambda: \\quad \\left(\\sum_{t=0}^T q_t^0\\left(c_t + \\left(k_{t+1}-(1-\\delta) k_t\\right) -w_t -\\eta_t k_t\\right)\\right) \\leq 0 \\tag{11}\n",
"$$\n",
"\n",
"\n",
"\n",
"$$\n",
"k_{T+1}: \\quad -\\lambda q_0^{T+1} \\leq 0, \\ \\leq 0 \\text{ if } k_{T+1}=0; \\ =0 \\text{ if } k_{T+1}>0 \\tag{12}\n",
"$$\n",
"\n",
"Now we plug in our guesses of prices and embark on some algebra in the hope of derived all first-order necessary conditions\n",
"[(20.7)](https://python.quantecon.org/cass_koopmans_1.html#equation-constraint1)-[(20.10)](https://python.quantecon.org/cass_koopmans_1.html#equation-constraint4) for the planning problem from this lecture [Cass-Koopmans Planning Model](https://python.quantecon.org/cass_koopmans_1.html).\n",
"\n",
"Combining [(21.9)](#equation-cond1) and [(21.2)](#equation-eq-price), we get:\n",
"\n",
"$$\n",
"u'(C_t) = \\mu_t\n",
"$$\n",
"\n",
"which is [(20.7)](https://python.quantecon.org/cass_koopmans_1.html#equation-constraint1).\n",
"\n",
"Combining [(21.10)](#equation-cond2), [(21.2)](#equation-eq-price), and\n",
"[(21.4)](#equation-eq-price3) we get:\n",
"\n",
"\n",
"\n",
"$$\n",
"-\\lambda \\beta^t \\mu_t\\left[(1-\\delta) +f'(K_t)\\right] +\\lambda \\beta^{t-1}\\mu_{t-1}=0 \\tag{13}\n",
"$$\n",
"\n",
"Rewriting [(21.13)](#equation-co-re) by dividing by $ \\lambda $ on\n",
"both sides (which is nonzero since u’>0) we get:\n",
"\n",
"$$\n",
"\\beta^t \\mu_t [(1-\\delta+f'(K_t)] = \\beta^{t-1} \\mu_{t-1}\n",
"$$\n",
"\n",
"or\n",
"\n",
"$$\n",
"\\beta \\mu_t [(1-\\delta+f'(K_t)] = \\mu_{t-1}\n",
"$$\n",
"\n",
"which is [(20.8)](https://python.quantecon.org/cass_koopmans_1.html#equation-constraint2).\n",
"\n",
"Combining [(21.11)](#equation-cond3), [(21.2)](#equation-eq-price), [(21.3)](#equation-eq-price2)\n",
"and [(21.4)](#equation-eq-price3) after multiplying both sides of\n",
"[(21.11)](#equation-cond3) by $ \\lambda $, we get\n",
"\n",
"$$\n",
"\\sum_{t=0}^T \\beta^t \\mu_{t} \\left(C_t+ (K_{t+1} -(1-\\delta)K_t)-f(K_t)+K_t f'(K_t)-f'(K_t)K_t\\right) \\leq 0\n",
"$$\n",
"\n",
"which simplifies\n",
"\n",
"$$\n",
"\\sum_{t=0}^T \\beta^t \\mu_{t} \\left(C_t +K_{t+1} -(1-\\delta)K_t - F(K_t,1)\\right) \\leq 0\n",
"$$\n",
"\n",
"Since $ \\beta^t \\mu_t >0 $ for $ t =0, \\ldots, T $, it follows that\n",
"\n",
"$$\n",
"C_t+K_{t+1}-(1-\\delta)K_t -F(K_t,1)=0 \\quad \\text{ for all }t \\text{ in } 0,\\dots,T\n",
"$$\n",
"\n",
"which is [(20.9)](https://python.quantecon.org/cass_koopmans_1.html#equation-constraint3).\n",
"\n",
"Combining [(21.12)](#equation-cond4) and [(21.2)](#equation-eq-price), we get:\n",
"\n",
"$$\n",
"-\\beta^{T+1} \\mu_{T+1} \\leq 0\n",
"$$\n",
"\n",
"Dividing both sides by $ \\beta^{T+1} $ gives\n",
"\n",
"$$\n",
"-\\mu_{T+1} \\leq 0\n",
"$$\n",
"\n",
"which is [(20.10)](https://python.quantecon.org/cass_koopmans_1.html#equation-constraint4) for the planning problem.\n",
"\n",
"Thus, at our guess of the equilibrium price system, the allocation\n",
"that solves the planning problem also solves the problem faced by a\n",
"representative household living in a competitive equilibrium.\n",
"\n",
"We now turn to the problem faced by a firm in a competitive\n",
"equilibrium:\n",
"\n",
"If we plug [(21.8)](#equation-eq-pl) into [(21.1)](#equation-zero-profits) for all t, we\n",
"get\n",
"\n",
"$$\n",
"\\frac{\\partial F(K_t, 1)}{\\partial K_t} = f'(K_t) = \\eta_t\n",
"$$\n",
"\n",
"which is [(21.4)](#equation-eq-price3).\n",
"\n",
"If we now plug [(21.8)](#equation-eq-pl) into [(21.1)](#equation-zero-profits) for all t, we\n",
"get:\n",
"\n",
"$$\n",
"\\frac{\\partial F(\\tilde K_t, 1)}{\\partial \\tilde L_t} = f(K_t)-f'(K_t)K_t=w_t\n",
"$$\n",
"\n",
"which is exactly [(21.5)](#equation-eq-pr4).\n",
"\n",
"So at our guess for the equilibrium price system, the allocation\n",
"that solves the planning problem also solves the problem faced by a firm\n",
"within a competitive equilibrium.\n",
"\n",
"By [(21.6)](#equation-ge1) and [(21.7)](#equation-ge2) this allocation is\n",
"identical to the one that solves the consumer’s problem.\n",
"\n",
"**Note:** Because budget sets are affected only by relative prices,\n",
"$ \\{q_0^t\\} $ is determined only up to multiplication by a\n",
"positive constant.\n",
"\n",
"**Normalization:** We are free to choose a $ \\{q_0^t\\} $ that\n",
"makes $ \\lambda=1 $ so that we are measuring $ q_0^t $ in\n",
"units of the marginal utility of time $ 0 $ goods.\n",
"\n",
"We will plot $ q, w, \\eta $ below to show these equilibrium prices\n",
"induce the same aggregate movements that we saw earlier in the planning\n",
"problem.\n",
"\n",
"To proceed, we bring in Python code that [Cass-Koopmans Planning Model](https://python.quantecon.org/cass_koopmans_1.html) used to solve the planning problem\n",
"\n",
"First let’s define a `jitclass` that stores parameters and functions\n",
"the characterize an economy."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"planning_data = [\n",
" ('γ', float64), # Coefficient of relative risk aversion\n",
" ('β', float64), # Discount factor\n",
" ('δ', float64), # Depreciation rate on capital\n",
" ('α', float64), # Return to capital per capita\n",
" ('A', float64) # Technology\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"@jitclass(planning_data)\n",
"class PlanningProblem():\n",
"\n",
" def __init__(self, γ=2, β=0.95, δ=0.02, α=0.33, A=1):\n",
"\n",
" self.γ, self.β = γ, β\n",
" self.δ, self.α, self.A = δ, α, A\n",
"\n",
" def u(self, c):\n",
" '''\n",
" Utility function\n",
" ASIDE: If you have a utility function that is hard to solve by hand\n",
" you can use automatic or symbolic differentiation\n",
" See https://github.com/HIPS/autograd\n",
" '''\n",
" γ = self.γ\n",
"\n",
" return c ** (1 - γ) / (1 - γ) if γ!= 1 else np.log(c)\n",
"\n",
" def u_prime(self, c):\n",
" 'Derivative of utility'\n",
" γ = self.γ\n",
"\n",
" return c ** (-γ)\n",
"\n",
" def u_prime_inv(self, c):\n",
" 'Inverse of derivative of utility'\n",
" γ = self.γ\n",
"\n",
" return c ** (-1 / γ)\n",
"\n",
" def f(self, k):\n",
" 'Production function'\n",
" α, A = self.α, self.A\n",
"\n",
" return A * k ** α\n",
"\n",
" def f_prime(self, k):\n",
" 'Derivative of production function'\n",
" α, A = self.α, self.A\n",
"\n",
" return α * A * k ** (α - 1)\n",
"\n",
" def f_prime_inv(self, k):\n",
" 'Inverse of derivative of production function'\n",
" α, A = self.α, self.A\n",
"\n",
" return (k / (A * α)) ** (1 / (α - 1))\n",
"\n",
" def next_k_c(self, k, c):\n",
" ''''\n",
" Given the current capital Kt and an arbitrary feasible\n",
" consumption choice Ct, computes Kt+1 by state transition law\n",
" and optimal Ct+1 by Euler equation.\n",
" '''\n",
" β, δ = self.β, self.δ\n",
" u_prime, u_prime_inv = self.u_prime, self.u_prime_inv\n",
" f, f_prime = self.f, self.f_prime\n",
"\n",
" k_next = f(k) + (1 - δ) * k - c\n",
" c_next = u_prime_inv(u_prime(c) / (β * (f_prime(k_next) + (1 - δ))))\n",
"\n",
" return k_next, c_next"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"@njit\n",
"def shooting(pp, c0, k0, T=10):\n",
" '''\n",
" Given the initial condition of capital k0 and an initial guess\n",
" of consumption c0, computes the whole paths of c and k\n",
" using the state transition law and Euler equation for T periods.\n",
" '''\n",
" if c0 > pp.f(k0):\n",
" print(\"initial consumption is not feasible\")\n",
"\n",
" return None\n",
"\n",
" # initialize vectors of c and k\n",
" c_vec = np.empty(T+1)\n",
" k_vec = np.empty(T+2)\n",
"\n",
" c_vec[0] = c0\n",
" k_vec[0] = k0\n",
"\n",
" for t in range(T):\n",
" k_vec[t+1], c_vec[t+1] = pp.next_k_c(k_vec[t], c_vec[t])\n",
"\n",
" k_vec[T+1] = pp.f(k_vec[T]) + (1 - pp.δ) * k_vec[T] - c_vec[T]\n",
"\n",
" return c_vec, k_vec"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"@njit\n",
"def bisection(pp, c0, k0, T=10, tol=1e-4, max_iter=500, k_ter=0, verbose=True):\n",
"\n",
" # initial boundaries for guess c0\n",
" c0_upper = pp.f(k0)\n",
" c0_lower = 0\n",
"\n",
" i = 0\n",
" while True:\n",
" c_vec, k_vec = shooting(pp, c0, k0, T)\n",
" error = k_vec[-1] - k_ter\n",
"\n",
" # check if the terminal condition is satisfied\n",
" if np.abs(error) < tol:\n",
" if verbose:\n",
" print('Converged successfully on iteration ', i+1)\n",
" return c_vec, k_vec\n",
"\n",
" i += 1\n",
" if i == max_iter:\n",
" if verbose:\n",
" print('Convergence failed.')\n",
" return c_vec, k_vec\n",
"\n",
" # if iteration continues, updates boundaries and guess of c0\n",
" if error > 0:\n",
" c0_lower = c0\n",
" else:\n",
" c0_upper = c0\n",
"\n",
" c0 = (c0_lower + c0_upper) / 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"pp = PlanningProblem()\n",
"\n",
"# Steady states\n",
"ρ = 1 / pp.β - 1\n",
"k_ss = pp.f_prime_inv(ρ+pp.δ)\n",
"c_ss = pp.f(k_ss) - pp.δ * k_ss"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The above code from this lecture [Cass-Koopmans Planning Model](https://python.quantecon.org/cass_koopmans_1.html) lets us compute an optimal allocation for the planning problem that turns\n",
"out to be the allocation associated with a competitive equilibium.\n",
"\n",
"Now we’re ready to bring in Python code that we require to compute additional objects that appear in a competitive equilibrium."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"@njit\n",
"def q(pp, c_path):\n",
" # Here we choose numeraire to be u'(c_0) -- this is q^(t_0)_t\n",
" T = len(c_path) - 1\n",
" q_path = np.ones(T+1)\n",
" q_path[0] = 1\n",
" for t in range(1, T+1):\n",
" q_path[t] = pp.β ** t * pp.u_prime(c_path[t])\n",
" return q_path\n",
"\n",
"@njit\n",
"def w(pp, k_path):\n",
" w_path = pp.f(k_path) - k_path * pp.f_prime(k_path)\n",
" return w_path\n",
"\n",
"@njit\n",
"def η(pp, k_path):\n",
" η_path = pp.f_prime(k_path)\n",
" return η_path"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we calculate and plot for each $ T $"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"T_arr = [250, 150, 75, 50]\n",
"\n",
"fix, axs = plt.subplots(2, 3, figsize=(13, 6))\n",
"titles = ['Arrow-Hicks Prices', 'Labor Rental Rate', 'Capital Rental Rate',\n",
" 'Consumption', 'Capital', 'Lagrange Multiplier']\n",
"ylabels = ['$q_t^0$', '$w_t$', '$\\eta_t$', '$c_t$', '$k_t$', '$\\mu_t$']\n",
"\n",
"for T in T_arr:\n",
" c_path, k_path = bisection(pp, 0.3, k_ss/3, T, verbose=False)\n",
" μ_path = pp.u_prime(c_path)\n",
"\n",
" q_path = q(pp, c_path)\n",
" w_path = w(pp, k_path)[:-1]\n",
" η_path = η(pp, k_path)[:-1]\n",
" paths = [q_path, w_path, η_path, c_path, k_path, μ_path]\n",
"\n",
" for i, ax in enumerate(axs.flatten()):\n",
" ax.plot(paths[i])\n",
" ax.set(title=titles[i], ylabel=ylabels[i], xlabel='t')\n",
" if titles[i] == 'Capital':\n",
" ax.axhline(k_ss, lw=1, ls='--', c='k')\n",
" if titles[i] == 'Consumption':\n",
" ax.axhline(c_ss, lw=1, ls='--', c='k')\n",
"\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Varying Curvature\n",
"\n",
"Now we see how our results change if we keep $ T $ constant, but allow\n",
"the curvature parameter, $ \\gamma $ to vary, starting\n",
"with $ K_0 $ below the steady state.\n",
"\n",
"We plot the results for $ T=150 $"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"T = 150\n",
"γ_arr = [1.1, 4, 6, 8]\n",
"\n",
"fix, axs = plt.subplots(2, 3, figsize=(13, 6))\n",
"\n",
"for γ in γ_arr:\n",
" pp_γ = PlanningProblem(γ=γ)\n",
" c_path, k_path = bisection(pp_γ, 0.3, k_ss/3, T, verbose=False)\n",
" μ_path = pp_γ.u_prime(c_path)\n",
"\n",
" q_path = q(pp_γ, c_path)\n",
" w_path = w(pp_γ, k_path)[:-1]\n",
" η_path = η(pp_γ, k_path)[:-1]\n",
" paths = [q_path, w_path, η_path, c_path, k_path, μ_path]\n",
"\n",
" for i, ax in enumerate(axs.flatten()):\n",
" ax.plot(paths[i], label=f'$\\gamma = {γ}$')\n",
" ax.set(title=titles[i], ylabel=ylabels[i], xlabel='t')\n",
" if titles[i] == 'Capital':\n",
" ax.axhline(k_ss, lw=1, ls='--', c='k')\n",
" if titles[i] == 'Consumption':\n",
" ax.axhline(c_ss, lw=1, ls='--', c='k')\n",
"\n",
"axs[0, 0].legend()\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Adjusting $ \\gamma $ means adjusting how much individuals prefer\n",
"to smooth consumption.\n",
"\n",
"Higher $ \\gamma $ means individuals prefer to smooth more\n",
"resulting in slower adjustments to the steady state allocations.\n",
"\n",
"Vice-versa for lower $ \\gamma $."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Yield Curves and Hicks-Arrow Prices\n",
"\n",
"We return to Hicks-Arrow prices and calculate how they are related to **yields** on loans of alternative maturities.\n",
"\n",
"This will let us plot a **yield curve** that graphs yields on bonds of maturities $ j=1, 2, \\ldots $ against $ j=1,2, \\ldots $.\n",
"\n",
"The formulas we want are:\n",
"\n",
"A **yield to maturity** on a loan made at time $ t_0 $ that matures at time $ t > t_0 $\n",
"\n",
"$$\n",
"r_{t_0,t}= -\\frac{\\log q^{t_0}_t}{t - t_0}\n",
"$$\n",
"\n",
"A Hicks-Arrow price for a base-year $ t_0\\leq t $\n",
"\n",
"$$\n",
"q^{t_0}_t = \\beta^{t-t_0} \\frac{u'(c_t)}{u'(c_{t_0})}= \\beta^{t-t_0}\n",
"\\frac{c_t^{-\\gamma}}{c_{t_0}^{-\\gamma}}\n",
"$$\n",
"\n",
"We redefine our function for $ q $ to allow arbitrary base\n",
"years, and define a new function for $ r $, then plot both.\n",
"\n",
"We begin by continuing to assume that $ t_0=0 $ and plot things for different maturities $ t=T $, with $ K_0 $ below the steady state"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"@njit\n",
"def q_generic(pp, t0, c_path):\n",
" # simplify notations\n",
" β = pp.β\n",
" u_prime = pp.u_prime\n",
"\n",
" T = len(c_path) - 1\n",
" q_path = np.zeros(T+1-t0)\n",
" q_path[0] = 1\n",
" for t in range(t0+1, T+1):\n",
" q_path[t-t0] = β ** (t-t0) * u_prime(c_path[t]) / u_prime(c_path[t0])\n",
" return q_path\n",
"\n",
"@njit\n",
"def r(pp, t0, q_path):\n",
" '''Yield to maturity'''\n",
" r_path = - np.log(q_path[1:]) / np.arange(1, len(q_path))\n",
" return r_path\n",
"\n",
"def plot_yield_curves(pp, t0, c0, k0, T_arr):\n",
"\n",
" fig, axs = plt.subplots(1, 2, figsize=(10, 5))\n",
"\n",
" for T in T_arr:\n",
" c_path, k_path = bisection(pp, c0, k0, T, verbose=False)\n",
" q_path = q_generic(pp, t0, c_path)\n",
" r_path = r(pp, t0, q_path)\n",
"\n",
" axs[0].plot(range(t0, T+1), q_path)\n",
" axs[0].set(xlabel='t', ylabel='$q_t^0$', title='Hicks-Arrow Prices')\n",
"\n",
" axs[1].plot(range(t0+1, T+1), r_path)\n",
" axs[1].set(xlabel='t', ylabel='$r_t^0$', title='Yields')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"T_arr = [150, 75, 50]\n",
"plot_yield_curves(pp, 0, 0.3, k_ss/3, T_arr)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we plot when $ t_0=20 $"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"plot_yield_curves(pp, 20, 0.3, k_ss/3, T_arr)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We aim to have more to say about the term structure of interest rates\n",
"in a planned lecture on the topic."
]
}
],
"metadata": {
"date": 1619590830.594648,
"filename": "cass_koopmans_2.md",
"kernelspec": {
"display_name": "Python",
"language": "python3",
"name": "python3"
},
"title": "Cass-Koopmans Competitive Equilibrium"
},
"nbformat": 4,
"nbformat_minor": 4
}