diff --git a/notebooks/IndShockConsumerType.ipynb b/notebooks/IndShockConsumerType.ipynb index e539217f..3760e8a1 100644 --- a/notebooks/IndShockConsumerType.ipynb +++ b/notebooks/IndShockConsumerType.ipynb @@ -141,13 +141,14 @@ }, "outputs": [], "source": [ - "IdiosyncDict={\n", + "IdiosyncDict={ # Click the arrow to expand this parameter dictionary\n", " # Parameters shared with the perfect foresight model\n", " \"CRRA\": 2.0, # Coefficient of relative risk aversion\n", " \"Rfree\": 1.03, # Interest factor on assets\n", " \"DiscFac\": 0.96, # Intertemporal discount factor\n", " \"LivPrb\" : [0.98], # Survival probability\n", " \"PermGroFac\" :[1.01], # Permanent income growth factor\n", + " \"BoroCnstArt\" : 0.0, # Artificial borrowing constraint; imposed minimum level of end-of period assets\n", " \n", " # Parameters that specify the income distribution over the lifecycle\n", " \"PermShkStd\" : [0.1], # Standard deviation of log permanent shocks to income\n", @@ -169,7 +170,6 @@ " \"aXtraExtra\" : [None], # Additional values to add to aXtraGrid\n", " \n", " # A few other paramaters\n", - " \"BoroCnstArt\" : 0.0, # Artificial borrowing constraint; imposed minimum level of end-of period assets\n", " \"vFuncBool\" : True, # Whether to calculate the value function during solution \n", " \"CubicBool\" : False, # Preference shocks currently only compatible with linear cFunc\n", " \"T_cycle\" : 1, # Number of periods in the cycle for this agent type \n", diff --git a/notebooks/KinkedRconsumerType.ipynb b/notebooks/KinkedRconsumerType.ipynb index cc57b6c4..d491f02e 100644 --- a/notebooks/KinkedRconsumerType.ipynb +++ b/notebooks/KinkedRconsumerType.ipynb @@ -140,12 +140,13 @@ " \"DiscFac\": 0.96, # Intertemporal discount factor\n", " \"LivPrb\" : [0.98], # Survival probability\n", " \"PermGroFac\" :[1.01], # Permanent income growth factor\n", + " \"BoroCnstArt\" : None, # Artificial borrowing constraint; imposed minimum level of end-of period assets\n", " \n", " # New parameters unique to the \"kinked R\" model\n", " \"Rboro\" : 1.20, # Interest factor on borrowing (a < 0)\n", " \"Rsave\" : 1.01, # Interest factor on saving (a > 0)\n", " \n", - " # Parameters that specify the income distribution over the lifecycle\n", + " # Parameters that specify the income distribution over the lifecycle (shared with IndShockConsumerType)\n", " \"PermShkStd\" : [0.1], # Standard deviation of log permanent shocks to income\n", " \"PermShkCount\" : 7, # Number of points in discrete approximation to permanent income shocks\n", " \"TranShkStd\" : [0.2], # Standard deviation of log transitory shocks to income\n", @@ -157,20 +158,19 @@ " \"T_retire\" : 0, # Period of retirement (0 --> no retirement)\n", " \"tax_rate\" : 0.0, # Flat income tax rate (legacy parameter, will be removed in future)\n", " \n", - " # Parameters for constructing the \"assets above minimum\" grid\n", + " # Parameters for constructing the \"assets above minimum\" grid (shared with IndShockConsumerType)\n", " \"aXtraMin\" : 0.001, # Minimum end-of-period \"assets above minimum\" value\n", " \"aXtraMax\" : 20, # Maximum end-of-period \"assets above minimum\" value\n", " \"aXtraCount\" : 48, # Number of points in the base grid of \"assets above minimum\"\n", " \"aXtraNestFac\" : 3, # Exponential nesting factor when constructing \"assets above minimum\" grid\n", " \"aXtraExtra\" : [None], # Additional values to add to aXtraGrid\n", " \n", - " # A few other paramaters\n", - " \"BoroCnstArt\" : None, # Artificial borrowing constraint; imposed minimum level of end-of period assets\n", + " # A few other paramaters (shared with IndShockConsumerType)\n", " \"vFuncBool\" : True, # Whether to calculate the value function during solution \n", " \"CubicBool\" : False, # Preference shocks currently only compatible with linear cFunc\n", " \"T_cycle\" : 1, # Number of periods in the cycle for this agent type \n", " \n", - " # Parameters only used in simulation\n", + " # Parameters only used in simulation (shared with PerfForesightConsumerType)\n", " \"AgentCount\" : 10000, # Number of agents of this type\n", " \"T_sim\" : 500, # Number of periods to simulate\n", " \"aNrmInitMean\" : -6.0, # Mean of log initial assets\n", diff --git a/notebooks/PerfForesightConsumerType.ipynb b/notebooks/PerfForesightConsumerType.ipynb index 992ddfaf..560d5fd0 100644 --- a/notebooks/PerfForesightConsumerType.ipynb +++ b/notebooks/PerfForesightConsumerType.ipynb @@ -23,6 +23,7 @@ "from time import clock\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", + "from copy import copy\n", "mystr = lambda number : \"{:.4f}\".format(number)" ] }, @@ -56,9 +57,11 @@ "\\begin{equation}\n", "U(C) = \\frac{C^{1-\\CRRA}}{1-\\rho},\n", "\\end{equation}\n", - "has perfect foresight about everything except whether he will die between the end of period $t$ and the beginning of period $t+1$, which occurs with probability $\\DiePrb_{t+1}$. Permanent labor income $P_t$ grows from period $t$ to period $t+1$ by factor $\\PermGroFac_{t+1}$. The consumer faces no artificial borrowing constraint and is able to borrow against the entire future stream of income he will receive.\n", + "has perfect foresight about everything except whether he will die between the end of period $t$ and the beginning of period $t+1$, which occurs with probability $\\DiePrb_{t+1}$. Permanent labor income $P_t$ grows from period $t$ to period $t+1$ by factor $\\PermGroFac_{t+1}$.\n", "\n", - "At the beginning of period $t$, the consumer has an amount of market resources $M_t$ (which includes both market wealth and currrent income) and must choose how much of those resources to consume $C_t$ and how much to retain in a riskless asset $A_t$, which will earn return factor $\\Rfree$. The agent's flow of future utility $U(C_{t+n})$ from consumption is geometrically discounted by factor $\\DiscFac$ per period. If the consumer dies, he receives zero utility flow for the rest of time.\n", + "At the beginning of period $t$, the consumer has an amount of market resources $M_t$ (which includes both market wealth and currrent income) and must choose how much of those resources to consume $C_t$ and how much to retain in a riskless asset $A_t$, which will earn return factor $\\Rfree$. The consumer cannot necessarily borrow arbitarily; instead, he might be constrained to have a wealth-to-income ratio at least as great as some \"artificial borrowing constraint\" $\\underline{a} \\leq 0$.\n", + "\n", + "The agent's flow of future utility $U(C_{t+n})$ from consumption is geometrically discounted by factor $\\DiscFac$ per period. If the consumer dies, he receives zero utility flow for the rest of time.\n", "\n", "The agent's problem can be written in Bellman form as:\n", "\n", @@ -66,6 +69,7 @@ "V_t(M_t,P_t) &=& \\max_{C_t}~U(C_t) ~+ \\DiscFac (1 - \\DiePrb_{t+1}) V_{t+1}(M_{t+1},P_{t+1}), \\\\\n", "& s.t. & \\\\\n", "A_t &=& M_t - C_t, \\\\\n", + "A_t/P_t &\\geq& \\underline{a}, \\\\\n", "M_{t+1} &=& \\Rfree A_t + Y_{t+1}, \\\\\n", "Y_{t+1} &=& P_{t+1}, \\\\ \n", "P_{t+1} &=& \\PermGroFac_{t+1} P_t.\n", @@ -79,6 +83,7 @@ "v_t(m_t) &=& \\max_{c_t}~U(c_t) ~+ \\DiscFac (1 - \\DiePrb_{t+1}) \\PermGroFac_{t+1}^{1-\\CRRA} v_{t+1}(m_{t+1}), \\\\\n", "& s.t. & \\\\\n", "a_t &=& m_t - c_t, \\\\\n", + "a_t &\\geq& \\underline{a}, \\\\\n", "m_{t+1} &=& \\Rfree/\\PermGroFac_{t+1} a_t + 1.\n", "\\end{eqnarray*}" ] @@ -107,11 +112,15 @@ "| $\\Rfree$ | Risk free interest factor | $\\texttt{Rfree}$ | $1.03$ | |\n", "| $1 - \\DiePrb_{t+1}$ |Survival probability | $\\texttt{LivPrb}$ | $[0.98]$ | $\\surd$ |\n", "|$\\PermGroFac_{t+1}$|Permanent income growth factor|$\\texttt{PermGroFac}$| $[1.01]$ | $\\surd$ |\n", + "|$\\underline{a}$|Artificial borrowing constraint|$\\texttt{BoroCnstArt}$| $None$ | |\n", + "|$(none)$|Maximum number of gridpoints in consumption function |$\\texttt{aXtraCount}$| $200$ | |\n", "|$T$| Number of periods in this type's \"cycle\" |$\\texttt{T_cycle}$| $1$ | |\n", "|(none)| Number of times the \"cycle\" occurs |$\\texttt{cycles}$| $0$ | |\n", "\n", "Note that the survival probability and income growth factor have time subscripts; likewise, the example values for these parameters are *lists* rather than simply single floats. This is because those parameters are *time-varying*: their values can depend on which period of the problem the agent is in. All time-varying parameters *must* be specified as lists, even if the same value occurs in each period for this type.\n", "\n", + "The artificial borrowing constraint can be any non-positive $\\texttt{float}$, or it can be $\\texttt{None}$ to indicate no artificial borrowing constraint. The maximum number of gridpoints in the consumption function is only relevant if the borrowing constraint is not $\\texttt{None}$; without an upper bound on the number of gridpoints, kinks in the consumption function will propagate indefinitely in an infinite horizon model if there is a borrowing constraint, eventually resulting in an overflow error. If there is no artificial borrowing constraint, then the number of gridpoints used to represent the consumption function is always exactly two.\n", + "\n", "The last two parameters in the table specify the \"nature of time\" for this type: the number of (non-terminal) periods in this type's \"cycle\", and the number of times that the \"cycle\" occurs. *Every* subclass of $\\texttt{AgentType}$ uses these two code parameters to define the nature of time. Here, $\\texttt{T_cycle}$ has the value $1$, indicating that there is exactly one period in the cycle, while $\\texttt{cycles}$ is $0$, indicating that the cycle is repeated in *infinite* number of times-- it is an infinite horizon model, with the same \"kind\" of period repeated over and over.\n", "\n", "In contrast, we could instead specify a life-cycle model by setting $\\texttt{T_cycle}$ to $1$, and specifying age-varying sequences of income growth and survival probability. In all cases, the number of elements in each time-varying parameter should exactly equal $\\texttt{T_cycle}$.\n", @@ -125,9 +134,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "code_folding": [ - 0 - ] + "code_folding": [] }, "outputs": [], "source": [ @@ -137,7 +144,9 @@ " \"Rfree\" : 1.03, # Interest factor on assets\n", " \"DiscFac\" : 0.96, # Default intertemporal discount factor\n", " \"LivPrb\" : [0.98], # Survival probability\n", - " \"PermGroFac\" :[1.01], # Permanent income growth factor\n", + " \"PermGroFac\" : [1.01], # Permanent income growth factor\n", + " \"BoroCnstArt\" : None, # Artificial borrowing constraint\n", + " \"aXtraCount\" : 200, # Maximum number of gridpoints in consumption function\n", " \n", " # Parameters that characterize the nature of time\n", " \"T_cycle\" : 1, # Number of periods in the cycle for this agent type\n", @@ -231,7 +240,35 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "An element of $\\texttt{solution}$ also includes the (normalized) marginal value function $\\texttt{vPfunc}$, and the lower and upper bounds of the marginal propensity to consume (MPC) $\\texttt{MPCmin}$ and $\\texttt{MPCmax}$. Note that with a linear consumption function, the MPC is constant, so its lower and upper bound are identical." + "An element of $\\texttt{solution}$ also includes the (normalized) marginal value function $\\texttt{vPfunc}$, and the lower and upper bounds of the marginal propensity to consume (MPC) $\\texttt{MPCmin}$ and $\\texttt{MPCmax}$. Note that with a linear consumption function, the MPC is constant, so its lower and upper bound are identical.\n", + "\n", + "### Liquidity constrained perfect foresight example\n", + "\n", + "Without an artificial borrowing constraint, a perfect foresight consumer is free to borrow against the PDV of his entire future stream of labor income-- his \"human wealth\" $\\texttt{hNrm}$-- and he will consume a constant proportion of his total wealth (market resources plus human wealth). If we introduce an artificial borrowing constraint, both of these features vanish. In the cell below, we define a parameter dictionary that prevents the consumer from borrowing *at all*, create and solve a new instance of $\\texttt{PerfForesightConsumerType}$ with it, and then plot its consumption function." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "LiqConstrDict = copy(PerfForesightDict)\n", + "LiqConstrDict['BoroCnstArt'] = 0.0 # Set the artificial borrowing constraint to zero\n", + "\n", + "LiqConstrExample = PerfForesightConsumerType(**LiqConstrDict)\n", + "LiqConstrExample.cycles = 0 # Make this type be infinite horizon\n", + "LiqConstrExample.solve()\n", + "\n", + "print('Liquidity constrained perfect foresight consumption function:')\n", + "plotFuncs(LiqConstrExample.solution[0].cFunc,0.,10.)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "At this time, the value function for a perfect foresight consumer with an artificial borrowing constraint is not computed nor included as part of its $\\texttt{solution}$." ] }, {