{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "
\n", " \n", " \"QuantEcon\"\n", " \n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Optimal Taxation without State-Contingent Debt" ] }, { "cell_type": "markdown", "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", "metadata": {}, "source": [ "## Overview\n", "\n", "In [an earlier lecture](opt_tax_recur.ipynb) we described a model of\n", "optimal taxation with state-contingent debt due to\n", "Robert E. Lucas, Jr., and Nancy Stokey [[LS83]](zreferences.ipynb#lucasstokey1983)\n", "\n", "Aiyagari, Marcet, Sargent, and Seppälä [[AMSS02]](zreferences.ipynb#amss-2002) (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", "metadata": {}, "source": [ "### Setup" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": true }, "outputs": [], "source": [ "using InstantiateFromURL\n", "github_project(\"QuantEcon/quantecon-notebooks-julia\", version = \"0.2.0\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "using LinearAlgebra, Statistics, Compat" ] }, { "cell_type": "markdown", "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](opt_tax_recur.ipynb)\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{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{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{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](dynamic_programming/smoothing.ipynb)\n", "\n", "It is at this point that AMSS [[AMSS02]](zreferences.ipynb#amss-2002) 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 [[Bar79]](zreferences.ipynb#barro1979) than they do in [[LS83]](zreferences.ipynb#lucasstokey1983)" ] }, { "cell_type": "markdown", "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 $ 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 nonnegative lump-sum transfer to the representative household [1](#fn-a) \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_t(s_t) - T_t(s^t) +\n", " {b_{t+1}(s^t) \\over R_t(s^t )}\n", " \\\\\n", " & \\equiv z(s^t) + {b_{t+1}(s^t) \\over R_t(s^t )},\n", "\\end{aligned} \\tag{4}\n", "$$\n", "\n", "where $ z(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 [(4)](#equation-ts-gov-wo)\n", "yields:\n", "\n", "\n", "\n", "$$\n", "b_t(s^{t-1}) = z(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{5}\n", "$$\n", "\n", "Components of $ z(s^t) $ on the right side depend on $ s^t $, but the left side is required to depend on $ s^{t-1} $ only\n", "\n", "**This is what it means for one-period government debt to be risk-free**\n", "\n", "Therefore, the sum on the right side of equation [(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 [(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(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(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 the 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(s^{t+j})\n", " \\end{aligned} \\tag{6}\n", "$$\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(s^t) $ as\n", "\n", "\n", "\n", "$$\n", "z(s^t)\n", " = \\left[1 - {u_{\\ell}(s^t) \\over u_c(s^t)}\\right] \\left[c_t(s^t)+g_t(s_t)\\right]\n", " -g_t(s_t) - T_t(s^t)\\,. \\tag{7}\n", "$$\n", "\n", "If we substitute the appropriate versions of right side of [(7)](#equation-amss-44-2) for $ z(s^{t+j}) $ into equation [(6)](#equation-ts-gov-wo3),\n", "we obtain a sequence of *implementability constraints* on a Ramsey allocation in an AMSS economy\n", "\n", "Expression [(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(s^{j}) \\tag{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(s^{t+j}) \\tag{9}\n", "$$\n", "\n", "Equation [(9)](#equation-ts-gov-wo4a) must hold for each $ s^t $ for each $ t \\geq 1 $" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Comparison with Lucas-Stokey Economy\n", "\n", "The expression on the right side of [(9)](#equation-ts-gov-wo4a) in the Lucas-Stokey (1983) economy would equal the present value of a continuation stream of government 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 surpluses in the Lucas-Stokey model must belong to the **marketable subspace** of the AMSS model" ] }, { "cell_type": "markdown", "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_t(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(s^{j}) \\geq b_0(s^{-1}) \\tag{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(s^{t+j}) = b_t(s^{t-1})\n", " \\quad \\forall \\, s^t \\tag{11}\n", "$$\n", "\n", "given $ b_0(s^{-1}) $" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Lagrangian Formulation\n", "\n", "Let $ \\gamma_0(s^0) $ be a nonnegative Lagrange multiplier on constraint [(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 stochastic processes $ \\{\\gamma_t(s^t)\\}_{t=1}^\\infty $ of\n", "Lagrange multipliers to the implementability constraints [(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 this direction }\n", " \\\\\n", " & \\mathbb{E}\\,_{t} \\sum_{j=0}^\\infty \\beta^j\n", " { u_c(s^{t+j}) \\over u_c(s^{t}) } \\;z(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 [(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](#fn-b)\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", "metadata": {}, "source": [ "### Some Calculations\n", "\n", "It is helpful to apply two transformations to the Lagrangian\n", "\n", "Multiply constraint [(10)](#equation-amss-44) by $ u_c(s^0) $ and the constraints [(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_t(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(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_t(s_t)\\right)\n", " \\\\\n", " & \\qquad + \\Psi_t(s^t)\\, u_c(s^{t}) \\,z(s^{t}) -\n", " \\gamma_t(s^t)\\, u_c(s^{t}) \\, b_t(s^{t-1}) \\biggr\\}\n", "\\end{aligned} \\tag{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{13}\n", "$$\n", "\n", "In [(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(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{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{15}\n", "$$\n", "\n", "If we substitute $ z(s^t) $ from [(7)](#equation-amss-44-2) and its derivative\n", "$ z_c(s^t) $ into first-order condition [(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 first-order condition\n", "[(14)](#equation-amss-foc-a) does not appear in the corresponding expression\n", "for the Lucas-Stokey economy\n", "\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", "\n", "\n", "\n", "2. The Lagrange multiplier $ \\Psi_t(s^t) $ in first-order condition\n", "[(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", "We need some code from our [an earlier lecture](opt_tax_recur.ipynb)\n", "on optimal taxation with state-contingent debt sequential allocation implementation:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false, "html-class": "collapse" }, "outputs": [], "source": [ "using QuantEcon, NLsolve, NLopt, Compat\n", "\n", "import QuantEcon.simulate\n", "\n", "mutable struct Model{TF <: AbstractFloat,\n", " TM <: AbstractMatrix{TF},\n", " TV <: AbstractVector{TF}}\n", " β::TF\n", " Π::TM\n", " G::TV\n", " Θ::TV\n", " transfers::Bool\n", " U::Function\n", " Uc::Function\n", " Ucc::Function\n", " Un::Function\n", " Unn::Function\n", " n_less_than_one::Bool\n", "end\n", "\n", "\n", "struct SequentialAllocation{TP <: Model,\n", " TI <: Integer,\n", " TV <: AbstractVector}\n", " model::TP\n", " mc::MarkovChain\n", " S::TI\n", " cFB::TV\n", " nFB::TV\n", " ΞFB::TV\n", " zFB::TV\n", "end\n", "\n", "\n", "function SequentialAllocation(model::Model)\n", " β, Π, G, Θ = model.β, model.Π, model.G, model.Θ\n", " mc = MarkovChain(Π)\n", " S = size(Π, 1) # Number of states\n", " # Now find the first best allocation\n", " cFB, nFB, ΞFB, zFB = find_first_best(model, S, 1)\n", "\n", " return SequentialAllocation(model, mc, S, cFB, nFB, ΞFB, zFB)\n", "end\n", "\n", "\n", "function find_first_best(model::Model, S::Integer, version::Integer)\n", " if version != 1 && version != 2\n", " throw(ArgumentError(\"version must be 1 or 2\"))\n", " end\n", " β, Θ, Uc, Un, G, Π =\n", " model.β, model.Θ, model.Uc, model.Un, model.G, model.Π\n", " function res!(out, z)\n", " c = z[1:S]\n", " n = z[S+1:end]\n", " out[1:S] = Θ .* Uc.(c, n) + Un.(c, n)\n", " out[S+1:end] = Θ .* n .- c .- G\n", " end\n", " res = nlsolve(res!, 0.5 * ones(2 * S))\n", "\n", " if converged(res) == false\n", " error(\"Could not find first best\")\n", " end\n", "\n", " if version == 1\n", " cFB = res.zero[1:S]\n", " nFB = res.zero[S+1:end]\n", " ΞFB = Uc(cFB, nFB) # Multiplier on the resource constraint\n", " zFB = vcat(cFB, nFB, ΞFB)\n", " return cFB, nFB, ΞFB, zFB\n", " elseif version == 2\n", " cFB = res.zero[1:S]\n", " nFB = res.zero[S+1:end]\n", " IFB = Uc(cFB, nFB) .* cFB + Un(cFB, nFB) .* nFB\n", " xFB = \\(LinearAlgebra.I - β * Π, IFB)\n", " zFB = [vcat(cFB[s], xFB[s], xFB) for s in 1:S]\n", " return cFB, nFB, IFB, xFB, zFB\n", " end\n", "end\n", "\n", "\n", "function time1_allocation(pas::SequentialAllocation, μ::Real)\n", " model, S = pas.model, pas.S\n", " Θ, β, Π, G, Uc, Ucc, Un, Unn =\n", " model.Θ, model.β, model.Π, model.G,\n", " model.Uc, model.Ucc, model.Un, model.Unn\n", " function FOC!(out, z::Vector)\n", " c = z[1:S]\n", " n = z[S+1:2S]\n", " Ξ = z[2S+1:end]\n", " out[1:S] = Uc.(c, n) - μ * (Ucc.(c, n) .* c + Uc.(c, n)) - Ξ # FOC c\n", " out[S+1:2S] = Un.(c, n) - μ * (Unn(c, n) .* n .+ Un.(c, n)) + Θ .* Ξ # FOC n\n", " out[2S+1:end] = Θ .* n - c .- G # resource constraint\n", " return out\n", " end\n", " # Find the root of the FOC\n", " res = nlsolve(FOC!, pas.zFB)\n", " if res.f_converged == false\n", " error(\"Could not find LS allocation.\")\n", " end\n", " z = res.zero\n", " c, n, Ξ = z[1:S], z[S+1:2S], z[2S+1:end]\n", " # Now compute x\n", " I = Uc(c, n) .* c + Un(c, n) .* n\n", " x = \\(LinearAlgebra.I - β * model.Π, I)\n", " return c, n, x, Ξ\n", "end\n", "\n", "\n", "function time0_allocation(pas::SequentialAllocation,\n", " B_::AbstractFloat, s_0::Integer)\n", " model = pas.model\n", " Π, Θ, G, β = model.Π, model.Θ, model.G, model.β\n", " Uc, Ucc, Un, Unn =\n", " model.Uc, model.Ucc, model.Un, model.Unn\n", "\n", " # First order conditions of planner's problem\n", " function FOC!(out, z)\n", " μ, c, n, Ξ = z[1], z[2], z[3], z[4]\n", " xprime = time1_allocation(pas, μ)[3]\n", " out .= vcat(\n", " Uc(c, n) .* (c - B_) + Un(c, n) .* n + β * dot(Π[s_0, :], xprime),\n", " Uc(c, n) .- μ * (Ucc(c, n) .* (c - B_) + Uc(c, n)) .- Ξ,\n", " Un(c, n) .- μ * (Unn(c, n) .* n + Un(c, n)) + Θ[s_0] .* Ξ,\n", " (Θ .* n .- c .- G)[s_0]\n", " )\n", " end\n", "\n", " # Find root\n", " res = nlsolve(FOC!, [0.0, pas.cFB[s_0], pas.nFB[s_0], pas.ΞFB[s_0]])\n", " if res.f_converged == false\n", " error(\"Could not find time 0 LS allocation.\")\n", " end\n", " return (res.zero...,)\n", "end\n", "\n", "\n", "function time1_value(pas::SequentialAllocation, μ::Real)\n", " model = pas.model\n", " c, n, x, Ξ = time1_allocation(pas, μ)\n", " U_val = model.U.(c, n)\n", " V = \\(LinearAlgebra.I - model.β*model.Π, U_val)\n", " return c, n, x, V\n", "end\n", "\n", "\n", "function Τ(model::Model, c::Union{Real,Vector}, n::Union{Real,Vector})\n", " Uc, Un = model.Uc.(c, n), model.Un.(c, n)\n", " return 1. .+ Un./(model.Θ .* Uc)\n", "end\n", "\n", "\n", "function simulate(pas::SequentialAllocation,\n", " B_::AbstractFloat, s_0::Integer,\n", " T::Integer,\n", " sHist::Union{Vector, Nothing}=nothing)\n", "\n", " model = pas.model\n", " Π, β, Uc = model.Π, model.β, model.Uc\n", "\n", " if isnothing(sHist)\n", " sHist = QuantEcon.simulate(pas.mc, T, init=s_0)\n", " end\n", " cHist = zeros(T)\n", " nHist = zeros(T)\n", " Bhist = zeros(T)\n", " ΤHist = zeros(T)\n", " μHist = zeros(T)\n", " RHist = zeros(T-1)\n", " # time 0\n", " μ, cHist[1], nHist[1], _ = time0_allocation(pas, B_, s_0)\n", " ΤHist[1] = Τ(pas.model, cHist[1], nHist[1])[s_0]\n", " Bhist[1] = B_\n", " μHist[1] = μ\n", " # time 1 onward\n", " for t in 2:T\n", " c, n, x, Ξ = time1_allocation(pas,μ)\n", " u_c = Uc(c,n)\n", " s = sHist[t]\n", " ΤHist[t] = Τ(pas.model, c, n)[s]\n", " Eu_c = dot(Π[sHist[t-1],:], u_c)\n", " cHist[t], nHist[t], Bhist[t] = c[s], n[s], x[s] / u_c[s]\n", " RHist[t-1] = Uc(cHist[t-1], nHist[t-1]) / (β * Eu_c)\n", " μHist[t] = μ\n", " end\n", " return cHist, nHist, Bhist, ΤHist, sHist, μHist, RHist\n", "end\n", "\n", "\n", "mutable struct BellmanEquation{TP <: Model,\n", " TI <: Integer,\n", " TV <: AbstractVector,\n", " TM <: AbstractMatrix{TV},\n", " TVV <: AbstractVector{TV}}\n", " model::TP\n", " S::TI\n", " xbar::TV\n", " time_0::Bool\n", " z0::TM\n", " cFB::TV\n", " nFB::TV\n", " xFB::TV\n", " zFB::TVV\n", "end\n", "\n", "\n", "function BellmanEquation(model::Model, xgrid::AbstractVector, policies0::Vector)\n", " S = size(model.Π, 1) # number of states\n", " xbar = [minimum(xgrid), maximum(xgrid)]\n", " time_0 = false\n", " cf, nf, xprimef = policies0\n", " z0 = [vcat(cf[s](x), nf[s](x), [xprimef[s, sprime](x) for sprime in 1:S])\n", " for x in xgrid, s in 1:S]\n", " cFB, nFB, IFB, xFB, zFB = find_first_best(model, S, 2)\n", " return BellmanEquation(model, S, xbar, time_0, z0, cFB, nFB, xFB, zFB)\n", "end\n", "\n", "\n", "function get_policies_time1(T::BellmanEquation,\n", " i_x::Integer, x::AbstractFloat,\n", " s::Integer, Vf::AbstractArray)\n", " model, S = T.model, T.S\n", " β, Θ, G, Π = model.β, model.Θ, model.G, model.Π\n", " U, Uc, Un = model.U, model.Uc, model.Un\n", "\n", " function objf(z::Vector, grad)\n", " c, xprime = z[1], z[2:end]\n", " n=c+G[s]\n", " Vprime = [Vf[sprime](xprime[sprime]) for sprime in 1:S]\n", " return -(U(c, n) + β * dot(Π[s, :], Vprime))\n", " end\n", " function cons(z::Vector, grad)\n", " c, xprime = z[1], z[2:end]\n", " n=c+G[s]\n", " return x - Uc(c, n) * c - Un(c, n) * n - β * dot(Π[s, :], xprime)\n", " end\n", " lb = vcat(0, T.xbar[1] * ones(S))\n", " ub = vcat(1 - G[s], T.xbar[2] * ones(S))\n", " opt = Opt(:LN_COBYLA, length(T.z0[i_x, s])-1)\n", " min_objective!(opt, objf)\n", " equality_constraint!(opt, cons)\n", " lower_bounds!(opt, lb)\n", " upper_bounds!(opt, ub)\n", " maxeval!(opt, 300)\n", " maxtime!(opt, 10)\n", " init = vcat(T.z0[i_x, s][1], T.z0[i_x, s][3:end])\n", " for (i, val) in enumerate(init)\n", " if val > ub[i]\n", " init[i] = ub[i]\n", " elseif val < lb[i]\n", " init[i] = lb[i]\n", " end\n", " end\n", " (minf, minx, ret) = optimize(opt, init)\n", " T.z0[i_x, s] = vcat(minx[1], minx[1] + G[s], minx[2:end])\n", " return vcat(-minf, T.z0[i_x, s])\n", "end\n", "\n", "function get_policies_time0(T::BellmanEquation,\n", " B_::AbstractFloat, s0::Integer, Vf::Array)\n", " model, S = T.model, T.S\n", " β, Θ, G, Π = model.β, model.Θ, model.G, model.Π\n", " U, Uc, Un = model.U, model.Uc, model.Un\n", " function objf(z, grad)\n", " c, xprime = z[1], z[2:end]\n", " n = c+G[s0]\n", " Vprime = [Vf[sprime](xprime[sprime]) for sprime in 1:S]\n", " return -(U(c, n) + β * dot(Π[s0, :], Vprime))\n", " end\n", " function cons(z::Vector, grad)\n", " c, xprime = z[1], z[2:end]\n", " n = c + G[s0]\n", " return -Uc(c, n) * (c - B_) - Un(c, n) * n - β * dot(Π[s0, :], xprime)\n", " end\n", " lb = vcat(0, T.xbar[1] * ones(S))\n", " ub = vcat(1-G[s0], T.xbar[2] * ones(S))\n", " opt = Opt(:LN_COBYLA, length(T.zFB[s0])-1)\n", " min_objective!(opt, objf)\n", " equality_constraint!(opt, cons)\n", " lower_bounds!(opt, lb)\n", " upper_bounds!(opt, ub)\n", " maxeval!(opt, 300)\n", " maxtime!(opt, 10)\n", " init = vcat(T.zFB[s0][1], T.zFB[s0][3:end])\n", " for (i, val) in enumerate(init)\n", " if val > ub[i]\n", " init[i] = ub[i]\n", " elseif val < lb[i]\n", " init[i] = lb[i]\n", " end\n", " end\n", " (minf, minx, ret) = optimize(opt, init)\n", " return vcat(-minf, vcat(minx[1], minx[1]+G[s0], minx[2:end]))\n", "end" ] }, { "cell_type": "markdown", "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](dyn_stack.ipynb) and [optimal taxation with state-contingent debt](opt_tax_recur.ipynb)" ] }, { "cell_type": "markdown", "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", " [(8)](#equation-ts-gov-wo4) from the Lucas-Stokey economy, but \n", "- adds measurability constraints [(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", "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 nonnegative transfers\n", "\n", "Throughout this lecture, we shall set transfers to zero (for some issues about the limiting behavior of debt, this makes a possibly\n", "important difference from AMSS [[AMSS02]](zreferences.ipynb#amss-2002), who restricted transfers\n", "to be nonnegative)\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{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", "[(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{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{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{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{20}\n", "$$\n", "\n", "for $ t \\geq 1 $" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Measurability Constraints\n", "\n", "Write equation [(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{21}\n", "$$\n", "\n", "The right side of equation [(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 [(21)](#equation-eqn-amssapp2b) must equal\n", "$ b_t(s^{t-1}) $\n", "\n", "That implies that it is has to be *measurable* with respect to $ s^{t-1} $\n", "\n", "Equations [(21)](#equation-eqn-amssapp2b) are the *measurablility constraints* that the AMSS model adds to the single time $ 0 $ implementation\n", "constraint imposed in the Lucas and Stokey model" ] }, { "cell_type": "markdown", "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{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{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{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{25}\n", "$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Martingale Supercedes State-Variable Degeneracy\n", "\n", "Let $ \\mu(s|s_-) \\Pi(s|s_-) $ be a Lagrange multiplier on constraint [(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{26}\n", "$$\n", "\n", "Applying the envelope theorem to Bellman equation [(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{27}\n", "$$\n", "\n", "Equations [(26)](#equation-eqn-amssapp7) and [(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), s) \\tag{28}\n", "$$\n", "\n", "Equation [(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 is 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", "$$\n", "\n", "**Exercise**: Please verify that $ \\check \\Pi(s|s_-) $ is a valid Markov\n", "transition density, i.e., that its elements are all nonnegative and\n", "that for each $ s_- $, the sum over $ s $ equals unity" ] }, { "cell_type": "markdown", "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](opt_tax_recur.ipynb), 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\n", " (i.e., $ x_t $ is an exact 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", "metadata": {}, "source": [ "### Digression on Nonnegative Transfers\n", "\n", "Throughout this lecture we have imposed that transfers $ T_t = 0 $\n", "\n", "AMSS [[AMSS02]](zreferences.ipynb#amss-2002) 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 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 nonnegative lump sum transfers" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Code\n", "\n", "The recursive formulation is implemented as follows" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "using Dierckx\n", "\n", "\n", "mutable struct BellmanEquation_Recursive{TP <: Model, TI <: Integer, TR <: Real}\n", " model::TP\n", " S::TI\n", " xbar::Array{TR}\n", " time_0::Bool\n", " z0::Array{Array}\n", " cFB::Vector{TR}\n", " nFB::Vector{TR}\n", " xFB::Vector{TR}\n", " zFB::Vector{Vector{TR}}\n", "end\n", "\n", "\n", "struct RecursiveAllocation{TP <: Model,\n", " TI <: Integer,\n", " TVg <: AbstractVector,\n", " TT <: Tuple}\n", " model::TP\n", " mc::MarkovChain\n", " S::TI\n", " T::BellmanEquation_Recursive\n", " μgrid::TVg\n", " xgrid::TVg\n", " Vf::Array\n", " policies::TT\n", "end\n", "\n", "\n", "function RecursiveAllocation(model::Model, μgrid::AbstractArray)\n", " G = model.G\n", " S = size(model.Π, 1) # number of states\n", " mc = MarkovChain(model.Π)\n", " # now find the first best allocation\n", " Vf, policies, T, xgrid = solve_time1_bellman(model, μgrid)\n", " T.time_0 = true # Bellman equation now solves time 0 problem\n", " return RecursiveAllocation(model, mc, S, T, μgrid, xgrid, Vf, policies)\n", "end\n", "\n", "\n", "function solve_time1_bellman(model::Model{TR}, μgrid::AbstractArray) where {TR <: Real}\n", " Π = model.Π\n", " S = size(model.Π, 1)\n", "\n", " # First get initial fit from lucas stockey solution.\n", " # Need to change things to be ex_ante\n", " PP = SequentialAllocation(model)\n", "\n", " function incomplete_allocation(PP::SequentialAllocation,\n", " μ_::AbstractFloat,\n", " s_::Integer)\n", " c, n, x, V = time1_value(PP, μ_)\n", " return c, n, dot(Π[s_, :], x), dot(Π[s_, :], V)\n", " end\n", "\n", " cf = Array{Function}(undef, S, S)\n", " nf = Array{Function}(undef, S, S)\n", " xprimef = Array{Function}(undef, S, S)\n", " Vf = Vector{Function}(undef, S)\n", " xgrid = Array{TR}(undef, S, length(μgrid))\n", "\n", " for s_ in 1:S\n", " c = Array{TR}(undef, length(μgrid), S)\n", " n = Array{TR}(undef, length(μgrid), S)\n", " x = Array{TR}(undef, length(μgrid))\n", " V = Array{TR}(undef, length(μgrid))\n", " for (i_μ, μ) in enumerate(μgrid)\n", " c[i_μ, :], n[i_μ, :], x[i_μ], V[i_μ] =\n", " incomplete_allocation(PP, μ, s_)\n", " end\n", " xprimes = repeat(x, 1, S)\n", " xgrid[s_, :] = x\n", " for sprime = 1:S\n", " splc = Spline1D(x[end:-1:1], c[:, sprime][end:-1:1], k=3)\n", " spln = Spline1D(x[end:-1:1], n[:, sprime][end:-1:1], k=3)\n", " splx = Spline1D(x[end:-1:1], xprimes[:, sprime][end:-1:1], k=3)\n", " cf[s_, sprime] = y -> splc(y)\n", " nf[s_, sprime] = y -> spln(y)\n", " xprimef[s_, sprime] = y -> splx(y)\n", " # cf[s_, sprime] = LinInterp(x[end:-1:1], c[:, sprime][end:-1:1])\n", " # nf[s_, sprime] = LinInterp(x[end:-1:1], n[:, sprime][end:-1:1])\n", " # xprimef[s_, sprime] = LinInterp(x[end:-1:1], xprimes[:, sprime][end:-1:1])\n", " end\n", " splV = Spline1D(x[end:-1:1], V[end:-1:1], k=3)\n", " Vf[s_] = y -> splV(y)\n", " # Vf[s_] = LinInterp(x[end:-1:1], V[end:-1:1])\n", " end\n", "\n", " policies = [cf, nf, xprimef]\n", "\n", " # Create xgrid\n", " xbar = [maximum(minimum(xgrid)), minimum(maximum(xgrid))]\n", " xgrid = range(xbar[1], xbar[2], length = length(μgrid))\n", "\n", " # Now iterate on Bellman equation\n", " T = BellmanEquation_Recursive(model, xgrid, policies)\n", " diff = 1.0\n", " while diff > 1e-4\n", " PF = (i_x, x, s) -> get_policies_time1(T, i_x, x, s, Vf, xbar)\n", " Vfnew, policies = fit_policy_function(T, PF, xgrid)\n", "\n", " diff = 0.0\n", " for s=1:S\n", " diff = max(diff, maximum(abs, (Vf[s].(xgrid) - Vfnew[s].(xgrid)) ./\n", " Vf[s].(xgrid)))\n", " end\n", "\n", " println(\"diff = $diff\")\n", " Vf = copy(Vfnew)\n", " end\n", "\n", " return Vf, policies, T, xgrid\n", "end\n", "\n", "\n", "function fit_policy_function(T::BellmanEquation_Recursive,\n", " PF::Function,\n", " xgrid::AbstractVector{TF}) where {TF <: AbstractFloat}\n", " S = T.S\n", " # preallocation\n", " PFvec = Array{TF}(undef, 4S + 1, length(xgrid))\n", " cf = Array{Function}(undef, S, S)\n", " nf = Array{Function}(undef, S, S)\n", " xprimef = Array{Function}(undef, S, S)\n", " TTf = Array{Function}(undef, S, S)\n", " Vf = Vector{Function}(undef, S)\n", " # fit policy fuctions\n", " for s_ in 1:S\n", " for (i_x, x) in enumerate(xgrid)\n", " PFvec[:, i_x] = PF(i_x, x, s_)\n", " end\n", " splV = Spline1D(xgrid, PFvec[1,:], k=3)\n", " Vf[s_] = y -> splV(y)\n", " # Vf[s_] = LinInterp(xgrid, PFvec[1, :])\n", " for sprime=1:S\n", " splc = Spline1D(xgrid, PFvec[1 + sprime, :], k=3)\n", " spln = Spline1D(xgrid, PFvec[1 + S + sprime, :], k=3)\n", " splxprime = Spline1D(xgrid, PFvec[1 + 2S + sprime, :], k=3)\n", " splTT = Spline1D(xgrid, PFvec[1 + 3S + sprime, :], k=3)\n", " cf[s_, sprime] = y -> splc(y)\n", " nf[s_, sprime] = y -> spln(y)\n", " xprimef[s_, sprime] = y -> splxprime(y)\n", " TTf[s_, sprime] = y -> splTT(y)\n", " end\n", " end\n", " policies = (cf, nf, xprimef, TTf)\n", " return Vf, policies\n", "end\n", "\n", "\n", "function Tau(pab::RecursiveAllocation,\n", " c::AbstractArray,\n", " n::AbstractArray)\n", " model = pab.model\n", " Uc, Un = model.Uc(c, n), model.Un(c, n)\n", " return 1. .+ Un ./ (model.Θ .* Uc)\n", "end\n", "\n", "Tau(pab::RecursiveAllocation, c::Real, n::Real) = Tau(pab, [c], [n])\n", "\n", "\n", "function time0_allocation(pab::RecursiveAllocation, B_::Real, s0::Integer)\n", " T, Vf = pab.T, pab.Vf\n", " xbar = T.xbar\n", " z0 = get_policies_time0(T, B_, s0, Vf, xbar)\n", "\n", " c0, n0, xprime0, T0 = z0[2], z0[3], z0[4], z0[5]\n", " return c0, n0, xprime0, T0\n", "end\n", "\n", "\n", "function simulate(pab::RecursiveAllocation,\n", " B_::TF, s_0::Integer, T::Integer,\n", " sHist::Vector=simulate(pab.mc, T, init=s_0)) where {TF <: AbstractFloat}\n", " model, mc, Vf, S = pab.model, pab.mc, pab.Vf, pab.S\n", " Π, Uc = model.Π, model.Uc\n", " cf, nf, xprimef, TTf = pab.policies\n", "\n", " cHist = Array{TF}(undef, T)\n", " nHist = Array{TF}(undef, T)\n", " Bhist = Array{TF}(undef, T)\n", " xHist = Array{TF}(undef, T)\n", " TauHist = Array{TF}(undef, T)\n", " THist = Array{TF}(undef, T)\n", " μHist = Array{TF}(undef, T)\n", "\n", " #time0\n", " cHist[1], nHist[1], xHist[1], THist[1] = time0_allocation(pab, B_, s_0)\n", " TauHist[1] = Tau(pab, cHist[1], nHist[1])[s_0]\n", " Bhist[1] = B_\n", " μHist[1] = Vf[s_0](xHist[1])\n", "\n", " #time 1 onward\n", " for t in 2:T\n", " s_, x, s = sHist[t-1], xHist[t-1], sHist[t]\n", " c = Array{TF}(undef, S)\n", " n = Array{TF}(undef, S)\n", " xprime = Array{TF}(undef, S)\n", " TT = Array{TF}(undef, S)\n", " for sprime=1:S\n", " c[sprime], n[sprime], xprime[sprime], TT[sprime] =\n", " cf[s_, sprime](x), nf[s_, sprime](x),\n", " xprimef[s_, sprime](x), TTf[s_, sprime](x)\n", " end\n", "\n", " Tau_val = Tau(pab, c, n)[s]\n", " u_c = Uc(c, n)\n", " Eu_c = dot(Π[s_, :], u_c)\n", "\n", " μHist[t] = Vf[s](xprime[s])\n", "\n", " cHist[t], nHist[t], Bhist[t], TauHist[t] = c[s], n[s], x/Eu_c, Tau_val\n", " xHist[t], THist[t] = xprime[s], TT[s]\n", " end\n", " return cHist, nHist, Bhist, xHist, TauHist, THist, μHist, sHist\n", "end\n", "\n", "\n", "function BellmanEquation_Recursive(model::Model{TF},\n", " xgrid::AbstractVector{TF},\n", " policies0::Array) where {TF <: AbstractFloat}\n", "\n", " S = size(model.Π, 1) # number of states\n", " xbar = [minimum(xgrid), maximum(xgrid)]\n", " time_0 = false\n", " z0 = Array{Array}(undef, length(xgrid), S)\n", " cf, nf, xprimef = policies0[1], policies0[2], policies0[3]\n", " for s in 1:S\n", " for (i_x, x) in enumerate(xgrid)\n", " cs = Array{TF}(undef, S)\n", " ns = Array{TF}(undef, S)\n", " xprimes = Array{TF}(undef, S)\n", " for j = 1:S\n", " cs[j], ns[j], xprimes[j] = cf[s, j](x), nf[s, j](x), xprimef[s, j](x)\n", " end\n", " z0[i_x, s] = vcat(cs, ns, xprimes, zeros(S))\n", " end\n", " end\n", " cFB, nFB, IFB, xFB, zFB = find_first_best(model, S, 2)\n", " return BellmanEquation_Recursive(model, S, xbar, time_0, z0, cFB, nFB, xFB, zFB)\n", "end\n", "\n", "\n", "\n", "function get_policies_time1(T::BellmanEquation_Recursive,\n", " i_x::Integer,\n", " x::Real,\n", " s_::Integer,\n", " Vf::AbstractArray{Function},\n", " xbar::AbstractVector)\n", " model, S = T.model, T.S\n", " β, Θ, G, Π = model.β, model.Θ, model.G, model.Π\n", " U,Uc,Un = model.U, model.Uc, model.Un\n", "\n", " S_possible = sum(Π[s_, :].>0)\n", " sprimei_possible = findall(Π[s_, :].>0)\n", "\n", " function objf(z, grad)\n", " c, xprime = z[1:S_possible], z[S_possible+1:2S_possible]\n", " n = (c .+ G[sprimei_possible]) ./ Θ[sprimei_possible]\n", " Vprime = [Vf[sprimei_possible[si]](xprime[si]) for si in 1:S_possible]\n", " return -dot(Π[s_, sprimei_possible], U.(c, n) + β * Vprime)\n", " end\n", "\n", " function cons(out, z, grad)\n", " c, xprime, TT =\n", " z[1:S_possible], z[S_possible + 1:2S_possible], z[2S_possible + 1:3S_possible]\n", " n = (c .+ G[sprimei_possible]) ./ Θ[sprimei_possible]\n", " u_c = Uc.(c, n)\n", " Eu_c = dot(Π[s_, sprimei_possible], u_c)\n", " out .= x * u_c/Eu_c - u_c .* (c - TT) - Un(c, n) .* n - β * xprime\n", " end\n", " function cons_no_trans(out, z, grad)\n", " c, xprime = z[1:S_possible], z[S_possible + 1:2S_possible]\n", " n = (c .+ G[sprimei_possible]) ./ Θ[sprimei_possible]\n", " u_c = Uc.(c, n)\n", " Eu_c = dot(Π[s_, sprimei_possible], u_c)\n", " out .= x * u_c / Eu_c - u_c .* c - Un(c, n) .* n - β * xprime\n", " end\n", "\n", " if model.transfers == true\n", " lb = vcat(zeros(S_possible), ones(S_possible)*xbar[1], zeros(S_possible))\n", " if model.n_less_than_one == true\n", " ub = vcat(ones(S_possible) - G[sprimei_possible],\n", " ones(S_possible) * xbar[2], ones(S_possible))\n", " else\n", " ub = vcat(100 * ones(S_possible),\n", " ones(S_possible) * xbar[2],\n", " 100 * ones(S_possible))\n", " end\n", " init = vcat(T.z0[i_x, s_][sprimei_possible],\n", " T.z0[i_x, s_][2S .+ sprimei_possible],\n", " T.z0[i_x, s_][3S .+ sprimei_possible])\n", " opt = Opt(:LN_COBYLA, 3S_possible)\n", " equality_constraint!(opt, cons, zeros(S_possible))\n", " else\n", " lb = vcat(zeros(S_possible), ones(S_possible)*xbar[1])\n", " if model.n_less_than_one == true\n", " ub = vcat(ones(S_possible)-G[sprimei_possible], ones(S_possible)*xbar[2])\n", " else\n", " ub = vcat(ones(S_possible), ones(S_possible) * xbar[2])\n", " end\n", " init = vcat(T.z0[i_x, s_][sprimei_possible],\n", " T.z0[i_x, s_][2S .+ sprimei_possible])\n", " opt = Opt(:LN_COBYLA, 2S_possible)\n", " equality_constraint!(opt, cons_no_trans, zeros(S_possible))\n", " end\n", " init[init .> ub] = ub[init .> ub]\n", " init[init .< lb] = lb[init .< lb]\n", "\n", " min_objective!(opt, objf)\n", " lower_bounds!(opt, lb)\n", " upper_bounds!(opt, ub)\n", " maxeval!(opt, 10000000)\n", " maxtime!(opt, 10)\n", " ftol_rel!(opt, 1e-8)\n", " ftol_abs!(opt, 1e-8)\n", "\n", " (minf, minx, ret) = optimize(opt, init)\n", "\n", " if ret != :SUCCESS && ret != :ROUNDOFF_LIMITED && ret != :MAXEVAL_REACHED &&\n", " ret != :FTOL_REACHED && ret != :MAXTIME_REACHED\n", " error(\"optimization failed: ret = $ret\")\n", " end\n", "\n", " T.z0[i_x, s_][sprimei_possible] = minx[1:S_possible]\n", " T.z0[i_x, s_][S .+ sprimei_possible] = minx[1:S_possible] .+ G[sprimei_possible]\n", " T.z0[i_x, s_][2S .+ sprimei_possible] = minx[S_possible .+ 1:2S_possible]\n", " if model.transfers == true\n", " T.z0[i_x, s_][3S .+ sprimei_possible] = minx[2S_possible + 1:3S_possible]\n", " else\n", " T.z0[i_x, s_][3S .+ sprimei_possible] = zeros(S)\n", " end\n", "\n", " return vcat(-minf, T.z0[i_x, s_])\n", "end\n", "\n", "\n", "function get_policies_time0(T::BellmanEquation_Recursive,\n", " B_::Real,\n", " s0::Integer,\n", " Vf::AbstractArray{Function},\n", " xbar::AbstractVector)\n", " model = T.model\n", " β, Θ, G = model.β, model.Θ, model.G\n", " U, Uc, Un = model.U, model.Uc, model.Un\n", "\n", " function objf(z, grad)\n", " c, xprime = z[1], z[2]\n", " n = (c + G[s0]) / Θ[s0]\n", " return -(U(c, n) + β * Vf[s0](xprime))\n", " end\n", "\n", " function cons(z,grad)\n", " c, xprime, TT = z[1], z[2], z[3]\n", " n = (c + G[s0]) / Θ[s0]\n", " return -Uc(c, n) * (c - B_ - TT) - Un(c, n) * n - β * xprime\n", " end\n", " cons_no_trans(z, grad) = cons(vcat(z, 0), grad)\n", "\n", " if model.transfers == true\n", " lb = [0.0, xbar[1], 0.0]\n", " if model.n_less_than_one == true\n", " ub = [1 - G[s0], xbar[2], 100]\n", " else\n", " ub = [100.0, xbar[2], 100.0]\n", " end\n", " init = vcat(T.zFB[s0][1], T.zFB[s0][3], T.zFB[s0][4])\n", " init = [0.95124922, -1.15926816, 0.0]\n", " opt = Opt(:LN_COBYLA, 3)\n", " equality_constraint!(opt, cons)\n", " else\n", " lb = [0.0, xbar[1]]\n", " if model.n_less_than_one == true\n", " ub = [1-G[s0], xbar[2]]\n", " else\n", " ub = [100, xbar[2]]\n", " end\n", " init = vcat(T.zFB[s0][1], T.zFB[s0][3])\n", " init = [0.95124922, -1.15926816]\n", " opt = Opt(:LN_COBYLA, 2)\n", " equality_constraint!(opt, cons_no_trans)\n", " end\n", " init[init .> ub] = ub[init .> ub]\n", " init[init .< lb] = lb[init .< lb]\n", "\n", "\n", " min_objective!(opt, objf)\n", " lower_bounds!(opt, lb)\n", " upper_bounds!(opt, ub)\n", " maxeval!(opt, 100000000)\n", " maxtime!(opt, 30)\n", "\n", " (minf, minx, ret) = optimize(opt, init)\n", "\n", " if ret != :SUCCESS && ret != :ROUNDOFF_LIMITED && ret != :MAXEVAL_REACHED &&\n", " ret != :FTOL_REACHED\n", " error(\"optimization failed: ret = $ret\")\n", " end\n", "\n", " if model.transfers == true\n", " return -minf, minx[1], minx[1]+G[s0], minx[2], minx[3]\n", " else\n", " return -minf, minx[1], minx[1]+G[s0], minx[2], 0\n", " end\n", "end" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Examples\n", "\n", "We now turn to some examples" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Anticipated One-Period War\n", "\n", "In our lecture on [optimal taxation with state contingent debt](opt_tax_recur.ipynb)\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 consider the same government expenditure process studied in the lecture on\n", "[optimal taxation with state contingent debt](opt_tax_recur.ipynb)\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](opt_tax_recur.ipynb)\n", "\n", "This utility function is implemented in the following constructor" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "function crra_utility(;\n", " β = 0.9,\n", " σ = 2.0,\n", " γ = 2.0,\n", " Π = 0.5 * ones(2, 2),\n", " G = [0.1, 0.2],\n", " Θ = ones(Float64, 2),\n", " transfers = false\n", " )\n", " function U(c, n)\n", " if σ == 1.0\n", " U = log(c)\n", " else\n", " U = (c.^(1.0 - σ) - 1.0) / (1.0 - σ)\n", " end\n", " return U - n.^(1 + γ) / (1 + γ)\n", " end\n", " # Derivatives of utility function\n", " Uc(c,n) = c.^(-σ)\n", " Ucc(c,n) = -σ * c.^(-σ - 1.0)\n", " Un(c,n) = -n.^γ\n", " Unn(c,n) = -γ * n.^(γ - 1.0)\n", " n_less_than_one = false\n", " return Model(β, Π, G, Θ, transfers,\n", " U, Uc, Ucc, Un, Unn, n_less_than_one)\n", "end" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following figure plots the Ramsey plan under both complete and incomplete\n", "markets for both possible realizations of the state at time $ t=3 $\n", "\n", "Optimal policies when the government has access to state contingent debt are\n", "represented by black lines, while the optimal policies when there is only a risk\n", "free bond are in red\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, "metadata": { "hide-output": false }, "outputs": [], "source": [ "time_example = crra_utility(G=[0.1, 0.1, 0.1, 0.2, 0.1, 0.1],\n", " Θ = ones(6)) # Θ can in principle be random\n", "\n", "time_example.Π = [ 0.0 1.0 0.0 0.0 0.0 0.0;\n", " 0.0 0.0 1.0 0.0 0.0 0.0;\n", " 0.0 0.0 0.0 0.5 0.5 0.0;\n", " 0.0 0.0 0.0 0.0 0.0 1.0;\n", " 0.0 0.0 0.0 0.0 0.0 1.0;\n", " 0.0 0.0 0.0 0.0 0.0 1.0]\n", "\n", "# Initialize μgrid for value function iteration\n", "μgrid = range(-0.7, 0.01, length = 200)\n", "\n", "time_example.transfers = true # Government can use transfers\n", "time_sequential = SequentialAllocation(time_example) # Solve sequential problem\n", "\n", "time_bellman = RecursiveAllocation(time_example, μgrid)\n", "\n", "sHist_h = [1, 2, 3, 4, 6, 6, 6]\n", "sHist_l = [1, 2, 3, 5, 6, 6, 6]\n", "\n", "sim_seq_h = simulate(time_sequential, 1., 1, 7, sHist_h)\n", "sim_bel_h = simulate(time_bellman, 1., 1, 7, sHist_h)\n", "sim_seq_l = simulate(time_sequential, 1., 1, 7, sHist_l)\n", "sim_bel_l = simulate(time_bellman, 1., 1, 7, sHist_l)\n", "\n", "using Plots\n", "gr(fmt=:png);\n", "titles = hcat(\"Consumption\", \"Labor Supply\", \"Government Debt\",\n", " \"Tax Rate\", \"Government Spending\", \"Output\")\n", "sim_seq_l_plot = hcat(sim_seq_l[1:3]..., sim_seq_l[4],\n", " time_example.G[sHist_l],\n", " time_example.Θ[sHist_l] .* sim_seq_l[2])\n", "sim_bel_l_plot = hcat(sim_bel_l[1:3]..., sim_bel_l[5],\n", " time_example.G[sHist_l],\n", " time_example.Θ[sHist_l] .* sim_bel_l[2])\n", "sim_seq_h_plot = hcat(sim_seq_h[1:3]..., sim_seq_h[4],\n", " time_example.G[sHist_h],\n", " time_example.Θ[sHist_h] .* sim_seq_h[2])\n", "sim_bel_h_plot = hcat(sim_bel_h[1:3]..., sim_bel_h[5],\n", " time_example.G[sHist_h],\n", " time_example.Θ[sHist_h] .* sim_bel_h[2])\n", "p = plot(size = (920, 750), layout =(3, 2),\n", " xaxis=(0:6), grid=false, titlefont=Plots.font(\"sans-serif\", 10))\n", "plot!(p, title = titles)\n", "for i=1:6\n", " plot!(p[i], 0:6, sim_seq_l_plot[:, i], marker=:circle, color=:black, lab=\"\")\n", " plot!(p[i], 0:6, sim_bel_l_plot[:, i], marker=:circle, color=:red, lab=\"\")\n", " plot!(p[i], 0:6, sim_seq_h_plot[:, i], marker=:utriangle, color=:black, lab=\"\")\n", " plot!(p[i], 0:6, sim_bel_h_plot[:, i], marker=:utriangle, color=:red, lab=\"\")\n", "end\n", "p" ] }, { "cell_type": "markdown", "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", "- These purchases are designed in such a way that regardless of whether or not there is a war at $ t=3 $, the government will begin 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", "It responds to this constraint by smoothing tax rates across time\n", "\n", "To finance a war it raises taxes and issues more debt\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 " ] }, { "cell_type": "markdown", "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](opt_tax_recur.ipynb)\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, "metadata": { "hide-output": false }, "outputs": [], "source": [ "function log_utility(;β = 0.9,\n", " ψ = 0.69,\n", " Π = 0.5 * ones(2, 2),\n", " G = [0.1, 0.2],\n", " Θ = ones(2),\n", " transfers = false)\n", " # Derivatives of utility function\n", " U(c,n) = log(c) + ψ * log(1 - n)\n", " Uc(c,n) = 1 ./ c\n", " Ucc(c,n) = -c.^(-2.0)\n", " Un(c,n) = -ψ ./ (1.0 .- n)\n", " Unn(c,n) = -ψ ./ (1.0 .- n).^2.0\n", " n_less_than_one = true\n", " return Model(β, Π, G, Θ, transfers,\n", " U, Uc, Ucc, Un, Unn, n_less_than_one)\n", "end" ] }, { "cell_type": "markdown", "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, "metadata": { "hide-output": false }, "outputs": [], "source": [ "log_example = log_utility()\n", "\n", "log_example.transfers = true # Government can use transfers\n", "log_sequential = SequentialAllocation(log_example) # Solve sequential problem\n", "log_bellman = RecursiveAllocation(log_example, μgrid) # Solve recursive problem\n", "\n", "T = 20\n", "sHist = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1]\n", "\n", "#simulate\n", "sim_seq = simulate(log_sequential, 0.5, 1, T, sHist)\n", "sim_bel = simulate(log_bellman, 0.5, 1, T, sHist)\n", "\n", "sim_seq_plot = hcat(sim_seq[1:3]...,\n", " sim_seq[4], log_example.G[sHist], log_example.Θ[sHist] .* sim_seq[2])\n", "sim_bel_plot = hcat(sim_bel[1:3]...,\n", " sim_bel[5], log_example.G[sHist], log_example.Θ[sHist] .* sim_bel[2])\n", "\n", "#plot policies\n", "p = plot(size = (920, 750), layout = grid(3, 2),\n", " xaxis=(0:T), grid=false, titlefont=Plots.font(\"sans-serif\", 10))\n", "labels = fill((\"\", \"\"), 6)\n", "labels[3] = (\"Complete Market\", \"Incomplete Market\")\n", "plot!(p, title = titles)\n", "for i = vcat(collect(1:4), 6)\n", " plot!(p[i], sim_seq_plot[:, i], marker=:circle, color=:black, lab=labels[i][1])\n", " plot!(p[i], sim_bel_plot[:, i], marker=:utriangle, color=:blue, lab=labels[i][2],\n", " legend=:bottomright)\n", "end\n", "plot!(p[5], sim_seq_plot[:, 5], marker=:circle, color=:blue, lab=\"\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When the government experiences a prolonged period of peace, it is able to reduce\n", "government debt and set permanently 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" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "T_long = 200\n", "sim_seq_long = simulate(log_sequential, 0.5, 1, T_long)\n", "sHist_long = sim_seq_long[end-2]\n", "sim_bel_long = simulate(log_bellman, 0.5, 1, T_long, sHist_long)\n", "sim_seq_long_plot = hcat(sim_seq_long[1:4]...,\n", " log_example.G[sHist_long], log_example.Θ[sHist_long] .* sim_seq_long[2])\n", "sim_bel_long_plot = hcat(sim_bel_long[1:3]..., sim_bel_long[5],\n", " log_example.G[sHist_long], log_example.Θ[sHist_long] .* sim_bel_long[2])\n", "\n", "p = plot(size = (920, 750), layout = (3, 2), xaxis=(0:50:T_long), grid=false,\n", " titlefont=Plots.font(\"sans-serif\", 10))\n", "plot!(p, title = titles)\n", "for i = 1:6\n", " plot!(p[i], sim_seq_long_plot[:, i], color=:black, linestyle=:solid, lab=labels[i][1])\n", " plot!(p[i], sim_bel_long_plot[:, i], color=:blue, linestyle=:dot, lab=labels[i][2],\n", " legend=:bottomright)\n", "end\n", "p" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Footnotes**\n", "\n", "\n", "**[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", "\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 [(11)](#equation-amss-46) takes a positive value, so\n", "$ \\gamma_t(\\tilde s^t)>0 $." ] } ], "metadata": { "filename": "amss.rst", "kernelspec": { "display_name": "Julia 1.2", "language": "julia", "name": "julia-1.2" }, "title": "Optimal Taxation without State-Contingent Debt" }, "nbformat": 4, "nbformat_minor": 2 }