{ "cells": [ { "cell_type": "markdown", "id": "a13f3908", "metadata": {}, "source": [ "\n", "" ] }, { "cell_type": "markdown", "id": "5aa28057", "metadata": {}, "source": [ "# Optimal Taxation without State-Contingent Debt" ] }, { "cell_type": "markdown", "id": "fd1b86e8", "metadata": {}, "source": [ "## Contents\n", "\n", "- [Optimal Taxation without State-Contingent Debt](#Optimal-Taxation-without-State-Contingent-Debt) \n", " - [Overview](#Overview) \n", " - [Competitive Equilibrium with Distorting Taxes](#Competitive-Equilibrium-with-Distorting-Taxes) \n", " - [Recursive Version of AMSS Model](#Recursive-Version-of-AMSS-Model) \n", " - [Examples](#Examples) " ] }, { "cell_type": "markdown", "id": "0848613b", "metadata": {}, "source": [ "In addition to what’s in Anaconda, this lecture will need the following libraries:" ] }, { "cell_type": "code", "execution_count": null, "id": "d2772ceb", "metadata": { "hide-output": false }, "outputs": [], "source": [ "!pip install --upgrade quantecon\n", "!pip install interpolation" ] }, { "cell_type": "markdown", "id": "59d65097", "metadata": {}, "source": [ "## Overview\n", "\n", "Let’s start with following imports:" ] }, { "cell_type": "code", "execution_count": null, "id": "6bd7192f", "metadata": { "hide-output": false }, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy.optimize import root\n", "from interpolation.splines import eval_linear, UCGrid, nodes\n", "from quantecon import optimize, MarkovChain\n", "from numba import njit, prange, float64\n", "from numba.experimental import jitclass" ] }, { "cell_type": "markdown", "id": "06b1080b", "metadata": {}, "source": [ "In [an earlier lecture](https://python-advanced.quantecon.org/opt_tax_recur.html), we described a model of\n", "optimal taxation with state-contingent debt due to\n", "Robert E. Lucas, Jr., and Nancy Stokey [[LS83](https://python-advanced.quantecon.org/zreferences.html#id176)].\n", "\n", "Aiyagari, Marcet, Sargent, and Seppälä [[AMSSeppala02](https://python-advanced.quantecon.org/zreferences.html#id130)] (hereafter, AMSS)\n", "studied optimal taxation in a model without state-contingent debt.\n", "\n", "In this lecture, we\n", "\n", "- describe assumptions and equilibrium concepts \n", "- solve the model \n", "- implement the model numerically \n", "- conduct some policy experiments \n", "- compare outcomes with those in a corresponding complete-markets model \n", "\n", "\n", "We begin with an introduction to the model." ] }, { "cell_type": "markdown", "id": "328d4932", "metadata": {}, "source": [ "## Competitive Equilibrium with Distorting Taxes\n", "\n", "Many but not all features of the economy are identical to those of [the Lucas-Stokey economy](https://python-advanced.quantecon.org/opt_tax_recur.html).\n", "\n", "Let’s start with things that are identical.\n", "\n", "For $ t \\geq 0 $, a history of the state is represented by $ s^t = [s_t, s_{t-1}, \\ldots, s_0] $.\n", "\n", "Government purchases $ g(s) $ are an exact time-invariant function of $ s $.\n", "\n", "Let $ c_t(s^t) $, $ \\ell_t(s^t) $, and $ n_t(s^t) $ denote consumption,\n", "leisure, and labor supply, respectively, at history $ s^t $ at time $ t $.\n", "\n", "Each period a representative household is endowed with one unit of time that can be divided between leisure\n", "$ \\ell_t $ and labor $ n_t $:\n", "\n", "\n", "\n", "$$\n", "n_t(s^t) + \\ell_t(s^t) = 1 \\tag{43.1}\n", "$$\n", "\n", "Output equals $ n_t(s^t) $ and can be divided between consumption $ c_t(s^t) $ and $ g(s_t) $\n", "\n", "\n", "\n", "$$\n", "c_t(s^t) + g(s_t) = n_t(s^t) \\tag{43.2}\n", "$$\n", "\n", "Output is not storable.\n", "\n", "The technology pins down a pre-tax wage rate to unity for all $ t, s^t $.\n", "\n", "A representative household’s preferences over $ \\{c_t(s^t), \\ell_t(s^t)\\}_{t=0}^\\infty $ are ordered by\n", "\n", "\n", "\n", "$$\n", "\\sum_{t=0}^\\infty \\sum_{s^t} \\beta^t \\pi_t(s^t) u[c_t(s^t), \\ell_t(s^t)] \\tag{43.3}\n", "$$\n", "\n", "where\n", "\n", "- $ \\pi_t(s^t) $ is a joint probability distribution over the sequence $ s^t $, and \n", "- the utility function $ u $ is increasing, strictly concave, and three times continuously differentiable in both arguments. \n", "\n", "\n", "The government imposes a flat rate tax $ \\tau_t(s^t) $ on labor income at time $ t $, history $ s^t $.\n", "\n", "Lucas and Stokey assumed that there are complete markets in one-period Arrow securities; also see [smoothing models](https://python-advanced.quantecon.org/smoothing.html).\n", "\n", "It is at this point that AMSS [[AMSSeppala02](https://python-advanced.quantecon.org/zreferences.html#id130)] modify the Lucas and Stokey economy.\n", "\n", "AMSS allow the government to issue only one-period risk-free debt each period.\n", "\n", "Ruling out complete markets in this way is a step in the direction of making total tax collections behave more like that prescribed in Robert Barro (1979) [[Bar79](https://python-advanced.quantecon.org/zreferences.html#id136)] than they do in Lucas and Stokey (1983) [[LS83](https://python-advanced.quantecon.org/zreferences.html#id176)]." ] }, { "cell_type": "markdown", "id": "a97ddc71", "metadata": {}, "source": [ "### Risk-free One-Period Debt Only\n", "\n", "In period $ t $ and history $ s^t $, let\n", "\n", "- $ b_{t+1}(s^t) $ be the amount of the time $ t+1 $ consumption good that at time $ t $, history $ s^t $ the government promised to pay \n", "- $ R_t(s^t) $ be the gross interest rate on risk-free one-period debt between periods $ t $ and $ t+1 $ \n", "- $ T_t(s^t) $ be a non-negative lump-sum *transfer* to the representative household [1] \n", "\n", "\n", "That $ b_{t+1}(s^t) $ is the same for all realizations of $ s_{t+1} $ captures its *risk-free* character.\n", "\n", "The market value at time $ t $ of government debt maturing at time $ t+1 $ equals $ b_{t+1}(s^t) $ divided by $ R_t(s^t) $.\n", "\n", "The government’s budget constraint in period $ t $ at history $ s^t $ is\n", "\n", "\n", "\n", "$$\n", "\\begin{aligned}\n", "b_t(s^{t-1})\n", " & = \\tau^n_t(s^t) n_t(s^t) - g(s_t) - T_t(s^t) +\n", " {b_{t+1}(s^t) \\over R_t(s^t )}\n", " \\\\\n", " & \\equiv z_t(s^t) + {b_{t+1}(s^t) \\over R_t(s^t )},\n", "\\end{aligned} \\tag{43.4}\n", "$$\n", "\n", "where $ z_t(s^t) $ is the net-of-interest government surplus.\n", "\n", "To rule out Ponzi schemes, we assume that the government is subject to a **natural debt limit** (to be discussed in a forthcoming lecture).\n", "\n", "The consumption Euler equation for a representative household able to trade only one-period risk-free debt\n", "with one-period gross interest rate $ R_t(s^t) $ is\n", "\n", "$$\n", "{1 \\over R_t(s^t)}\n", "= \\sum_{s^{t+1}\\vert s^t} \\beta \\pi_{t+1}(s^{t+1} | s^t)\n", " { u_c(s^{t+1}) \\over u_c(s^{t}) }\n", "$$\n", "\n", "Substituting this expression into the government’s budget constraint [(43.4)](#equation-ts-gov-wo)\n", "yields:\n", "\n", "\n", "\n", "$$\n", "b_t(s^{t-1}) = z_t(s^t) + \\beta \\sum_{s^{t+1}\\vert s^t} \\pi_{t+1}(s^{t+1} | s^t)\n", " { u_c(s^{t+1}) \\over u_c(s^{t}) } \\; b_{t+1}(s^t) \\tag{43.5}\n", "$$\n", "\n", "Components of $ z_t(s^t) $ on the right side depend on $ s^t $, but the left side is required to depend only\n", "on $ s^{t-1} $ .\n", "\n", "**This is what it means for one-period government debt to be risk-free**.\n", "\n", "Therefore, the right side of equation [(43.5)](#equation-ts-gov-wo2) also has to depend only on $ s^{t-1} $.\n", "\n", "This requirement will give rise to **measurability constraints** on the Ramsey allocation to be discussed soon.\n", "\n", "If we replace $ b_{t+1}(s^t) $ on the right side of equation [(43.5)](#equation-ts-gov-wo2) by the right\n", "side of next period’s budget constraint (associated with a\n", "particular realization $ s_{t} $) we get\n", "\n", "$$\n", "b_t(s^{t-1}) = z_t(s^t) + \\sum_{s^{t+1}\\vert s^t} \\beta \\pi_{t+1}(s^{t+1} | s^t)\n", " { u_c(s^{t+1}) \\over u_c(s^{t}) }\n", "\\, \\left[z_{t+1}(s^{t+1}) + {b_{t+2}(s^{t+1}) \\over R_{t+1}(s^{t+1})}\\right]\n", "$$\n", "\n", "After making similar repeated substitutions for all future occurrences of\n", "government indebtedness, and by invoking a natural debt limit, we\n", "arrive at:\n", "\n", "\n", "\n", "$$\n", "\\begin{aligned}\n", "b_t(s^{t-1})\n", " &= \\sum_{j=0}^\\infty \\sum_{s^{t+j} | s^t} \\beta^j \\pi_{t+j}(s^{t+j} | s^t)\n", " { u_c(s^{t+j}) \\over u_c(s^{t}) } \\;z_{t+j}(s^{t+j})\n", " \\end{aligned} \\tag{43.6}\n", "$$\n", "\n", "Notice how the conditioning sets in equation [(43.6)](#equation-ts-gov-wo3) differ: they are $ s^{t-1} $ on the left side and\n", "$ s^t $ on the right side.\n", "\n", "Now let’s\n", "\n", "- substitute the resource constraint into the net-of-interest government surplus, and \n", "- use the household’s first-order condition $ 1-\\tau^n_t(s^t)= u_{\\ell}(s^t) /u_c(s^t) $ to eliminate the labor tax rate \n", "\n", "\n", "so that we can express the net-of-interest government surplus $ z_t(s^t) $ as\n", "\n", "\n", "\n", "$$\n", "z_t(s^t)\n", " = \\left[1 - {u_{\\ell}(s^t) \\over u_c(s^t)}\\right] \\left[c_t(s^t)+g(s_t)\\right]\n", " -g(s_t) - T_t(s^t)\\,. \\tag{43.7}\n", "$$\n", "\n", "If we substitute appropriate versions of the right side of [(43.7)](#equation-amss-44-2) for $ z_{t+j}(s^{t+j}) $ into equation [(43.6)](#equation-ts-gov-wo3),\n", "we obtain a sequence of *implementability constraints* on a Ramsey allocation in an AMSS economy.\n", "\n", "Expression [(43.6)](#equation-ts-gov-wo3) at time $ t=0 $ and initial state $ s^0 $\n", "was also an *implementability constraint* on a Ramsey allocation in a Lucas-Stokey economy:\n", "\n", "\n", "\n", "$$\n", "b_0(s^{-1}) = \\mathbb E_0 \\sum_{j=0}^\\infty \\beta^j\n", " { u_c(s^{j}) \\over u_c(s^{0}) } \\;z_j(s^{j}) \\tag{43.8}\n", "$$\n", "\n", "Indeed, it was the *only* implementability constraint there.\n", "\n", "But now we also have a large number of additional implementability constraints\n", "\n", "\n", "\n", "$$\n", "b_t(s^{t-1}) = \\mathbb E_t \\sum_{j=0}^\\infty \\beta^j\n", " { u_c(s^{t+j}) \\over u_c(s^{t}) } \\;z_{t+j}(s^{t+j}) \\tag{43.9}\n", "$$\n", "\n", "Equation [(43.9)](#equation-ts-gov-wo4a) must hold for each $ s^t $ for each $ t \\geq 1 $." ] }, { "cell_type": "markdown", "id": "e7da9ce4", "metadata": {}, "source": [ "### Comparison with Lucas-Stokey Economy\n", "\n", "The expression on the right side of [(43.9)](#equation-ts-gov-wo4a) in the Lucas-Stokey (1983) economy would equal the present value of a continuation stream of government net-of-interest surpluses evaluated at what would be competitive equilibrium Arrow-Debreu prices at date $ t $.\n", "\n", "In the Lucas-Stokey economy, that present value is measurable with respect to $ s^t $.\n", "\n", "In the AMSS economy, the restriction that government debt be risk-free imposes that that same present value must be measurable with respect to $ s^{t-1} $.\n", "\n", "In a language used in the literature on incomplete markets models, it can be said that the AMSS model requires that at each $ (t, s^t) $ what would be the present value of continuation government net-of-interest surpluses in the Lucas-Stokey model must belong to the **marketable subspace** of the AMSS model." ] }, { "cell_type": "markdown", "id": "e1751163", "metadata": {}, "source": [ "### Ramsey Problem Without State-contingent Debt\n", "\n", "After we have substituted the resource constraint into the utility function, we can express the Ramsey problem as being to choose an allocation that solves\n", "\n", "$$\n", "\\max_{\\{c_t(s^t),b_{t+1}(s^t)\\}}\n", "\\mathbb E_0 \\sum_{t=0}^\\infty \\beta^t\n", " u\\left(c_t(s^t),1-c_t(s^t)-g(s_t)\\right)\n", "$$\n", "\n", "where the maximization is subject to\n", "\n", "\n", "\n", "$$\n", "\\mathbb E_{0} \\sum_{j=0}^\\infty \\beta^j\n", " { u_c(s^{j}) \\over u_c(s^{0}) } \\;z_j(s^{j}) \\geq b_0(s^{-1}) \\tag{43.10}\n", "$$\n", "\n", "and\n", "\n", "\n", "\n", "$$\n", "\\mathbb E_{t} \\sum_{j=0}^\\infty \\beta^j\n", " { u_c(s^{t+j}) \\over u_c(s^{t}) } \\;\n", " z_{t+j}(s^{t+j}) = b_t(s^{t-1})\n", " \\quad \\forall \\, t, s^t \\tag{43.11}\n", "$$\n", "\n", "given $ b_0(s^{-1}) $." ] }, { "cell_type": "markdown", "id": "493eed31", "metadata": {}, "source": [ "#### Lagrangian Formulation\n", "\n", "Let $ \\gamma_0(s^0) $ be a non-negative Lagrange multiplier on constraint [(43.10)](#equation-amss-44).\n", "\n", "As in the Lucas-Stokey economy, this multiplier is strictly positive when the government must resort to\n", "distortionary taxation; otherwise it equals zero.\n", "\n", "A consequence of the assumption that there are no markets in state-contingent securities and that a market exists only in a risk-free security is that we have to attach a stochastic process $ \\{\\gamma_t(s^t)\\}_{t=1}^\\infty $ of\n", "Lagrange multipliers to the implementability constraints [(43.11)](#equation-amss-46).\n", "\n", "Depending on how the constraints bind, these multipliers can be positive or negative:\n", "\n", "$$\n", "\\begin{aligned}\n", " \\gamma_t(s^t)\n", " &\\;\\geq\\; (\\leq)\\;\\, 0 \\quad \\text{if the constraint binds in the following direction }\n", " \\\\\n", " & \\mathbb E_{t} \\sum_{j=0}^\\infty \\beta^j\n", " { u_c(s^{t+j}) \\over u_c(s^{t}) } \\;z_{t+j}(s^{t+j}) \\;\\geq \\;(\\leq)\\;\\, b_t(s^{t-1})\n", "\\end{aligned}\n", "$$\n", "\n", "A negative multiplier $ \\gamma_t(s^t)<0 $ means that if we could\n", "relax constraint [(43.11)](#equation-amss-46), we would like to *increase* the beginning-of-period\n", "indebtedness for that particular realization of history $ s^t $.\n", "\n", "That would let us reduce the beginning-of-period indebtedness for some other history [2].\n", "\n", "These features flow from the fact that the government cannot use state-contingent debt and therefore cannot allocate its indebtedness efficiently across future states." ] }, { "cell_type": "markdown", "id": "8c196299", "metadata": {}, "source": [ "### Some Calculations\n", "\n", "It is helpful to apply two transformations to the Lagrangian.\n", "\n", "Multiply constraint [(43.10)](#equation-amss-44) by $ u_c(s^0) $ and the constraints [(43.11)](#equation-amss-46) by $ \\beta^t u_c(s^{t}) $.\n", "\n", "Then a Lagrangian for the Ramsey problem can be represented as\n", "\n", "\n", "\n", "$$\n", "\\begin{aligned}\n", " J &= \\mathbb E_{0} \\sum_{t=0}^\\infty \\beta^t\n", " \\biggl\\{ u\\left(c_t(s^t), 1-c_t(s^t)-g(s_t)\\right)\\\\\n", " & \\qquad + \\gamma_t(s^t) \\Bigl[ \\mathbb E_{t} \\sum_{j=0}^\\infty \\beta^j\n", " u_c(s^{t+j}) \\,z_{t+j}(s^{t+j}) - u_c(s^{t}) \\,b_t(s^{t-1}) \\biggr\\}\n", " \\\\\n", " &= \\mathbb E_{0} \\sum_{t=0}^\\infty \\beta^t\n", " \\biggl\\{ u\\left(c_t(s^t), 1-c_t(s^t)-g(s_t)\\right)\n", " \\\\\n", " & \\qquad + \\Psi_t(s^t)\\, u_c(s^{t}) \\,z_t(s^{t}) -\n", " \\gamma_t(s^t)\\, u_c(s^{t}) \\, b_t(s^{t-1}) \\biggr\\}\n", "\\end{aligned} \\tag{43.12}\n", "$$\n", "\n", "where\n", "\n", "\n", "\n", "$$\n", "\\Psi_t(s^t)=\\Psi_{t-1}(s^{t-1})+\\gamma_t(s^t)\n", " \\quad \\text{and} \\quad\n", "\\Psi_{-1}(s^{-1})=0 \\tag{43.13}\n", "$$\n", "\n", "In [(43.12)](#equation-amss-lagr-a), the second equality uses the law of iterated expectations\n", "and Abel’s summation formula (also called *summation by parts*, see\n", "[this page](https://en.wikipedia.org/wiki/Abel%27s_summation_formula)).\n", "\n", "First-order conditions with respect\n", "to $ c_t(s^t) $ can be expressed as\n", "\n", "\n", "\n", "$$\n", "\\begin{aligned}\n", " u_c(s^t)-u_{\\ell}(s^t) &+ \\Psi_t(s^t)\\left\\{ \\left[\n", " u_{cc}(s^t) - u_{c\\ell}(s^{t})\\right]z_t(s^{t}) +\n", " u_{c}(s^{t})\\,z_c(s^{t}) \\right\\}\n", " \\\\\n", " & \\hspace{35mm} - \\gamma_t(s^t)\\left[\n", " u_{cc}(s^{t}) - u_{c\\ell}(s^{t})\\right]b_t(s^{t-1}) =0\n", "\\end{aligned} \\tag{43.14}\n", "$$\n", "\n", "and with respect to $ b_t(s^t) $ as\n", "\n", "\n", "\n", "$$\n", "\\mathbb E_{t} \\left[\\gamma_{t+1}(s^{t+1})\\,u_c(s^{t+1})\\right] = 0 \\tag{43.15}\n", "$$\n", "\n", "If we substitute $ z_t(s^t) $ from [(43.7)](#equation-amss-44-2) and its derivative\n", "$ z_c(s^t) $ into the first-order condition [(43.14)](#equation-amss-foc-a), we find two\n", "differences from the corresponding condition for the optimal allocation\n", "in a Lucas-Stokey economy with state-contingent government debt.\n", "\n", "1. The term involving $ b_t(s^{t-1}) $ in the first-order condition\n", " [(43.14)](#equation-amss-foc-a) does not appear in the corresponding expression\n", " for the Lucas-Stokey economy. \n", " - This term reflects the constraint that\n", " beginning-of-period government indebtedness must be the same across all\n", " realizations of next period’s state, a constraint that would not be present if\n", " government debt could be state-contingent. \n", "1. The Lagrange multiplier $ \\Psi_t(s^t) $ in the first-order condition\n", " [(43.14)](#equation-amss-foc-a) may change over time in response to realizations of the state,\n", " while the multiplier $ \\Phi $ in the Lucas-Stokey economy is time-invariant. \n", "\n", "\n", "We need some code from [an earlier lecture](https://python-advanced.quantecon.org/opt_tax_recur.html)\n", "on optimal taxation with state-contingent debt sequential allocation implementation:" ] }, { "cell_type": "code", "execution_count": null, "id": "2f2dc9ad", "metadata": { "hide-output": false }, "outputs": [], "source": [ "class SequentialLS:\n", "\n", " '''\n", " Class that takes a preference object, state transition matrix,\n", " and state contingent government expenditure plan as inputs, and\n", " solves the sequential allocation problem described above.\n", " It returns optimal allocations about consumption and labor supply,\n", " as well as the multiplier on the implementability constraint Φ.\n", " '''\n", "\n", " def __init__(self,\n", " pref,\n", " π=np.full((2, 2), 0.5),\n", " g=np.array([0.1, 0.2])):\n", "\n", " # Initialize from pref object attributes\n", " self.β, self.π, self.g = pref.β, π, g\n", " self.mc = MarkovChain(self.π)\n", " self.S = len(π) # Number of states\n", " self.pref = pref\n", "\n", " # Find the first best allocation\n", " self.find_first_best()\n", "\n", " def FOC_first_best(self, c, g):\n", " '''\n", " First order conditions that characterize\n", " the first best allocation.\n", " '''\n", "\n", " pref = self.pref\n", " Uc, Ul = pref.Uc, pref.Ul\n", "\n", " n = c + g\n", " l = 1 - n\n", "\n", " return Uc(c, l) - Ul(c, l)\n", "\n", " def find_first_best(self):\n", " '''\n", " Find the first best allocation\n", " '''\n", " S, g = self.S, self.g\n", "\n", " res = root(self.FOC_first_best, np.full(S, 0.5), args=(g,))\n", "\n", " if (res.fun > 1e-10).any():\n", " raise Exception('Could not find first best')\n", "\n", " self.cFB = res.x\n", " self.nFB = self.cFB + g\n", "\n", " def FOC_time1(self, c, Φ, g):\n", " '''\n", " First order conditions that characterize\n", " optimal time 1 allocation problems.\n", " '''\n", "\n", " pref = self.pref\n", " Uc, Ucc, Ul, Ull, Ulc = pref.Uc, pref.Ucc, pref.Ul, pref.Ull, pref.Ulc\n", "\n", " n = c + g\n", " l = 1 - n\n", "\n", " LHS = (1 + Φ) * Uc(c, l) + Φ * (c * Ucc(c, l) - n * Ulc(c, l))\n", " RHS = (1 + Φ) * Ul(c, l) + Φ * (c * Ulc(c, l) - n * Ull(c, l))\n", "\n", " diff = LHS - RHS\n", "\n", " return diff\n", "\n", " def time1_allocation(self, Φ):\n", " '''\n", " Computes optimal allocation for time t >= 1 for a given Φ\n", " '''\n", " pref = self.pref\n", " S, g = self.S, self.g\n", "\n", " # use the first best allocation as intial guess\n", " res = root(self.FOC_time1, self.cFB, args=(Φ, g))\n", "\n", " if (res.fun > 1e-10).any():\n", " raise Exception('Could not find LS allocation.')\n", "\n", " c = res.x\n", " n = c + g\n", " l = 1 - n\n", "\n", " # Compute x\n", " I = pref.Uc(c, n) * c - pref.Ul(c, l) * n\n", " x = np.linalg.solve(np.eye(S) - self.β * self.π, I)\n", "\n", " return c, n, x\n", "\n", " def FOC_time0(self, c0, Φ, g0, b0):\n", " '''\n", " First order conditions that characterize\n", " time 0 allocation problem.\n", " '''\n", "\n", " pref = self.pref\n", " Ucc, Ulc = pref.Ucc, pref.Ulc\n", "\n", " n0 = c0 + g0\n", " l0 = 1 - n0\n", "\n", " diff = self.FOC_time1(c0, Φ, g0)\n", " diff -= Φ * (Ucc(c0, l0) - Ulc(c0, l0)) * b0\n", "\n", " return diff\n", "\n", " def implementability(self, Φ, b0, s0, cn0_arr):\n", " '''\n", " Compute the differences between the RHS and LHS\n", " of the implementability constraint given Φ,\n", " initial debt, and initial state.\n", " '''\n", "\n", " pref, π, g, β = self.pref, self.π, self.g, self.β\n", " Uc, Ul = pref.Uc, pref.Ul\n", " g0 = self.g[s0]\n", "\n", " c, n, x = self.time1_allocation(Φ)\n", "\n", " res = root(self.FOC_time0, cn0_arr[0], args=(Φ, g0, b0))\n", " c0 = res.x\n", " n0 = c0 + g0\n", " l0 = 1 - n0\n", "\n", " cn0_arr[:] = c0.item(), n0.item()\n", "\n", " LHS = Uc(c0, l0) * b0\n", " RHS = Uc(c0, l0) * c0 - Ul(c0, l0) * n0 + β * π[s0] @ x\n", "\n", " return RHS - LHS\n", "\n", " def time0_allocation(self, b0, s0):\n", " '''\n", " Finds the optimal time 0 allocation given\n", " initial government debt b0 and state s0\n", " '''\n", "\n", " # use the first best allocation as initial guess\n", " cn0_arr = np.array([self.cFB[s0], self.nFB[s0]])\n", "\n", " res = root(self.implementability, 0., args=(b0, s0, cn0_arr))\n", "\n", " if (res.fun > 1e-10).any():\n", " raise Exception('Could not find time 0 LS allocation.')\n", "\n", " Φ = res.x[0]\n", " c0, n0 = cn0_arr\n", "\n", " return Φ, c0, n0\n", "\n", " def τ(self, c, n):\n", " '''\n", " Computes τ given c, n\n", " '''\n", " pref = self.pref\n", " Uc, Ul = pref.Uc, pref.Ul\n", "\n", " return 1 - Ul(c, 1-n) / Uc(c, 1-n)\n", "\n", " def simulate(self, b0, s0, T, sHist=None):\n", " '''\n", " Simulates planners policies for T periods\n", " '''\n", " pref, π, β = self.pref, self.π, self.β\n", " Uc = pref.Uc\n", "\n", " if sHist is None:\n", " sHist = self.mc.simulate(T, s0)\n", "\n", " cHist, nHist, Bhist, τHist, ΦHist = np.empty((5, T))\n", " RHist = np.empty(T-1)\n", "\n", " # Time 0\n", " Φ, cHist[0], nHist[0] = self.time0_allocation(b0, s0)\n", " τHist[0] = self.τ(cHist[0], nHist[0])\n", " Bhist[0] = b0\n", " ΦHist[0] = Φ\n", "\n", " # Time 1 onward\n", " for t in range(1, T):\n", " c, n, x = self.time1_allocation(Φ)\n", " τ = self.τ(c, n)\n", " u_c = Uc(c, 1-n)\n", " s = sHist[t]\n", " Eu_c = π[sHist[t-1]] @ u_c\n", " cHist[t], nHist[t], Bhist[t], τHist[t] = c[s], n[s], x[s] / u_c[s], τ[s]\n", " RHist[t-1] = Uc(cHist[t-1], 1-nHist[t-1]) / (β * Eu_c)\n", " ΦHist[t] = Φ\n", "\n", " gHist = self.g[sHist]\n", " yHist = nHist\n", "\n", " return [cHist, nHist, Bhist, τHist, gHist, yHist, sHist, ΦHist, RHist]" ] }, { "cell_type": "markdown", "id": "656e12d8", "metadata": {}, "source": [ "To analyze the AMSS model, we find it useful to adopt a recursive formulation\n", "using techniques like those in our lectures on [dynamic Stackelberg models](https://python-advanced.quantecon.org/dyn_stack.html) and [optimal taxation with state-contingent debt](https://python-advanced.quantecon.org/opt_tax_recur.html)." ] }, { "cell_type": "markdown", "id": "a082fe23", "metadata": {}, "source": [ "## Recursive Version of AMSS Model\n", "\n", "We now describe a recursive formulation of the AMSS economy.\n", "\n", "We have noted that from the point of view of the Ramsey planner, the restriction\n", "to one-period risk-free securities\n", "\n", "- leaves intact the single implementability constraint on allocations\n", " [(43.8)](#equation-ts-gov-wo4) from the Lucas-Stokey economy, but \n", "- adds measurability constraints [(43.6)](#equation-ts-gov-wo3) on functions of tails of\n", " allocations at each time and history \n", "\n", "\n", "We now explore how these constraints alter Bellman equations for a time\n", "$ 0 $ Ramsey planner and for time $ t \\geq 1 $, history $ s^t $\n", "continuation Ramsey planners." ] }, { "cell_type": "markdown", "id": "07f778dd", "metadata": {}, "source": [ "### Recasting State Variables\n", "\n", "In the AMSS setting, the government faces a sequence of budget constraints\n", "\n", "$$\n", "\\tau_t(s^t) n_t(s^t) + T_t(s^t) + b_{t+1}(s^t)/ R_t (s^t) = g_t + b_t(s^{t-1})\n", "$$\n", "\n", "where $ R_t(s^t) $ is the gross risk-free rate of interest between $ t $\n", "and $ t+1 $ at history $ s^t $ and $ T_t(s^t) $ are non-negative transfers.\n", "\n", "Throughout this lecture, we shall set transfers to zero (for some issues about the limiting behavior of debt, this is possibly an important difference from AMSS [[AMSSeppala02](https://python-advanced.quantecon.org/zreferences.html#id130)], who restricted transfers\n", "to be non-negative).\n", "\n", "In this case, the household faces a sequence of budget constraints\n", "\n", "\n", "\n", "$$\n", "b_t(s^{t-1}) + (1-\\tau_t(s^t)) n_t(s^t) = c_t(s^t) + b_{t+1}(s^t)/R_t(s^t) \\tag{43.16}\n", "$$\n", "\n", "The household’s first-order conditions are $ u_{c,t} = \\beta R_t \\mathbb E_t u_{c,t+1} $\n", "and $ (1-\\tau_t) u_{c,t} = u_{l,t} $.\n", "\n", "Using these to eliminate $ R_t $ and $ \\tau_t $ from budget constraint\n", "[(43.16)](#equation-eqn-amssapp1) gives\n", "\n", "\n", "\n", "$$\n", "b_t(s^{t-1}) + \\frac{u_{l,t}(s^t)}{u_{c,t}(s^t)} n_t(s^t)\n", "= c_t(s^t) + {\\frac{\\beta (\\mathbb E_t u_{c,t+1}) b_{t+1}(s^t)}{u_{c,t}(s^t)}} \\tag{43.17}\n", "$$\n", "\n", "or\n", "\n", "\n", "\n", "$$\n", "u_{c,t}(s^t) b_t(s^{t-1}) + u_{l,t}(s^t) n_t(s^t)\n", "= u_{c,t}(s^t) c_t(s^t) + \\beta (\\mathbb E_t u_{c,t+1}) b_{t+1}(s^t) \\tag{43.18}\n", "$$\n", "\n", "Now define\n", "\n", "\n", "\n", "$$\n", "x_t \\equiv \\beta b_{t+1}(s^t) \\mathbb E_t u_{c,t+1} = u_{c,t} (s^t) {\\frac{b_{t+1}(s^t)}{R_t(s^t)}} \\tag{43.19}\n", "$$\n", "\n", "and represent the household’s budget constraint at time $ t $,\n", "history $ s^t $ as\n", "\n", "\n", "\n", "$$\n", "{\\frac{u_{c,t} x_{t-1}}{\\beta \\mathbb E_{t-1} u_{c,t}}} = u_{c,t} c_t - u_{l,t} n_t + x_t \\tag{43.20}\n", "$$\n", "\n", "for $ t \\geq 1 $." ] }, { "cell_type": "markdown", "id": "c8b1bd4b", "metadata": {}, "source": [ "### Measurability Constraints\n", "\n", "Write equation [(43.18)](#equation-eqn-amssapp2) as\n", "\n", "\n", "\n", "$$\n", "b_t(s^{t-1}) = c_t(s^t) - { \\frac{u_{l,t}(s^t)}{u_{c,t}(s^t)}} n_t(s^t) +\n", "{\\frac{\\beta (\\mathbb E_t u_{c,t+1}) b_{t+1}(s^t)}{u_{c,t}}} \\tag{43.21}\n", "$$\n", "\n", "The right side of equation [(43.21)](#equation-eqn-amssapp2b) expresses the time $ t $ value of government debt\n", "in terms of a linear combination of terms whose individual components\n", "are measurable with respect to $ s^t $.\n", "\n", "The sum of terms on the right side of equation [(43.21)](#equation-eqn-amssapp2b) must equal\n", "$ b_t(s^{t-1}) $.\n", "\n", "That implies that it has to be *measurable* with respect to $ s^{t-1} $.\n", "\n", "Equations [(43.21)](#equation-eqn-amssapp2b) are the *measurability constraints* that the AMSS model adds to the single time $ 0 $ implementation\n", "constraint imposed in the Lucas and Stokey model." ] }, { "cell_type": "markdown", "id": "c6252ed1", "metadata": {}, "source": [ "### Two Bellman Equations\n", "\n", "Let $ \\Pi(s|s_-) $ be a Markov transition matrix whose entries tell probabilities of moving from state $ s_- $ to state $ s $ in one period.\n", "\n", "Let\n", "\n", "- $ V(x_-, s_-) $ be the continuation value of a continuation\n", " Ramsey plan at $ x_{t-1} = x_-, s_{t-1} =s_- $ for $ t \\geq 1 $ \n", "- $ W(b, s) $ be the value of the Ramsey plan at time $ 0 $ at\n", " $ b_0=b $ and $ s_0 = s $ \n", "\n", "\n", "We distinguish between two types of planners:\n", "\n", "For $ t \\geq 1 $, the value function for a **continuation Ramsey planner**\n", "satisfies the Bellman equation\n", "\n", "\n", "\n", "$$\n", "V(x_-,s_-) = \\max_{\\{n(s), x(s)\\}} \\sum_s \\Pi(s|s_-) \\left[ u(n(s) -\n", "g(s), 1-n(s)) + \\beta V(x(s),s) \\right] \\tag{43.22}\n", "$$\n", "\n", "subject to the following collection of implementability constraints, one\n", "for each $ s \\in {\\cal S} $:\n", "\n", "\n", "\n", "$$\n", "{\\frac{u_c(s) x_- }{\\beta \\sum_{\\tilde s} \\Pi(\\tilde s|s_-) u_c(\\tilde s) }}\n", "= u_c(s) (n(s) - g(s)) - u_l(s) n(s) + x(s) \\tag{43.23}\n", "$$\n", "\n", "A continuation Ramsey planner at $ t \\geq 1 $ takes\n", "$ (x_{t-1}, s_{t-1}) = (x_-, s_-) $ as given and before\n", "$ s $ is realized chooses\n", "$ (n_t(s_t), x_t(s_t)) = (n(s), x(s)) $ for $ s \\in {\\cal S} $.\n", "\n", "The **Ramsey planner** takes $ (b_0, s_0) $ as given and chooses $ (n_0, x_0) $.\n", "\n", "The value function $ W(b_0, s_0) $ for the time $ t=0 $ Ramsey planner\n", "satisfies the Bellman equation\n", "\n", "\n", "\n", "$$\n", "W(b_0, s_0) = \\max_{n_0, x_0} u(n_0 - g_0, 1-n_0) + \\beta V(x_0,s_0) \\tag{43.24}\n", "$$\n", "\n", "where maximization is subject to\n", "\n", "\n", "\n", "$$\n", "u_{c,0} b_0 = u_{c,0} (n_0-g_0) - u_{l,0} n_0 + x_0 \\tag{43.25}\n", "$$" ] }, { "cell_type": "markdown", "id": "72fe2873", "metadata": {}, "source": [ "### Martingale Supercedes State-Variable Degeneracy\n", "\n", "Let $ \\mu(s|s_-) \\Pi(s|s_-) $ be a Lagrange multiplier on the constraint [(43.23)](#equation-eqn-amssapp6)\n", "for state $ s $.\n", "\n", "After forming an appropriate Lagrangian, we find that the continuation Ramsey planner’s first-order\n", "condition with respect to $ x(s) $ is\n", "\n", "\n", "\n", "$$\n", "\\beta V_x(x(s),s) = \\mu(s|s_-) \\tag{43.26}\n", "$$\n", "\n", "Applying an envelope theorem to Bellman equation [(43.22)](#equation-eqn-amssapp5) gives\n", "\n", "\n", "\n", "$$\n", "V_x(x_-,s_-) = \\sum_s \\Pi(s|s_-) \\mu(s|s_-) {\\frac{u_c(s)}{\\beta \\sum_{\\tilde s}\n", "\\Pi(\\tilde s|s_-) u_c(\\tilde s) }} \\tag{43.27}\n", "$$\n", "\n", "Equations [(43.26)](#equation-eqn-amssapp7) and [(43.27)](#equation-eqn-amssapp8) imply that\n", "\n", "\n", "\n", "$$\n", "V_x(x_-, s_-) = \\sum_{s} \\left( \\Pi(s|s_-) {\\frac{u_c(s)}{\\sum_{\\tilde s}\n", "\\Pi(\\tilde s| s_-) u_c(\\tilde s)}} \\right) V_x(x, s) \\tag{43.28}\n", "$$\n", "\n", "Equation [(43.28)](#equation-eqn-amssapp9) states that $ V_x(x, s) $ is a *risk-adjusted martingale*.\n", "\n", "Saying that $ V_x(x, s) $ is a risk-adjusted martingale means that\n", "$ V_x(x, s) $ is a martingale with respect to the probability distribution\n", "over $ s^t $ sequences that are generated by the *twisted* transition probability matrix:\n", "\n", "$$\n", "\\check \\Pi(s|s_-) \\equiv \\Pi(s|s_-) {\\frac{u_c(s)}{\\sum_{\\tilde s}\n", "\\Pi(\\tilde s| s_-) u_c(\\tilde s)}}\n", "$$" ] }, { "cell_type": "markdown", "id": "8048f5e9", "metadata": {}, "source": [ "### Exercise 43.1\n", "\n", "Please verify that $ \\check \\Pi(s|s_-) $ is a valid Markov\n", "transition density, i.e., that its elements are all non-negative and\n", "that for each $ s_- $, the sum over $ s $ equals unity." ] }, { "cell_type": "markdown", "id": "88a1038c", "metadata": {}, "source": [ "### Absence of State Variable Degeneracy\n", "\n", "Along a Ramsey plan, the state variable $ x_t = x_t(s^t, b_0) $\n", "becomes a function of the history $ s^t $ and initial\n", "government debt $ b_0 $.\n", "\n", "In [Lucas-Stokey model](https://python-advanced.quantecon.org/opt_tax_recur.html), we\n", "found that\n", "\n", "- a counterpart to $ V_x(x,s) $ is time-invariant and equal to\n", " the Lagrange multiplier on the Lucas-Stokey implementability constraint \n", "- time invariance of $ V_x(x,s) $ is the source of a key\n", " feature of the Lucas-Stokey model, namely, **state variable degeneracy** in which $ x_t $ is an exact time-invariant function of $ s_t $. \n", "\n", "\n", "That $ V_x(x,s) $ varies over time according to a twisted martingale\n", "means that there is no state-variable degeneracy in the AMSS model.\n", "\n", "In the AMSS model, both $ x $ and $ s $ are needed to describe the state.\n", "\n", "This property of the AMSS model transmits a twisted martingale\n", "component to consumption, employment, and the tax rate." ] }, { "cell_type": "markdown", "id": "4018ce40", "metadata": {}, "source": [ "### Digression on Non-negative Transfers\n", "\n", "Throughout this lecture, we have imposed that transfers $ T_t = 0 $.\n", "\n", "AMSS [[AMSSeppala02](https://python-advanced.quantecon.org/zreferences.html#id130)] instead imposed a nonnegativity\n", "constraint $ T_t\\geq 0 $ on transfers.\n", "\n", "They also considered a special case of quasi-linear preferences,\n", "$ u(c,l)= c + H(l) $.\n", "\n", "In this case, $ V_x(x,s)\\leq 0 $ is a non-positive martingale.\n", "\n", "By the *martingale convergence theorem* $ V_x(x,s) $ converges almost surely.\n", "\n", "Furthermore, when the Markov chain $ \\Pi(s| s_-) $ and the government\n", "expenditure function $ g(s) $ are such that $ g_t $ is perpetually\n", "random, $ V_x(x, s) $ almost surely converges to zero.\n", "\n", "For quasi-linear preferences, the first-order condition for maximizing [(43.22)](#equation-eqn-amssapp5) subject to [(43.23)](#equation-eqn-amssapp6) with respect to $ n(s) $ becomes\n", "\n", "$$\n", "(1-\\mu(s|s_-) ) (1 - u_l(s)) + \\mu(s|s_-) n(s) u_{ll}(s) =0\n", "$$\n", "\n", "When $ \\mu(s|s_-) = \\beta V_x(x(s),x) $ converges to zero, in the limit\n", "$ u_l(s)= 1 =u_c(s) $, so that $ \\tau(x(s),s) =0 $.\n", "\n", "Thus, in the limit, if $ g_t $ is perpetually random, the government\n", "accumulates sufficient assets to finance all expenditures from earnings on those\n", "assets, returning any excess revenues to the household as non-negative lump-sum transfers." ] }, { "cell_type": "markdown", "id": "b20527e6", "metadata": {}, "source": [ "### Code\n", "\n", "The recursive formulation is implemented as follows" ] }, { "cell_type": "code", "execution_count": null, "id": "fb0137a4", "metadata": { "hide-output": false }, "outputs": [], "source": [ "class AMSS:\n", " # WARNING: THE CODE IS EXTREMELY SENSITIVE TO CHOCIES OF PARAMETERS.\n", " # DO NOT CHANGE THE PARAMETERS AND EXPECT IT TO WORK\n", "\n", " def __init__(self, pref, β, Π, g, x_grid, bounds_v):\n", " self.β, self.Π, self.g = β, Π, g\n", " self.x_grid = x_grid\n", " self.n = x_grid[0][2]\n", " self.S = len(Π)\n", " self.bounds = bounds_v\n", " self.pref = pref\n", "\n", " self.T_v, self.T_w = bellman_operator_factory(Π, β, x_grid, g,\n", " bounds_v)\n", "\n", " self.V_solved = False\n", " self.W_solved = False\n", "\n", " def compute_V(self, V, σ_v_star, tol_vfi, maxitr, print_itr):\n", "\n", " T_v = self.T_v\n", "\n", " self.success = False\n", "\n", " V_new = np.zeros_like(V)\n", "\n", " Δ = 1.0\n", " for itr in range(maxitr):\n", " T_v(V, V_new, σ_v_star, self.pref)\n", "\n", " Δ = np.max(np.abs(V_new - V))\n", "\n", " if Δ < tol_vfi:\n", " self.V_solved = True\n", " print('Successfully completed VFI after %i iterations'\n", " % (itr+1))\n", " break\n", "\n", " if (itr + 1) % print_itr == 0:\n", " print('Error at iteration %i : ' % (itr + 1), Δ)\n", "\n", " V[:] = V_new[:]\n", "\n", " self.V = V\n", " self.σ_v_star = σ_v_star\n", "\n", " return V, σ_v_star\n", "\n", " def compute_W(self, b_0, W, σ_w_star):\n", " T_w = self.T_w\n", " V = self.V\n", "\n", " T_w(W, σ_w_star, V, b_0, self.pref)\n", "\n", " self.W = W\n", " self.σ_w_star = σ_w_star\n", " self.W_solved = True\n", " print('Succesfully solved the time 0 problem.')\n", "\n", " return W, σ_w_star\n", "\n", " def solve(self, V, σ_v_star, b_0, W, σ_w_star, tol_vfi=1e-7,\n", " maxitr=1000, print_itr=10):\n", " print(\"===============\")\n", " print(\"Solve time 1 problem\")\n", " print(\"===============\")\n", " self.compute_V(V, σ_v_star, tol_vfi, maxitr, print_itr)\n", " print(\"===============\")\n", " print(\"Solve time 0 problem\")\n", " print(\"===============\")\n", " self.compute_W(b_0, W, σ_w_star)\n", "\n", " def simulate(self, s_hist, b_0):\n", " if not (self.V_solved and self.W_solved):\n", " msg = \"V and W need to be successfully computed before simulation.\"\n", " raise ValueError(msg)\n", "\n", " pref = self.pref\n", " x_grid, g, β, S = self.x_grid, self.g, self.β, self.S\n", " σ_v_star, σ_w_star = self.σ_v_star, self.σ_w_star\n", "\n", " T = len(s_hist)\n", " s_0 = s_hist[0]\n", "\n", " # Pre-allocate\n", " n_hist = np.zeros(T)\n", " x_hist = np.zeros(T)\n", " c_hist = np.zeros(T)\n", " τ_hist = np.zeros(T)\n", " b_hist = np.zeros(T)\n", " g_hist = np.zeros(T)\n", "\n", " # Compute t = 0\n", " l_0, T_0 = σ_w_star[s_0]\n", " c_0 = (1 - l_0) - g[s_0]\n", " x_0 = (-pref.Uc(c_0, l_0) * (c_0 - T_0 - b_0) +\n", " pref.Ul(c_0, l_0) * (1 - l_0))\n", "\n", " n_hist[0] = (1 - l_0)\n", " x_hist[0] = x_0\n", " c_hist[0] = c_0\n", " τ_hist[0] = 1 - pref.Ul(c_0, l_0) / pref.Uc(c_0, l_0)\n", " b_hist[0] = b_0\n", " g_hist[0] = g[s_0]\n", "\n", " # Compute t > 0\n", " for t in range(T - 1):\n", " x_ = x_hist[t]\n", " s_ = s_hist[t]\n", " l = np.zeros(S)\n", " T = np.zeros(S)\n", " for s in range(S):\n", " x_arr = np.array([x_])\n", " l[s] = eval_linear(x_grid, σ_v_star[s_, :, s], x_arr)\n", " T[s] = eval_linear(x_grid, σ_v_star[s_, :, S+s], x_arr)\n", "\n", " c = (1 - l) - g\n", " u_c = pref.Uc(c, l)\n", " Eu_c = Π[s_] @ u_c\n", "\n", " x = u_c * x_ / (β * Eu_c) - u_c * (c - T) + pref.Ul(c, l) * (1 - l)\n", "\n", " c_next = c[s_hist[t+1]]\n", " l_next = l[s_hist[t+1]]\n", "\n", " x_hist[t+1] = x[s_hist[t+1]]\n", " n_hist[t+1] = 1 - l_next\n", " c_hist[t+1] = c_next\n", " τ_hist[t+1] = 1 - pref.Ul(c_next, l_next) / pref.Uc(c_next, l_next)\n", " b_hist[t+1] = x_ / (β * Eu_c)\n", " g_hist[t+1] = g[s_hist[t+1]]\n", "\n", " return c_hist, n_hist, b_hist, τ_hist, g_hist, n_hist\n", "\n", "\n", "def obj_factory(Π, β, x_grid, g):\n", " S = len(Π)\n", "\n", " @njit\n", " def obj_V(σ, state, V, pref):\n", " # Unpack state\n", " s_, x_ = state\n", "\n", " l = σ[:S]\n", " T = σ[S:]\n", "\n", " c = (1 - l) - g\n", " u_c = pref.Uc(c, l)\n", " Eu_c = Π[s_] @ u_c\n", " x = u_c * x_ / (β * Eu_c) - u_c * (c - T) + pref.Ul(c, l) * (1 - l)\n", "\n", " V_next = np.zeros(S)\n", "\n", " for s in range(S):\n", " V_next[s] = eval_linear(x_grid, V[s], np.array([x[s]]))\n", "\n", " out = Π[s_] @ (pref.U(c, l) + β * V_next)\n", "\n", " return out\n", "\n", " @njit\n", " def obj_W(σ, state, V, pref):\n", " # Unpack state\n", " s_, b_0 = state\n", " l, T = σ\n", "\n", " c = (1 - l) - g[s_]\n", " x = -pref.Uc(c, l) * (c - T - b_0) + pref.Ul(c, l) * (1 - l)\n", "\n", " V_next = eval_linear(x_grid, V[s_], np.array([x]))\n", "\n", " out = pref.U(c, l) + β * V_next\n", "\n", " return out\n", "\n", " return obj_V, obj_W\n", "\n", "\n", "def bellman_operator_factory(Π, β, x_grid, g, bounds_v):\n", " obj_V, obj_W = obj_factory(Π, β, x_grid, g)\n", " n = x_grid[0][2]\n", " S = len(Π)\n", " x_nodes = nodes(x_grid)\n", "\n", " @njit(parallel=True)\n", " def T_v(V, V_new, σ_star, pref):\n", " for s_ in prange(S):\n", " for x_i in prange(n):\n", " state = (s_, x_nodes[x_i])\n", " x0 = σ_star[s_, x_i]\n", " res = optimize.nelder_mead(obj_V, x0, bounds=bounds_v,\n", " args=(state, V, pref))\n", "\n", " if res.success:\n", " V_new[s_, x_i] = res.fun\n", " σ_star[s_, x_i] = res.x\n", " else:\n", " print(\"Optimization routine failed.\")\n", "\n", " bounds_w = np.array([[-9.0, 1.0], [0., 10.]])\n", "\n", " def T_w(W, σ_star, V, b_0, pref):\n", " for s_ in prange(S):\n", " state = (s_, b_0)\n", " x0 = σ_star[s_]\n", " res = optimize.nelder_mead(obj_W, x0, bounds=bounds_w,\n", " args=(state, V, pref))\n", "\n", " W[s_] = res.fun\n", " σ_star[s_] = res.x\n", "\n", " return T_v, T_w" ] }, { "cell_type": "markdown", "id": "92004021", "metadata": {}, "source": [ "## Examples\n", "\n", "We now turn to some examples." ] }, { "cell_type": "markdown", "id": "601d350e", "metadata": {}, "source": [ "### Anticipated One-Period War\n", "\n", "In our lecture on [optimal taxation with state-contingent debt](https://python-advanced.quantecon.org/opt_tax_recur.html)\n", "we studied how the government manages uncertainty in a simple setting.\n", "\n", "As in that lecture, we assume the one-period utility function\n", "\n", "$$\n", "u(c,n) = {\\frac{c^{1-\\sigma}}{1-\\sigma}} - {\\frac{n^{1+\\gamma}}{1+\\gamma}}\n", "$$\n", "\n", ">**Note**\n", ">\n", ">For convenience in matching our computer code, we have expressed\n", "utility as a function of $ n $ rather than leisure $ l $.\n", "\n", "We first consider a government expenditure process that we studied earlier in a lecture on\n", "[optimal taxation with state-contingent debt](https://python-advanced.quantecon.org/opt_tax_recur.html).\n", "\n", "Government expenditures are known for sure in all periods except one.\n", "\n", "- For $ t<3 $ or $ t > 3 $ we assume that $ g_t = g_l = 0.1 $. \n", "- At $ t = 3 $ a war occurs with probability 0.5. \n", " - If there is war, $ g_3 = g_h = 0.2 $. \n", " - If there is no war $ g_3 = g_l = 0.1 $. \n", "\n", "\n", "A useful trick is to define components of the state vector as the following six\n", "$ (t,g) $ pairs:\n", "\n", "$$\n", "(0,g_l), (1,g_l), (2,g_l), (3,g_l), (3,g_h), (t\\geq 4,g_l)\n", "$$\n", "\n", "We think of these 6 states as corresponding to $ s=1,2,3,4,5,6 $.\n", "\n", "The transition matrix is\n", "\n", "$$\n", "P = \\begin{pmatrix}\n", " 0 & 1 & 0 & 0 & 0 & 0\\\\\n", " 0 & 0 & 1 & 0 & 0 & 0\\\\\n", " 0 & 0 & 0 & 0.5 & 0.5 & 0\\\\\n", " 0 & 0 & 0 & 0 & 0 & 1\\\\\n", " 0 & 0 & 0 & 0 & 0 & 1\\\\\n", " 0 & 0 & 0 & 0 & 0 & 1\n", "\\end{pmatrix}\n", "$$\n", "\n", "The government expenditure at each state is\n", "\n", "$$\n", "g = \\left(\\begin{matrix} 0.1\\\\0.1\\\\0.1\\\\0.1\\\\0.2\\\\0.1 \\end{matrix}\\right)\n", "$$\n", "\n", "We assume the same utility parameters as in the [Lucas-Stokey economy](https://python-advanced.quantecon.org/opt_tax_recur.html).\n", "\n", "This utility function is implemented in the following class." ] }, { "cell_type": "code", "execution_count": null, "id": "857b8b17", "metadata": { "hide-output": false }, "outputs": [], "source": [ "crra_util_data = [\n", " ('β', float64),\n", " ('σ', float64),\n", " ('γ', float64)\n", "]\n", "\n", "@jitclass(crra_util_data)\n", "class CRRAutility:\n", "\n", " def __init__(self,\n", " β=0.9,\n", " σ=2,\n", " γ=2):\n", "\n", " self.β, self.σ, self.γ = β, σ, γ\n", "\n", " # Utility function\n", " def U(self, c, l):\n", " # Note: `l` should not be interpreted as labor, it is an auxiliary\n", " # variable used to conveniently match the code and the equations\n", " # in the lecture\n", " σ = self.σ\n", " if σ == 1.:\n", " U = np.log(c)\n", " else:\n", " U = (c**(1 - σ) - 1) / (1 - σ)\n", " return U - (1-l) ** (1 + self.γ) / (1 + self.γ)\n", "\n", " # Derivatives of utility function\n", " def Uc(self, c, l):\n", " return c ** (-self.σ)\n", "\n", " def Ucc(self, c, l):\n", " return -self.σ * c ** (-self.σ - 1)\n", "\n", " def Ul(self, c, l):\n", " return (1-l) ** self.γ\n", "\n", " def Ull(self, c, l):\n", " return -self.γ * (1-l) ** (self.γ - 1)\n", "\n", " def Ucl(self, c, l):\n", " return 0\n", "\n", " def Ulc(self, c, l):\n", " return 0" ] }, { "cell_type": "markdown", "id": "033350a9", "metadata": {}, "source": [ "The following figure plots Ramsey plans under complete and incomplete\n", "markets for both possible realizations of the state at time $ t=3 $.\n", "\n", "Ramsey outcomes and policies when the government has access to state-contingent debt are\n", "represented by black lines and by red lines when there is only a risk-free bond.\n", "\n", "Paths with circles are histories in which there is peace, while those with\n", "triangle denote war." ] }, { "cell_type": "code", "execution_count": null, "id": "47808f60", "metadata": { "hide-output": false }, "outputs": [], "source": [ "# WARNING: DO NOT EXPECT THE CODE TO WORK IF YOU CHANGE PARAMETERS\n", "σ = 2\n", "γ = 2\n", "β = 0.9\n", "Π = np.array([[0, 1, 0, 0, 0, 0],\n", " [0, 0, 1, 0, 0, 0],\n", " [0, 0, 0, 0.5, 0.5, 0],\n", " [0, 0, 0, 0, 0, 1],\n", " [0, 0, 0, 0, 0, 1],\n", " [0, 0, 0, 0, 0, 1]])\n", "g = np.array([0.1, 0.1, 0.1, 0.2, 0.1, 0.1])\n", "\n", "x_min = -1.5555\n", "x_max = 17.339\n", "x_num = 300\n", "\n", "x_grid = UCGrid((x_min, x_max, x_num))\n", "\n", "crra_pref = CRRAutility(β=β, σ=σ, γ=γ)\n", "\n", "S = len(Π)\n", "bounds_v = np.vstack([np.hstack([np.full(S, -10.), np.zeros(S)]),\n", " np.hstack([np.ones(S) - g, np.full(S, 10.)])]).T\n", "\n", "amss_model = AMSS(crra_pref, β, Π, g, x_grid, bounds_v)" ] }, { "cell_type": "code", "execution_count": null, "id": "25e353fc", "metadata": { "hide-output": false }, "outputs": [], "source": [ "# WARNING: DO NOT EXPECT THE CODE TO WORK IF YOU CHANGE PARAMETERS\n", "V = np.zeros((len(Π), x_num))\n", "V[:] = -nodes(x_grid).T ** 2\n", "\n", "σ_v_star = np.ones((S, x_num, S * 2))\n", "σ_v_star[:, :, :S] = 0.0\n", "\n", "W = np.empty(len(Π))\n", "b_0 = 1.0\n", "σ_w_star = np.ones((S, 2))\n", "σ_w_star[:, 0] = -0.05" ] }, { "cell_type": "code", "execution_count": null, "id": "c5c932f7", "metadata": { "hide-output": false }, "outputs": [], "source": [ "%%time\n", "\n", "amss_model.solve(V, σ_v_star, b_0, W, σ_w_star)" ] }, { "cell_type": "code", "execution_count": null, "id": "7297b9b8", "metadata": { "hide-output": false }, "outputs": [], "source": [ "# Solve the LS model\n", "ls_model = SequentialLS(crra_pref, g=g, π=Π)" ] }, { "cell_type": "code", "execution_count": null, "id": "bb43b541", "metadata": { "hide-output": false }, "outputs": [], "source": [ "# WARNING: DO NOT EXPECT THE CODE TO WORK IF YOU CHANGE PARAMETERS\n", "s_hist_h = np.array([0, 1, 2, 3, 5, 5, 5])\n", "s_hist_l = np.array([0, 1, 2, 4, 5, 5, 5])\n", "\n", "sim_h_amss = amss_model.simulate(s_hist_h, b_0)\n", "sim_l_amss = amss_model.simulate(s_hist_l, b_0)\n", "\n", "sim_h_ls = ls_model.simulate(b_0, 0, 7, s_hist_h)\n", "sim_l_ls = ls_model.simulate(b_0, 0, 7, s_hist_l)\n", "\n", "fig, axes = plt.subplots(3, 2, figsize=(14, 10))\n", "titles = ['Consumption', 'Labor Supply', 'Government Debt',\n", " 'Tax Rate', 'Government Spending', 'Output']\n", "\n", "for ax, title, ls_l, ls_h, amss_l, amss_h in zip(axes.flatten(), titles,\n", " sim_l_ls, sim_h_ls,\n", " sim_l_amss, sim_h_amss):\n", " ax.plot(ls_l, '-ok', ls_h, '-^k', amss_l, '-or', amss_h, '-^r',\n", " alpha=0.7)\n", " ax.set(title=title)\n", " ax.grid()\n", "\n", "plt.tight_layout()\n", "plt.show()" ] }, { "cell_type": "markdown", "id": "b2754ce8", "metadata": {}, "source": [ "How a Ramsey planner responds to war depends on the structure of the asset market.\n", "\n", "If it is able to trade state-contingent debt, then at time $ t=2 $\n", "\n", "- the government **purchases** an Arrow security that pays off when $ g_3 = g_h $ \n", "- the government **sells** an Arrow security that pays off when $ g_3 = g_l $ \n", "- the Ramsey planner designs these purchases and sales designed so that, regardless of whether or not there is a war at $ t=3 $, the government begins period $ t=4 $ with the *same* government debt \n", "\n", "\n", "This pattern facilities smoothing tax rates across states.\n", "\n", "The government without state-contingent debt cannot do this.\n", "\n", "Instead, it must enter time $ t=3 $ with the same level of debt falling due whether there is peace or war at $ t=3 $.\n", "\n", "The risk-free rate between time $ 2 $ and time $ 3 $ is unusually **low** because at time $ 2 $ consumption at time $ 3 $ is expected to be unusually **low**.\n", "\n", "A **low** risk-free rate of return on government debt between time $ 2 $ and time $ 3 $ allows the government to enter period $ 3 $ with **lower** government debt than it entered period $ 2 $.\n", "\n", "To finance a war at time $ 3 $ it raises taxes and issues more debt to carry into perpetual peace that begins in period $ 4 $.\n", "\n", "To service the additional debt burden, it raises taxes in all future periods.\n", "\n", "The absence of state-contingent debt leads to an important difference in the\n", "optimal tax policy.\n", "\n", "When the Ramsey planner has access to state-contingent debt, the optimal tax\n", "policy is history independent\n", "\n", "- the tax rate is a function of the current level of government spending only,\n", " given the Lagrange multiplier on the implementability constraint \n", "\n", "\n", "Without state-contingent debt, the optimal tax rate is history dependent.\n", "\n", "- A war at time $ t=3 $ causes a permanent **increase** in the tax rate. \n", "- Peace at time $ t=3 $ causes a permanent **reduction** in the tax rate. " ] }, { "cell_type": "markdown", "id": "4670fd17", "metadata": {}, "source": [ "#### Perpetual War Alert\n", "\n", "History dependence occurs more dramatically in a case in which the government\n", "perpetually faces the prospect of war.\n", "\n", "This case was studied in the final example of the lecture on\n", "[optimal taxation with state-contingent debt](https://python-advanced.quantecon.org/opt_tax_recur.html).\n", "\n", "There, each period the government faces a constant probability, $ 0.5 $, of war.\n", "\n", "In addition, this example features the following preferences\n", "\n", "$$\n", "u(c,n) = \\log(c) + 0.69 \\log(1-n)\n", "$$\n", "\n", "In accordance, we will re-define our utility function." ] }, { "cell_type": "code", "execution_count": null, "id": "edb579e6", "metadata": { "hide-output": false }, "outputs": [], "source": [ "log_util_data = [\n", " ('β', float64),\n", " ('ψ', float64)\n", "]\n", "\n", "@jitclass(log_util_data)\n", "class LogUtility:\n", "\n", " def __init__(self,\n", " β=0.9,\n", " ψ=0.69):\n", "\n", " self.β, self.ψ = β, ψ\n", "\n", " # Utility function\n", " def U(self, c, l):\n", " return np.log(c) + self.ψ * np.log(l)\n", "\n", " # Derivatives of utility function\n", " def Uc(self, c, l):\n", " return 1 / c\n", "\n", " def Ucc(self, c, l):\n", " return -c**(-2)\n", "\n", " def Ul(self, c, l):\n", " return self.ψ / l\n", "\n", " def Ull(self, c, l):\n", " return -self.ψ / l**2\n", "\n", " def Ucl(self, c, l):\n", " return 0\n", "\n", " def Ulc(self, c, l):\n", " return 0" ] }, { "cell_type": "markdown", "id": "7d9ba310", "metadata": {}, "source": [ "With these preferences, Ramsey tax rates will vary even in the Lucas-Stokey\n", "model with state-contingent debt.\n", "\n", "The figure below plots optimal tax policies for both the economy with\n", "state-contingent debt (circles) and the economy with only a risk-free bond\n", "(triangles)." ] }, { "cell_type": "code", "execution_count": null, "id": "c6ca6ea3", "metadata": { "hide-output": false }, "outputs": [], "source": [ "# WARNING: DO NOT EXPECT THE CODE TO WORK IF YOU CHANGE PARAMETERS\n", "ψ = 0.69\n", "Π = np.full((2, 2), 0.5)\n", "β = 0.9\n", "g = np.array([0.1, 0.2])\n", "\n", "x_min = -3.4107\n", "x_max = 3.709\n", "x_num = 300\n", "\n", "x_grid = UCGrid((x_min, x_max, x_num))\n", "log_pref = LogUtility(β=β, ψ=ψ)\n", "\n", "S = len(Π)\n", "bounds_v = np.vstack([np.zeros(2 * S), np.hstack([1 - g, np.ones(S)]) ]).T\n", "\n", "V = np.zeros((len(Π), x_num))\n", "V[:] = -(nodes(x_grid).T + x_max) ** 2 / 14\n", "\n", "σ_v_star = 1 - np.full((S, x_num, S * 2), 0.55)\n", "\n", "W = np.empty(len(Π))\n", "b_0 = 0.5\n", "σ_w_star = 1 - np.full((S, 2), 0.55)\n", "\n", "amss_model = AMSS(log_pref, β, Π, g, x_grid, bounds_v)" ] }, { "cell_type": "code", "execution_count": null, "id": "374f3a34", "metadata": { "hide-output": false }, "outputs": [], "source": [ "%%time\n", "\n", "amss_model.solve(V, σ_v_star, b_0, W, σ_w_star, tol_vfi=3e-5, maxitr=3000,\n", " print_itr=100)" ] }, { "cell_type": "code", "execution_count": null, "id": "869ac7bc", "metadata": { "hide-output": false }, "outputs": [], "source": [ "ls_model = SequentialLS(log_pref, g=g, π=Π) # Solve sequential problem" ] }, { "cell_type": "code", "execution_count": null, "id": "a0125c9c", "metadata": { "hide-output": false }, "outputs": [], "source": [ "# WARNING: DO NOT EXPECT THE CODE TO WORK IF YOU CHANGE PARAMETERS\n", "s_hist = np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1,\n", " 0, 0, 0, 1, 1, 1, 1, 1, 1, 0])\n", "\n", "T = len(s_hist)\n", "\n", "sim_amss = amss_model.simulate(s_hist, b_0)\n", "sim_ls = ls_model.simulate(0.5, 0, T, s_hist)\n", "\n", "titles = ['Consumption', 'Labor Supply', 'Government Debt',\n", " 'Tax Rate', 'Government Spending', 'Output']\n", "\n", "fig, axes = plt.subplots(3, 2, figsize=(14, 10))\n", "\n", "for ax, title, ls, amss in zip(axes.flatten(), titles, sim_ls, sim_amss):\n", " ax.plot(ls, '-ok', amss, '-^b')\n", " ax.set(title=title)\n", " ax.grid()\n", "\n", "axes[0, 0].legend(('Complete Markets', 'Incomplete Markets'))\n", "plt.tight_layout()\n", "plt.show()" ] }, { "cell_type": "markdown", "id": "c91c132b", "metadata": {}, "source": [ "When the government experiences a prolonged period of peace, it is able to reduce\n", "government debt and set persistently lower tax rates.\n", "\n", "However, the government finances a long war by borrowing and raising taxes.\n", "\n", "This results in a drift away from policies with state-contingent debt that\n", "depends on the history of shocks.\n", "\n", "This is even more evident in the following figure that plots the evolution of\n", "the two policies over 200 periods.\n", "\n", "This outcome reflects the presence of a force for **precautionary saving** that the incomplete markets structure imparts to the Ramsey plan.\n", "\n", "In [this subsequent lecture](https://python-advanced.quantecon.org/amss2.html) and [this subsequent lecture](https://python-advanced.quantecon.org/amss3.html), some ultimate consequences of that force are explored." ] }, { "cell_type": "code", "execution_count": null, "id": "8dc565e2", "metadata": { "hide-output": false }, "outputs": [], "source": [ "T = 200\n", "s_0 = 0\n", "mc = MarkovChain(Π)\n", "\n", "s_hist_long = mc.simulate(T, init=s_0, random_state=5)" ] }, { "cell_type": "code", "execution_count": null, "id": "e40ae071", "metadata": { "hide-output": false }, "outputs": [], "source": [ "sim_amss = amss_model.simulate(s_hist_long, b_0)\n", "sim_ls = ls_model.simulate(0.5, 0, T, s_hist_long)\n", "\n", "titles = ['Consumption', 'Labor Supply', 'Government Debt',\n", " 'Tax Rate', 'Government Spending', 'Output']\n", "\n", "\n", "fig, axes = plt.subplots(3, 2, figsize=(14, 10))\n", "\n", "for ax, title, ls, amss in zip(axes.flatten(), titles, sim_ls, \\\n", " sim_amss):\n", " ax.plot(ls, '-k', amss, '-.b', alpha=0.5)\n", " ax.set(title=title)\n", " ax.grid()\n", "\n", "axes[0, 0].legend(('Complete Markets','Incomplete Markets'))\n", "plt.tight_layout()\n", "plt.show()" ] }, { "cell_type": "markdown", "id": "1fb2f6a7", "metadata": {}, "source": [ "

[1] In an allocation that solves the Ramsey problem and that levies distorting\n", "taxes on labor, why would the government ever want to hand revenues back\n", "to the private sector? It would not in an economy with state-contingent debt, since\n", "any such allocation could be improved by lowering distortionary taxes\n", "rather than handing out lump-sum transfers. But, without state-contingent\n", "debt there can be circumstances when a government would like to make\n", "lump-sum transfers to the private sector.\n", "\n", "

[2] From the first-order conditions for the Ramsey\n", "problem, there exists another realization $ \\tilde s^t $ with\n", "the same history up until the previous period, i.e., $ \\tilde s^{t-1}=\n", "s^{t-1} $, but where the multiplier on constraint [(43.11)](#equation-amss-46) takes a positive value, so\n", "$ \\gamma_t(\\tilde s^t)>0 $." ] } ], "metadata": { "date": 1705369584.5952008, "filename": "amss.md", "kernelspec": { "display_name": "Python", "language": "python3", "name": "python3" }, "title": "Optimal Taxation without State-Contingent Debt" }, "nbformat": 4, "nbformat_minor": 5 }