Abstract¶
Heterogeneous agent models with multiple decisions are often solved using inefficient grid search methods that require many evaluations and are slow. This paper provides a novel method for solving such models using an extension of the Endogenous Grid Method (EGM) that uses Gaussian Process Regression (GPR) to interpolate functions on unstructured grids. First, I propose an intuitive and strategic procedure for decomposing a problem into subproblems which allows the use of efficient solution methods. Second, using an exogenous grid of post-decision states and solving for an endogenous grid of pre-decision states that obey a first-order condition greatly speeds up the solution process. Third, since the resulting endogenous grid can often be non-rectangular at best and unstructured at worst, GPR provides an efficient and accurate method for interpolating the value, marginal value, and decision functions. Applied sequentially to each decision within the problem, the method is able to solve heterogeneous agent models with multiple decisions in a fraction of the time and with less computational resources than are required by standard methods currently used. Software to reproduce these methods is available under the Econ-ARK/HARK
project for the python
programming language.
1Introduction¶
1.1Background¶
Macroeconomic modeling aims to describe a complex world of agents interacting with each other and making decisions in a dynamic setting. The models are often very complex, require strong underlying assumptions, and use a lot of computational power to solve. One of the most common methods to solve these complex problems is using a grid search method to solve the model. The Endogenous Grid Method (EGM) developed by Carroll (2006) allows dynamic optimization problems to be solved in a more computationally efficient and faster manner than the previous method of convex optimization using grid search. Many problems that before took hours to compute became much easier to solve and allowed macroeconomists and computational economists to focus on estimation and simulation. However, the Endogenous Grid Method is limited to a few specific classes of problems. Recently, the classes of problems to which EGM can be applied have been expanded[1], but with every new method comes a new set of limitations. This paper introduces a new approach to EGM in a multivariate setting. The method is called Sequential EGM (or EGMn) and introduces a novel way of breaking down complex problems into a sequence of simpler, smaller, and more tractable problems, along with an exploration of new multidimensional interpolation methods that can be used to solve these problems.
1.2Literature Review¶
Carroll (2006) first introduced the Endogenous Grid Method as a way to speed up the solution of dynamic stochastic consumption-savings problems. The method consists of starting with an exogenous grid of post-decision states and using the inverse of the first-order condition to find the optimal consumption policy that rationalizes such post-decision states. Given the optimal policy and post-decision states, it is straightforward to calculate the initial pre-decision state that leads to the optimal policy. Although this method is certainly innovative, it only applied to a model with one control variable and one state variable. Barillas & Fernández-Villaverde (2007) further extend this method by including more than one control variable in the form of a labor-leisure choice, as well as a second state variable for stochastic persistence.
Hintermaier & Koeniger (2010) introduce a model with collateral constraints and non-separable utility and solve using an EGM method that allows for occasionally binding constraints among endogenous variables. Jørgensen (2013) evaluates the performance of the Endogenous Grid Method against other methods for solving dynamic stochastic optimization problems and finds it to be fast and efficient. Maliar & Maliar (2013) develop the Envelope Condition Method based on a similar idea as the Endogenous Grid Method, avoiding the need for costly numerical optimization and grid search. However, their model is limited to infinite horizon problems as it is a forward solution method.
Further development into a multivariate Endogenous Grid Method expanded the ability of researchers to solve models efficiently. White (2015) formally characterized the conditions for the Endogenous Grid Method and developed an interpolation method for structured non-rectilinear, or curvilinear, grids. Iskhakov (2015) additionally establishes conditions for solving multivariate models with EGM, requiring the invertibility of a triangular system of first-order conditions. Ludwig & Schön (2018) also develops a novel interpolating method using Delaunay triangulation of the resulting unstructured endogenous grid. However, the authors show that the gains from avoiding the grid search method are often offset by the costly construction of the triangulation.
For the papers discussed above, continuity and smoothness of the value and first-order conditions are strict requirements. Fella (2014) first introduced a method to solve non-convex problems using the Endogenous Grid Method. The idea is based on evaluating necessary but not sufficient candidates for the first-order condition in overlapping regions of the state space. Arellano et al. (2016) use the Envelope Condition Method to solve a sovereign default risk model with similar efficiency gains to EGM. Iskhakov et al. (2017) further advances the methodology by using extreme errors to solve discrete choice problems with Endogenous Grid Method. These methods however were only applied to a single control variable and a single state variable. Druedahl & Jørgensen (2017) introduces the to handle non-convex problems with more than 1 control variable and more than 1 state variable. This method is also capable of handling occasionally binding constraints which previous multivariate EGM methods were not.
Clausen & Strub (2020) formalize the applicability of the Endogenous Grid Method and its extensions to discrete choice models and discuss the nesting of problems to efficiently find accurate solutions. Druedahl (2021) similarly suggest the nesting of problems to efficiently use the Endogenous Grid Method within problems with multiple control variables. However, while these nested methods reduce the complexity of solving these models, they often still require grid search methods as is the case with Druedahl (2021).
1.3Research Question¶
The purpose of this paper is to describe a new method for solving dynamic optimization problems efficiently and accurately while avoiding convex optimization and grid search methods with the use of the Endogenous Grid Method and first-order conditions. The method is called Sequential EGM (or EGMn) and introduces a novel way of breaking down complex problems into a sequence of simpler, smaller, and more tractable problems, along with an exploration of new multidimensional interpolation methods that can be used to solve these problems. This paper also illustrates an example of how Sequential EGM can be used to solve a dynamic optimization problem in a multivariate setting.
1.4Methodology¶
The sequential Endogenous Grid Method consists of 3 major parts: First, the problem to be solved should be broken up into a sequence of smaller problems that themselves don’t add any additional state variables or introduce asynchronous dynamics with respect to the uncertainty. If the problem is broken up in such a way that uncertainty can happen in more than one period, then the solution to this sequence of problems might be different from the aggregate problem due to giving the agent additional information about the future by realizing some uncertainty. Second, I evaluate each of the smaller problems to see if they can be solved using the Endogenous Grid Method. This evaluation is of greater scope than the traditional Endogenous Grid Method, as it allows for the resulting exogenous grid to be non-regular. If the subproblem can not be solved with EGM, then convex optimization is used. Third, if the exogenous grid generated by the EGM is non-regular, then I use a multidimensional interpolation method that takes advantage of machine learning tools to generate an interpolating function. Solving each subproblem in this way, the sequential Endogenous Grid Method is capable of solving complex problems that are not solvable with the traditional Endogenous Grid Method and are difficult and time-consuming to solve with convex optimization and grid search methods.
1.5Contributions¶
The Sequential Endogenous Grid Method is capable of solving multivariate dynamic optimization problems in an efficient and fast manner by avoiding grid search. This should allow researchers and practitioners to solve more complex problems that were previously not easily accessible to them, but more accurately capture the dynamics of the macroeconomy. By using advancements in machine learning techniques such as Gaussian Process Regression, the Sequential Endogenous Grid Method is capable of solving problems that were not previously able to be solved using the traditional Endogenous Grid Method. In particular, the Sequential Endogenous Grid Method is different from NEGM in that it allows for using more than one Endogenous Grid Method step to solve a problem, avoiding costly grid search methods to the extent that the problem allows.
Additionally, the Sequential Endogenous Grid Method often sheds light on the problem by breaking it down into a sequence of simpler problems that were not previously apparent. This is because intermediary steps in the solution process generate value and marginal value functions of different pre- and post-decision states that can be used to understand the problem better.
1.6Outline¶
Section 2 presents a basic model that illustrates the sequential Endogenous Grid Method in one dimension. Then Section 3 introduces a more complex method with two state variables to demonstrate the use of machine learning tools to generate an interpolating function. In Section 4 I present the unstructured interpolation methods using machine learning in more detail. Section 5 discusses the theoretical requirements to use the Sequential Endogenous Grid Method. Finally, Section 6 concludes with some limitations and future work.
2The Sequential Endogenous Grid Method¶
2.1A basic model¶
The baseline problem which I will use to demonstrate the Sequential Endogenous Grid Method (EGMn) is a discrete time version of Bodie et al. (1992) where a consumer has the ability to adjust their labor as well as their consumption in response to financial risk. The objective consists of maximizing the present discounted lifetime utility of consumption and leisure.
In particular, this example makes use of a utility function that is based on Example 1 in the paper, which is that of additively separable utility of labor and leisure as
where the term is introduced to allow for a balanced growth path as in Mertens & Ravn (2011). The use of additively separable utility is ad-hoc, as it will allow for the use of multiple EGM steps in the solution process, as we’ll see later.
This model represents a consumer who begins the period with a level of bank balances and a given wage offer . Simultaneously, they are able to choose consumption, labor intensity, and a risky portfolio share with the objective of maximizing their utility of consumption and leisure, as well as their future wealth.
The problem can be written in normalized recursive form[2] as
in which is the time supplied to labor net of leisure, is the market resources totaling bank balances and labor income, is the amount of saving assets held by the consumer, and is the risky share of assets, which induce a return on portfolio that results in next period’s bank balances normalized by next period’s permanent income .
2.2Restating the problem sequentially¶
We can make a few choices to create a sequential problem which will allow us to use multiple EGM steps in succession. First, the agent decides their labor-leisure trade-off and receives a wage. Their wage plus their previous bank balance then becomes their market resources. Second, given market resources, the agent makes a pure consumption-saving decision. Finally, given an amount of savings, the consumer then decides their risky portfolio share.
Starting from the beginning of the period, we can define the labor-leisure problem as
The pure consumption-saving problem is then
Finally, the risky portfolio problem is
This sequential approach is explicitly modeled after the nested approaches explored in Clausen & Strub (2020) and Druedahl (2021). However, I will offer additional insights that expand on these methods. An important observation is that now, every single choice is self-contained in a subproblem, and although the structure is specifically chosen to minimize the number of state variables at every stage, the problem does not change by this structural imposition. This is because there is no additional information or realization of uncertainty that happens between decisions, as can be seen by the expectation operator being in the last subproblem. From the perspective of the consumer, these decisions are essentially simultaneous, but a careful organization into sub-period problems enables us to solve the model more efficiently and can provide key economic insights. In this problem, as we will see, a key insight will be the ability to explicitly calculate the marginal value of wealth and the Frisch elasticity of labor.
2.3The portfolio decision subproblem¶
As useful as it is to be able to use the EGM step more than once, there are clear problems where the EGM step is not applicable. This basic labor-portfolio choice problem demonstrates where we can use an additional EGM step, and where we can not. First, we go over a subproblem where we can not use the EGM step.
In reorganizing the labor-portfolio problem into subproblems, we assigned the utility of leisure to the leisure-labor subproblem and the utility of consumption to the consumption-savings subproblem. There are no more separable convex utility functions to assign to this problem, and even if we re-organized the problem in a way that moved one of the utility functions into this subproblem, they would not be useful in solving this subproblem via EGM as there is no direct relation between the risky share of portfolio and consumption or leisure. Therefore, the only way to solve this subproblem is through standard convex optimization and root-finding techniques.
Restating the problem in compact form gives
The first-order condition with respect to the risky portfolio share is then
Finding the optimal risky share requires numerical optimization and root-solving of the first-order condition. To close out the problem, we can calculate the envelope condition as
2.3.1A note on avoiding taking expectations more than once¶
We could instead define the portfolio choice subproblem as:
where
In this case, the process is similar. The only difference is that we don’t have to take expectations more than once. Given the next period’s solution, we can calculate the marginal value functions as:
If we are clever, we can calculate both of these in one step. Now, the optimal risky share can be found by the first-order condition and we can use it to evaluate the envelope condition.
2.4The consumption-saving subproblem¶
The consumption-saving EGM follows Carroll (2006) but I will cover it for exposition. We can begin the solution process by restating the consumption-savings subproblem in a more compact form, substituting the market resources constraint and ignoring the no-borrowing constraint for now. The problem is:
To solve, we derive the first-order condition with respect to which gives the familiar Euler equation:
Inverting the above equation is the (first) EGM step.
Given the utility function above, the marginal utility of consumption and its inverse are
Carroll (2006) demonstrates that by using an exogenous grid of points we can find the unique that optimizes the consumption-saving problem, since the first-order condition is necessary and sufficient. Further, using the market resources constraint, we can recover the exact amount of market resources that is consistent with this consumption-saving decision as
This is the ``endogenous’’ grid that is consistent with the exogenous decision grid . Now that we have a pair for each , we can construct an interpolating consumption function for market resources points that are off-the-grid.
The envelope condition will be useful in the next section, but for completeness is defined here.
2.5The labor-leisure subproblem¶
The labor-leisure subproblem can be restated more compactly as:
The first-order condition with respect to leisure implies the labor-leisure Euler equation
The marginal utility of leisure and its inverse are
Using an exogenous grid of and , we can find leisure as
In this case, it’s important to note that there are conditions for leisure itself. An agent with a small level of market resources might want to work more than their available time endowment, especially at higher levels of income , if the utility of leisure is not enough to compensate for their low wealth. In these situations, the optimal unconstrained leisure might be negative, so we must impose a constraint on the optimal leisure function. This is similar to the treatment of an artificial borrowing constraint in the pure consumption subproblem. From now on, let’s call this constrained optimal function , where
Then, we derive labor as . Finally, for each and as an exogenous grid, we can find the endogenous grid of bank balances as .
The envelope condition then provides a heterogeneous Frisch elasticity of labor as simply
2.6Alternative Parametrization¶
An alternative formulation for the utility of leisure is to state it in terms of the disutility of labor as in (references)
In this case, we can restate the problem as
The marginal utility of leisure and its inverse are
2.7Curvilinear Grids¶
Although EGMn seems to be a simple approach, there is one important caveat that we have not discussed, which is the details of the interpolation. In the pure consumption-savings problem, a one-dimensional exogenous grid of post-decision liquid assets results in a one-dimensional endogenous grid of total market resources . However, as we know from standard EGM, the spacing in the grid is different from the spacing in the grid as the inverted Euler equation is non-linear. This is no problem in a one-dimensional problem as we can simply use non-uniform linear interpolation.
However, the same is true of higher dimensional problems, where the exogenous grid gets mapped to a warped endogenous grid. In this case, it is not possible to use standard multi-linear interpolation, as the resulting endogenous grid is not rectilinear. Instead, I introduce a novel approach to interpolation that I call Warped Grid Interpolation (WGI), which is similar to White (2015)’s approach but computationally more efficient and robust. The details of this interpolation method will be further explained in Section 4, but for now, we show the resulting warped endogenous grid for the labor-leisure problem.
2.8Warped Grid Interpolation (WGI)¶
Assume we have a set of points indexed by in two-dimensional space for which we have corresponding functional values in a third dimension, such that . In practice, we are interested in cases where the are difficult to compute and is unknown, so we are unable to compute them at other values of and --- which is why we want to interpolate[3]. These points however are not evenly spaced and do not form a rectilinear grid which would make it easy to interpolate the function off the grid. Nevertheless, these points do have a regular structure as we will see.
In Figure 2, we can see the true function in three-dimensional space, along with the points for which we actually know the value of the function. The underlying regular structure comes from the points’ position in the matrix, the coordinates. If we join the points along every row and every column, we can see that the resulting grid is regular and piecewise affine (curvilinear).
In Figure 3 we see the values of the function at their index coordinate points in the matrix. We can see that there exists a mapping between the curvilinear grid and the index coordinates of the matrix.
The objective is to be able to interpolate the value of the function at any point off the grid, where presumably we are only interested in points internal to the curvilinear space and not outside the boundaries. For example, we can imagine that we want an approximation to the function at the point pictured Figure 4. If we could find the corresponding point in the coordinate grid, interpolation would be straightforward. We can find where the -coordinate of the point of interest intersects with the index-coordinates of the matrix. This is similar to assuming that we have 3 linear interpolators formed by connecting the points on the green lines in the x-direction, and for each interpolator we can approximate the corresponding y and z values using the grid data. Now, for each circle in Figure 4, we have a corresponding pair , and we can interpolate in the y-direction to find the corresponding z-value for the point’s y-coordinate[4].
3The EGMn in Higher Dimensions¶
The problem in Section 2 demonstrates the simplicity of solving problems sequentially. However, as constructed, the problem has only one state variable and one post-decision state variable per stage. Can EGMn be used to solve higher dimensional problems? In short, yes, but it requires additional thought on interpolation.
3.1A more complex problem¶
For a demonstration, we now turn to the problem of a worker saving up for retirement. This worker must consume, save, and deposit resources into a tax-advantaged account that can not be liquidated until retirement. In the recursive problem, the worker begins a new period with a liquid account of market resources and an illiquid account of retirement savings . The worker maximizes their utility by choosing consumption and pension deposit . The pension deposit is set aside on a retirement account that is exposed to a risky return, while their post-consumption liquid assets accrue risk-free interest every period. The worker additionally receives an income that faces a permanent () and a transitory () shock every period. At the age of 65, the worker is retired and their assets are liquidated, at which point the state reduces to one liquid account of market resources. The worker’s recursive problem is:
where
This problem can subsequently be broken down into 3 stages: a pension deposit stage, a consumption stage, and an income shock stage.
3.2Breaking down the problem¶
In the deposit stage, the worker begins with market resources and a retirement savings account. The worker must maximize their value of liquid wealth and retirement balance by choosing a pension deposit , which must be positive. The retirement balance is the cash value of their retirement account plus their pension deposit and an additional amount that provides an incentive to save for retirement. As we’ll see, this additional term will allow us to use the Endogenous Grid Method to solve this subproblem.
After making their pension decision, the worker begins their consumption stage with liquid wealth and retirement balance . From their liquid wealth, the worker must choose a level of consumption to maximize utility and continuation value . After consumption, the worker is left with post-decision states that represent liquid assets and retirement balance , which passes through this problem unaffected because it can’t be liquidated until retirement.
Finally, the post-decision value function represents the value of both liquid and illiquid account balances before the realization of uncertainty regarding the risky return and income shocks. Since we are dealing with a normalized problem, this stage handles the normalization of state variables and value functions into the next period.
The advantage of conceptualizing this subproblem as a separate stage is that we can construct a function and use it in the prior optimization problems without having to worry about stochastic optimization and taking expectations repeatedly.
3.3The consumption-saving problem¶
As seen in the consumption stage above, the retirement balance passes through the problem unaffected because it can’t be liquidated until retirement. In this sense, it is already a post-decision state variable. To solve this problem, we can use a fixed grid of and for each obtain endogenous consumption and ex-ante market resources using the simple Endogenous Grid Method for the consumption problem.
3.4The pension deposit problem¶
In the deposit stage, both the state variables and post-decision variables are different since both are affected by the pension deposit decision.
First, we can rewrite the pension deposit problem more compactly:
The first-order condition is
Rearranging this equation gives
where
Given that exists and is invertible, we can find
Using this, we can back out as
and as
In sum, given an exogenous grid we obtain the triple , which we can use to create an interpolator for the decision rule .
To close the solution method, the envelope conditions are
3.5Unstructured Grid Interpolation¶
As in Section 2, the resulting endogenous grid is not rectilinear, and in this more complex problem it is not even a regular grid. We can see in Figure 5 that starting from a regular and rectilinear exogenous grid of liquid assets post-consumption and pension balances post-deposit , we obtain Figure 6 which shows an irregular and unstructured endogenous grid of market resources and pension balances pre-deposit .
To interpolate a function defined on an unstructured grid, we use Gaussian Process Regression as in Scheidegger & Bilionis (2019).
4Multivariate Interpolation on Unstructured Grids¶
This section presents alternative interpolation methods for non-rectilinear grids. First, I present the relatively simple case of fast warped interpolation on a curvilinear grid, which improves upon the interpolation in White (2015). Then, I present a machine learning approach to interpolation on unstructured grids based on Gaussian Process Regression as presented in Scheidegger & Bilionis (2019).
4.1Unstructured Grids¶
Unstructured interpolation arises in many dynamic programming applications when using the Endogenous Grid Method because the first-order conditions might be highly non-linear and non-monotonic, or because boundary constraints induce kinks in the policy and value functions. In these cases, the grid points generated by the EGM step are not evenly spaced, leading to the need for curvilinear interpolation. We saw in the previous subsection an approach to curvilinear interpolation based on White (2015) that is incapable of interpolation on structured grids. A similar approach was presented in Ludwig & Schön (2018) which used Delaunay interpolation. However, this approach is not well suited for our purposes because triangulation can be computationally intensive and slow, often offsetting the efficiency gains from the Endogenous Grid Method.
As an alternative to these methods, I introduce the use of Gaussian Process Regression (GPR) along with the Endogenous Grid Method. GPR is computationally efficient, and tools exist to easily parallelize and take advantage of hardware such as Graphics Processing Units (GPU)[5].
4.1.1Gaussian Process Regression¶
A Gaussian Process is an infinite dimensional random process for which every subset of random variables is jointly Gaussian or has a multivariate normal distribution.
where
Being infinitely dimensional, a Gaussian Process can be used to represent a probability distribution over the space of functions in dimensions. Thus, a Gaussian Process Regression is used to find the best fit function to a set of data points.
where is the vector of function values at the points , is the mean of the function, and is a kernel function that describes the covariance between the function values at different points.
A standard kernel function is the squared exponential kernel, or the radial basis function kernel, which is defined as
Using GPR to interpolate a function , we can both predict the value of the function at a point and the uncertainty in the prediction, which provides useful information as to the accuracy of the approximation.
4.1.2An example of the GPR¶
In Figure 7, we see the function we are trying to approximate along with a sample of data points for which we know the value of the function. In practice, the value of the function is unknown and/or expensive to compute, so we must use a limited amount of data to approximate it.
As we discussed, a Gaussian Process is an infinite dimensional random process which can be used to represent a probability of distributions over the space of functions. In Figure 8, we see a random sample of functions from the GPR posterior, which is a Gaussian Process conditioned on fitting the data. From this small sample of functions, we can see that the GP generates functions that fit the data well, and the goal of GPR is to find the one function that best fits the data given some hyperparameters by minimizing the negative log-likelihood of the data.
In Figure 9, we see the result of GPR with a particular parametrization[6] of the kernel function. The dotted line shows the true function, while the blue dots show the known data points. GPR provides the mean function which best fits the data, represented in the figure as an orange line. The shaded region represents a 95% confidence interval, which is the uncertainty of the predicted function. Along with finding the best fit of the function, GPR provides the uncertainty of the prediction, which is useful information as to the accuracy of the approximation.
5Conditions for using the Sequential Endogenous Grid Method¶
5.1Splitting the problem into subproblems¶
The first step in using the Sequential Endogenous Grid Method is to split the problem into subproblems. This process of splitting up the problem has to be strategic to not insert additional complexity into the original problem. If one is not careful when doing this, the subproblems can become more complex and intractable than the original problem.
To split up the problem, we first count the number of control variables or decisions faced by the agent. Ideally, if the agent has control variables, then the problem should be split into subproblems, each handling a different control variable. For counting the number of control variables, it is important to not double count variables which are equivalent and have market clearing conditions. For example, the decision of how much to consume and how much to save may seem like two different choices, but because of the market clearing condition they are resolved simultaneously and count as only one decision variable. Similarly, the choice between labor and leisure are simultaneous and count as only one decision.
Having counted our control variables, we look for differentiable and invertible utility functions which are separable in the dynamic programming problem, such as in Section 2 of the paper, or differentiable and invertible functions in the transition, as in Section 3 of the paper.
5.1.1Separable utility functions¶
In Section 2, we have additively separable utility of consumption and leisure, which allows for each of these control variables to be handled by separate subproblems. So, it makes sense to split the utility between subproblems and attach one to the consumption subproblem and one to the leisure subproblem.
As mentioned in that section, however, there are only two separable utility functions in the problem which have been assigned to two subproblems already. This leaves one control variable without a separable utility function. In that case, there is not another Endogenous Grid Method step to exploit, and this subproblem has to be handled by standard convex optimization techniques such as maximization of the value function (VFI) or finding the root of the Euler equation (PFI).
Now that we have split the problem into conceptual subproblems, it is important to sequence them in such a way that they don’t become more complex than the original problem. The key here is to avoid adding unnecessary state variables. For example, in the consumption-leisure-portfolio problem, if we were to choose consumption first, we would have to track the wage rate into the following leisure subproblem. This would mean that our consumption problem would be two-dimensional as well as our labor decision problem. As presented, the choice of order in Section 2 ensures that the consumption problem is one-dimensional, as we can shed the information about the wage rate offer after the agent has made their labor-leisure decision. If we did this the other way, the problem would be more complex and require additional computational resources.
The consumption subproblem would be two-dimensional instead of one-dimensional, adding more complexity,
while the labor-leisure subproblem would have an additional constraint
Therefore, strategic ordering of subproblems can greatly simplify the solution process and reduce computational the burden.
Consider the utility function of the form
where is the -th control variable and is the vector of all control variables except the -th one.
which is separable in the state and control variables that correspond to the index .
For simplicity, define
then
the first order condition
we require for to be able to solve for .
5.1.2Differentiable and invertible transition¶
In Section 3, we see that a problem with a differentiable and invertible transition can also be used to embed an additional Endogenous Grid Method step. Because the transition applies independently to a state variable that is not related to the other control variable, consumption, it can be handled separately from the consumption subproblem.
In this particular problem, however, it turns out to make no difference how we order the two subproblems. This is because the control variables, consumption and pension deposit, each affect a separate resource account, namely market resources and pension balance. Because of this, the two subproblems are independent of each other and can be solved in any order.
A good rule of thumb is that when splitting up a problem into subproblems, we should try to reduce the information set that is passed onto the next subproblem. In Section 2, choosing leisure-labor and realizing total market resources before consumption allows us to shed the wage rate offer state variable before the consumption problem, and we know that for the portfolio choice we only need to know liquid assets after expenditures (consumption). Thus, the order makes intuitive sense; agent first chooses leisure-labor, realizing total market resources, then chooses consumption and savings, and finally chooses their risky portfolio choice. In Section 3, there are two expenditures that are independent of each other, consumption and deposit, and making one decision or the other first does not reduce the information set for the agent, thus the order of these subproblems does not matter.
5.2The Endogenous Grid Method for Subproblems¶
Once we have strategically split the problem into subproblems, we can use the Endogenous Grid Method in each applicable subproblem while iterating backwards from the terminal period. As we discussed in Sections Section 2 and Section 3, the EGM step can be applied when there is a separable, differentiable and invertible utility function in the subproblem or when there is a differentiable and invertible transition in the subproblem. We will discuss each of these cases in turn.
5.2.1Utility function¶
A generic subproblem with a differentiable and invertible utility function can be characterized as follows:
For an interior solution, the first-order condition is thus
If, as we assumed, the utility function is differentiable and invertible, then the Endogenous Grid Method consists of
By using an exogenous grid of the post-decision state , we can solve for the optimal decision rule at each point on the grid. This is the Endogenous Grid Method step.
5.2.2Transition¶
If the generic subproblem has no separable utility, but instead has a differentiable and invertible transition, then the Endogenous Grid Method can still be used.
Here, the first-order condition is
and the Endogenous Grid Method step is
6Conclusion¶
This paper introduces a novel method for solving dynamic stochastic optimization problems called the Sequential Endogenous Grid Method (EGMn). Given a problem with multiple decisions (or control variables), the Sequential Endogenous Grid Method proposes separating the problem into a sequence of smaller subproblems that can be solved sequentially by using more than one EGM step. Then, depending on the resulting endogenous grid from each subproblem, this paper proposes different methods for interpolating functions on non-rectilinear grids, called the Warped Grid Interpolation (WGI) and the Gaussian Process Regression (GPR) method.
EGMn is similar to the Nested Endogenous Grid Method (NEGM)[7] and the Generalized Endogenous Grid Method (G2EGM)[8] in that it can solve problems with multiple decisions, but it differs from these methods in that by choosing the subproblems strategically, we can take advantage of multiple sequential EGM steps to solve complex multidimensional models in a fast and efficient manner. Additionally, the use of machine learning tools such as the GPR overcomes bottlenecks seen in unstructured interpolation using Delauany triangulation and other similar methods.
7Appendix: Solving the illustrative G2EGM model with EGMn¶
7.1The problem for a retired household¶
I designate as the problem of a retired household at time with total resources . The retired household solves a simple consumption-savings problem with no income uncertainty and a certain next period pension of .
Notice that there is no uncertainty and the household receives a retirement income every period until death.
7.2The problem for a worker household¶
The value function of a worker household is
where the choice specific problem for a working household that decides to continue working is
and the choice specific problem for a working household that decides to retire is
7.3Applying the Sequential EGM¶
The first step is to define a post-decision value function. Once the household decides their level of consumption and pension deposits, they are left with liquid assets they are saving for the future and illiquid assets in their pension account which they can’t access again until retirement. The post-decision value function can be defined as
Then redefine the working agent’s problem as
Clearly, the structure of the problem remains the same, and this is the problem that G2EGM solves. We’ve only moved some of the stochastic mechanics out of the problem. Now, we can apply the sequential EGMn method. Let the agent first decide , the deposit amount into their retirement; we will call this the deposit problem, or outer loop. Thereafter, the agent will have net liquid assets of and pension assets of .
Now, the agent can move on to picking their consumption and savings; we can call this the pure consumption problem or inner loop.
Because we’ve already made the pension decision, the amount of pension assets does not change in this loop and it just passes through to the post-decision value function.
7.4Solving the problem¶
7.4.1Solving the Inner Consumption Saving Problem¶
Let’s start with the pure consumption-saving problem, which we can summarize by substitution as
The first-order condition is
We can invert this Euler equation as in standard EGM to obtain the consumption function.
Again as before, . To sum up, using an exogenous grid of we obtain the trio which provides an interpolating function for our optimal consumption decision rule over the grid. Without loss of generality, assume and define the interpolating function as
For completeness, we derive the envelope conditions as well, and as we will see, these will be useful when solving the next section.
7.4.2Solving the Outer Pension Deposit Problem¶
Now, we can move on to solving the deposit problem, which we can also summarize as
The first-order condition is
Rearranging this equation gives
Assuming that exists and is invertible, we can find
Using this, we can back out as
and as
In sum, given an exogenous grid we obtain the triple , which we can use to create an interpolator for the decision rule .
To close the solution method, the envelope conditions are
7.5Is g invertible?¶
We’ve already seen that is invertible, but is ?
7.6The Post-Decision Value and Marginal Value Functions¶
and
and
7.7Taste Shocks¶
From discrete choice theory and from DCEGM paper, we know that
and
the first-order conditions are therefore
Acknowledgments¶
I would like to thank Chris Carroll, Matthew White, and Simon Scheidegger for their helpful comments and suggestions. The remaining errors are my own. All figures and other numerical results were produced using the Econ-ARK/HARK
toolkit Carroll et al., 2018. Additional libraries used in the production of this paper include but are not limited to: scipy
Virtanen et al., 2020, numpy
Harris et al., 2020, numba
Lam et al., 2015, cupy
Okuta et al., 2017, scikit-learn
Pedregosa et al., 2011, pytorch
Paszke et al., 2019, and gpytorch
Gardner et al., 2018
As in Carroll (2009), where the utility of normalized consumption and leisure is defined as
For more examples of the Warped Grid Interpolation method in action, see the github project
alanlujan91/multinterp
.Gardner et al. (2018)
For details see notebook.
- Carroll, C., Kaufman, A., Kazil, J., Palmer, N., & White, M. (2018). The econ-ARK and HARK: Open source tools for computational economics. In F. Akici, D. Lippa, D. Niederhut, & M. Pacer (Eds.), Proceedings of the Python in Science Conference (pp. 25–30). SciPy. 10.25080/majora-4af1f417-004
- Virtanen, P., Gommers, R., Oliphant, T. E., Haberland, M., Reddy, T., Cournapeau, D., Burovski, E., Peterson, P., Weckesser, W., Bright, J., van der Walt, S. J., Brett, M., Wilson, J., Millman, K. J., Mayorov, N., Nelson, A. R. J., Jones, E., Kern, R., Larson, E., … SciPy 1.0 Contributors. (2020). SciPy 1.0: fundamental algorithms for scientific computing in Python. Nature Methods, 17(3), 261–272. 10.1038/s41592-019-0686-2
- Harris, C. R., Millman, K. J., van der Walt, S. J., Gommers, R., Virtanen, P., Cournapeau, D., Wieser, E., Taylor, J., Berg, S., Smith, N. J., Kern, R., Picus, M., Hoyer, S., van Kerkwijk, M. H., Brett, M., Haldane, A., Del Rı́o, J. F., Wiebe, M., Peterson, P., … Oliphant, T. E. (2020). Array programming with NumPy. Nature, 585(7825), 357–362. 10.1038/s41586-020-2649-2
- Lam, S. K., Pitrou, A., & Seibert, S. (2015). Numba: a LLVM-based Python JIT compiler. Proceedings of the Second Workshop on the LLVM Compiler Infrastructure in HPC, Article 7, 1–6. 10.1145/2833157.2833162
- Okuta, R., Unno, Y., Nishino, D., Hido, S., & Loomis, C. (2017). Cupy: A numpy-compatible library for nvidia gpu calculations. Proceedings of Workshop on Machine Learning Systems (LearningSys) in the Thirty-First Annual Conference on Neural Information Processing Systems (NIPS), 5.