Skip to article content

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.

Keywords:endogenous grid methoddynamic programmingmachine learning

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 G2EGMG2EGM 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.

V0(B0,θ0)=maxEt[n=0Ttβnu(Ct+n,Zt+n)]\VFunc_0(\BLev_0, \tShkEmp_0) = \max \Ex_{t} \left[ \sum_{n = 0}^{T-t} \DiscFac^{n} \utilFunc(\CLev_{t+n}, \Leisure_{t+n}) \right]

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

u(C,Z)=u(C)+h(Z)=C1ρ1ρ+ν1ρZ1ζ1ζ\utilFunc(\CLev, \Leisure) = \util(\CLev) + \h(\Leisure) = \frac{C^{1-\CRRA}}{1-\CRRA} + \labShare^{1-\CRRA} \frac{\Leisure^{1-\leiShare}}{1-\leiShare}

where the term ν1ρ\labShare^{1-\CRRA} 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 bt\bRat_{t} and a given wage offer θt\tShkEmp_{t}. 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

vt(bt,θt)=max{ct,zt,ςt}u(ct,zt)+βEt[Γt+11ρvt+1(bt+1,θt+1)]s.t.t=1ztmt=bt+θttat=mtctRt+1=R+(Rt+1R)ςtbt+1=atRt+1/Γt+1\begin{split} \vFunc_{t}(\bRat_{t}, \tShkEmp_{t}) & = \max_{\{\cRat_{t}, \leisure_{t}, \riskyshare_{t}\}} \utilFunc(\cRat_{t}, \leisure_{t}) + \DiscFac \Ex_{t} \left[ \PGro_{t+1}^{1-\CRRA} \vFunc_{t+1} (\bRat_{t+1}, \tShkEmp_{t+1}) \right] \\ & \text{s.t.} \\ \labor_{t} & = 1 - \leisure_{t} \\ \mRat_{t} & = \bRat_{t} + \tShkEmp_{t}\labor_{t} \\ \aRat_{t} & = \mRat_{t} - \cRat_{t} \\ \Rport_{t+1} & = \Rfree + (\Risky_{t+1} - \Rfree) \riskyshare_{t} \\ \bRat_{t+1} & = \aRat_{t} \Rport_{t+1} / \PGro_{t+1} \end{split}

in which t\labor_{t} is the time supplied to labor net of leisure, mt\mRat_{t} is the market resources totaling bank balances and labor income, at\aRat_{t} is the amount of saving assets held by the consumer, and ςt\riskyshare_{t} is the risky share of assets, which induce a Rt+1\Rport_{t+1} return on portfolio that results in next period’s bank balances bt+1\bRat_{t+1} normalized by next period’s permanent income Γt+1\PGro_{t+1}.

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

vt(bt,θt)=maxzth(zt)+v~t(mt)s.t.0zt1t=1ztmt=bt+θtt.\begin{split} \vFunc_{t}(\bRat_{t}, \tShkEmp_{t}) & = \max_{ \leisure_{t}} \h(\leisure_{t}) + \vOpt_{t} (\mRat_{t}) \\ & \text{s.t.} \\ 0 & \leq \leisure_{t} \leq 1 \\ \labor_{t} & = 1 - \leisure_{t} \\ \mRat_{t} & = \bRat_{t} + \tShkEmp_{t}\labor_{t}. \end{split}

The pure consumption-saving problem is then

v~t(mt)=maxctu(ct)+βvt(at)s.t.0ctmtat=mtct.\begin{split} \vOpt_{t}(\mRat_{t}) & = \max_{\cRat_{t}} \util(\cRat_{t}) + \DiscFac\vEnd_{t}(\aRat_{t}) \\ & \text{s.t.} \\ 0 & \leq \cRat_{t} \leq \mRat_{t} \\ \aRat_{t} & = \mRat_{t} - \cRat_{t}. \end{split}

Finally, the risky portfolio problem is

vt(at)=maxςtEt[Γt+11ρvt+1(bt+1,θt+1)]s.t.0ςt1Rt+1=R+(Rt+1R)ςtbt+1=atRt+1/Γt+1.\begin{split} \vEnd_{t}(\aRat_{t}) & = \max_{\riskyshare_{t}} \Ex_{t} \left[ \PGro_{t+1}^{1-\CRRA} \vFunc_{t+1}(\bRat_{t+1}, \tShkEmp_{t+1}) \right] \\ & \text{s.t.} \\ 0 & \leq \riskyshare_{t} \leq 1 \\ \Rport_{t+1} & = \Rfree + (\Risky_{t+1} - \Rfree) \riskyshare_{t} \\ \bRat_{t+1} & = \aRat_{t} \Rport_{t+1} / \PGro_{t+1}. \end{split}

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

vt(at)=maxςtEt[Γt+11ρvt+1(at(R+(Rt+1R)ςt),θt+1)].\vEnd_{t}(\aRat_{t}) = \max_{\riskyshare_{t}} \Ex_{t} \left[ \PGro_{t+1}^{1-\CRRA} \vFunc_{t+1}\left(\aRat_{t}(\Rfree + (\Risky_{t+1} - \Rfree) \riskyshare_{t}), \tShkEmp_{t+1}\right) \right].

The first-order condition with respect to the risky portfolio share is then

Et[Γt+1ρvt+1b(bt+1,θt+1)(Rt+1R)]=0.\Ex_{t} \left[ \PGro_{t+1}^{-\CRRA} \vFunc_{t+1}^{\bRat}\left(\bRat_{t+1}, \tShkEmp_{t+1}\right) (\Risky_{t+1} - \Rfree) \right] = 0.

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

vt(at)=Et[Γt+1ρvt+1b(bt+1,θt+1)Rt+1].\vEnd_{t}'(\aRat_{t}) = \Ex_{t} \left[ \PGro_{t+1}^{-\CRRA} \vFunc_{t+1}^{\bRat}\left(\bRat_{t+1}, \tShkEmp_{t+1}\right) \Rport_{t+1} \right].

2.3.1A note on avoiding taking expectations more than once

We could instead define the portfolio choice subproblem as:

vt(at)=maxςtv~ˋ(at,ςt)\vEnd_{t}(\aRat_{t}) = \max_{\riskyshare_{t}} \vOptAlt(\aRat_{t}, \riskyshare_{t})

where

v~ˋt(at,ςt)=Et[Γt+11ρvt+1(bt+1,θt+1)]Rt+1=R+(Rt+1R)ςtbt+1=atRt+1/Γt+1\begin{split} \vOptAlt_{t}(\aRat_{t}, \riskyshare_{t}) & = \Ex_{t} \left[ \PGro_{t+1}^{1-\CRRA} \vFunc_{t+1}\left(\bRat_{t+1}, \tShkEmp_{t+1}\right) \right] \\ \Rport_{t+1} & = \Rfree + (\Risky_{t+1} - \Rfree) \riskyshare_{t} \\ \bRat_{t+1} & = \aRat_{t} \Rport_{t+1} / \PGro_{t+1} \end{split}

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:

v~ˋta(at,ςt)=Et[Γt+1ρvt+1(bt+1,θt+1)Rt+1]v~ˋtς(at,ςt)=Et[Γt+1ρvt+1(bt+1,θt+1)at(Rt+1R)]\begin{split} \vOptAlt_{t}^{\aRat}(\aRat_{t}, \riskyshare_{t}) & = \Ex_{t} \left[ \PGro_{t+1}^{-\CRRA} \vFunc_{t+1}'\left(\bRat_{t+1}, \tShkEmp_{t+1}\right) \Rport_{t+1} \right] \\ \vOptAlt_{t}^{\riskyshare}(\aRat_{t}, \riskyshare_{t}) & = \Ex_{t} \left[ \PGro_{t+1}^{-\CRRA} \vFunc_{t+1}'\left(\bRat_{t+1}, \tShkEmp_{t+1}\right) \aRat_{t} (\Risky_{t+1} - \Rfree) \right] \\ \end{split}

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.

F.O.C.:v~ˋtς(at,ςt)=0E.C.:vta(at)=v~ˋta(at,ςt)\text{F.O.C.:} \qquad \vOptAlt_{t}^{\riskyshare}(\aRat_{t}, \riskyshare_{t}^{*}) = 0 \qquad \text{E.C.:} \qquad \vEnd_{t}^{\aRat}(\aRat_{t}) = \vOptAlt_{t}^{\aRat}(\aRat_{t}, \riskyshare_{t}^{*})

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:

v~t(mt)=maxctu(ct)+βvt(mtct)\vOpt_{t}(\mRat_{t}) = \max_{\cRat_{t}} \util(\cRat_{t}) + \DiscFac \vEnd_{t}(\mRat_{t}-\cRat_{t})

To solve, we derive the first-order condition with respect to ct\cRat_{t} which gives the familiar Euler equation:

u(ct)=βvt(mtct)=βvt(at)\utilFunc'(\cRat_t) = \DiscFac \vEnd_{t}'(\mRat_{t} - \cRat_{t}) = \DiscFac \vEnd_{t}'(\aRat_{t})

Inverting the above equation is the (first) EGM step.

ct(at)=u1(βvt(at))\cEndFunc_{t}(\aRat_{t}) = \utilFunc'^{-1}\left( \DiscFac \vEnd_{t}'(\aRat_{t}) \right)

Given the utility function above, the marginal utility of consumption and its inverse are

u(c)=cρu1(x)=x1/ρ.\utilFunc'(\cRat) = \cRat^{-\CRRA} \qquad \utilFunc'^{-1}(\xRat) = \xRat^{-1/\CRRA}.

Carroll (2006) demonstrates that by using an exogenous grid of [a]\aMat points we can find the unique ct([a])\cEndFunc_{t}(\aMat) 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

mt([a])=ct([a])+[a].\mEndFunc_{t}(\aMat) = \cEndFunc_{t}(\aMat) + \aMat.

This mt([a])\mEndFunc_{t}(\aMat) is the ``endogenous’’ grid that is consistent with the exogenous decision grid [a]\aMat. Now that we have a (mt([a]),ct([a]))(\mEndFunc_{t}(\aMat), \cEndFunc_{t}(\aMat)) pair for each a[a]\aRat \in \aMat, 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.

v~t(mt)=βvt(at)=u(ct)\vOpt_{t}'(\mRat_{t}) = \DiscFac \vEnd_{t}'(\aRat_{t}) = \utilFunc'(\cRat_{t})

2.5The labor-leisure subproblem

The labor-leisure subproblem can be restated more compactly as:

vt(bt,θt)=maxzth(zt)+v~t(bt+θt(1zt))\vFunc_{t}(\bRat_{t}, \tShkEmp_{t}) = \max_{ \leisure_{t}} \h(\leisure_{t}) + \vOpt_{t}(\bRat_{t} + \tShkEmp_{t}(1-\leisure_{t}))

The first-order condition with respect to leisure implies the labor-leisure Euler equation

h(zt)=v~t(mt)θt\h'(\leisure_{t}) = \vOpt_{t}'(\mRat_{t}) \tShkEmp_{t}

The marginal utility of leisure and its inverse are

h(z)=νzζh1(x)=(x/ν)1/ζ\h'(\leisure) = \labShare\leisure^{-\leiShare} \qquad \h'^{-1}(\xRat) = (\xRat/\labShare)^{-1/\leiShare}

Using an exogenous grid of [m]\mMat and [θ]\tShkMat, we can find leisure as

zt([m],[θ])=h1(v~t([m])[θ])\zEndFunc_{t}(\mMat, \tShkMat) = \h'^{-1}\left( \vOpt_{t}'(\mMat) \tShkMat \right)

In this case, it’s important to note that there are conditions for leisure itself. An agent with a small level of market resources mt\mRat_{t} might want to work more than their available time endowment, especially at higher levels of income θt\tShkEmp_{t}, 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 z^t([m],[θ])\hat{\zEndFunc}_{t}(\mMat, \tShkMat), where

z^t([m],[θ])=max[min[zt([m],[θ]),1],0]\hat{\zEndFunc}_{t}(\mMat, \tShkMat) = \max \left[ \min \left[ \zEndFunc_{t}(\mMat, \tShkMat), 1 \right], 0 \right]

Then, we derive labor as lt(mt,θt)=1z^t(mt,θt)\lEndFunc_{t}(\mRat_{t}, \tShkEmp_{t}) = 1 - \hat{\zEndFunc}_{t}(\mRat_{t}, \tShkEmp_{t}). Finally, for each θt\tShkEmp_{t} and mt\mRat_{t} as an exogenous grid, we can find the endogenous grid of bank balances as bt(mt,θt)=mtθtlt(mt,θt)\bEndFunc_{t}(\mRat_{t}, \tShkEmp_{t}) = \mRat_{t} - \tShkEmp_{t}\lEndFunc_{t}(\mRat_{t}, \tShkEmp_{t}).

The envelope condition then provides a heterogeneous Frisch elasticity of labor as simply

vtb(bt,θt)=v~t(mt)=h(zt)/θt.\vFunc_{t}^{b}(\bRat_{t}, \tShkEmp_{t}) = \vOpt_{t}'(\mRat_{t}) = \h'(\leisure_{t})/\tShkEmp_{t}.

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)

h()=ζ1+ν1+ν\h(\labor) = - \leiShare \frac{\labor^{1+\labShare}}{1+\labShare}

In this case, we can restate the problem as

h(z)=ζ(1z)1+ν1+ν\h(\leisure) = - \leiShare \frac{(1-\leisure)^{1+\labShare}}{1+\labShare}

The marginal utility of leisure and its inverse are

h(z)=ζ(1z)νh1(x)=1(x/ζ)1/ν\h'(\leisure) = \leiShare(1-\leisure)^{\labShare} \qquad \h'^{-1}(\xRat) = 1 - (\xRat/\leiShare)^{1/\labShare}

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 [a]\aMat results in a one-dimensional endogenous grid of total market resources [m]\mMat. However, as we know from standard EGM, the spacing in the [m]\mMat grid is different from the spacing in the [a]\aMat 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.

Warped Curvlinear Grid that results from multivariate EGM. This grid can be interpolated by WGI.

Figure 1:Warped Curvlinear Grid that results from multivariate EGM. This grid can be interpolated by WGI.

2.8Warped Grid Interpolation (WGI)

Assume we have a set of points indexed by (i,j)(i,j) in two-dimensional space for which we have corresponding functional values in a third dimension, such that f(xij,yij)=zijf(x_{ij},y_{ij}) = z_{ij}. In practice, we are interested in cases where the zijz_{ij} are difficult to compute and f(xij,yij)f(x_{ij},y_{ij}) is unknown, so we are unable to compute them at other values of xx and yy --- which is why we want to interpolate[3]. These (xij,yij)(x_{ij},y_{ij}) 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.

True function and curvilinear grid of points for which we know the value of the function.

Figure 2:True function and curvilinear grid of points for which we know the value of the function.

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 (i,j)(i,j) 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.

Homotopy between the curvilinear grid and the index coordinates of the matrix.

Figure 3:Homotopy 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 (x,y)=(3,5)(x,y) = (3, 5) pictured Figure 4. If we could find the corresponding point in the coordinate grid, interpolation would be straightforward. We can find where the xx-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 (y,z)(y,z), and we can interpolate in the y-direction to find the corresponding z-value for the point’s y-coordinate[4].

The method consist of extending the loci of points in the x dimension to find the corresponding crossing points in the y dimension.

Figure 4:The method consist of extending the loci of points in the xx dimension to find the corresponding crossing points in the yy dimension.

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 mt\mRat_{t} and an illiquid account of retirement savings nt\nRat_{t}. The worker maximizes their utility by choosing consumption ct\cRat_{t} and pension deposit dt\dRat_{t}. 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 (Γt+1\PGro_{t+1}) and a transitory (θt+1\tShkEmp_{t+1}) 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:

vt(mt,nt)=maxct,dtu(ct)+βEt[Γt+11ρvt+1(mt+1,nt+1)]s.t.ct0,dt0at=mtctdtbt=nt+dt+g(dt)mt+1=atR/Γt+1+θt+1nt+1=btRt+1//Γt+1\begin{split} \vFunc_{t}(\mRat_{t}, \nRat_{t}) & = \max_{\cRat_{t}, \dRat_{t}} \util(\cRat_{t}) + \DiscFac \Ex_{t} \left[ \PGro_{t+1}^{1-\CRRA} \vFunc_{t+1}(\mRat_{t+1}, \nRat_{t+1}) \right] \\ & \text{s.t.} \quad \cRat_{t} \ge 0, \quad \dRat_{t} \ge 0 \\ \aRat_{t} & = \mRat_{t} - \cRat_{t} - \dRat_{t} \\ \bRat_{t} & = \nRat_{t} + \dRat_{t} + g(\dRat_{t}) \\ \mRat_{t+1} & = \aRat_{t} \Rfree / \PGro_{t+1} + \tShkEmp_{t+1} \\ \nRat_{t+1} & = \bRat_{t} \Risky_{t+1} / / \PGro_{t+1} \end{split}

where

g(d)=χlog(1+d).\gFunc(\dRat) = \xFer \log(1+\dRat).

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 lt\lRat_{t} and retirement balance bt\bRat_{t} by choosing a pension deposit dt\dRat_{t}, which must be positive. The retirement balance b\bRat is the cash value of their retirement account plus their pension deposit and an additional amount g(dt)g(\dRat_{t}) 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.

vt(mt,nt)=maxdtv~t(lt,bt)s.t.dt0lt=mtdtbt=nt+dt+g(dt)\begin{split} \vFunc_{t}(\mRat_{t}, \nRat_{t}) & = \max_{\dRat_{t}} \vOpt_{t}(\lRat_{t}, \bRat_{t}) \\ & \text{s.t.} \quad \dRat_{t} \ge 0 \\ \lRat_{t} & = \mRat_{t} - \dRat_{t} \\ \bRat_{t} & = \nRat_{t} + \dRat_{t} + g(\dRat_{t}) \end{split}

After making their pension decision, the worker begins their consumption stage with liquid wealth lt\lRat_{t} and retirement balance bt\bRat_{t}. From their liquid wealth, the worker must choose a level of consumption to maximize utility and continuation value wt\wFunc_{t}. After consumption, the worker is left with post-decision states that represent liquid assets at\aRat_{t} and retirement balance bt\bRat_{t}, which passes through this problem unaffected because it can’t be liquidated until retirement.

v~t(lt,bt)=maxctu(ct)+βwt(at,bt)s.t.ct0at=ltct\begin{split} \vOpt_{t}(\lRat_{t}, \bRat_{t}) & = \max_{\cRat_{t}} \util(\cRat_{t}) + \DiscFac \wFunc_{t}(\aRat_{t}, \bRat_{t}) \\ & \text{s.t.} \quad \cRat_{t} \ge 0 \\ \aRat_{t} & = \lRat_{t} - \cRat_{t} \end{split}

Finally, the post-decision value function wt\wFunc_{t} 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.

wt(at,bt)=Et[Γt+11ρvt+1(mt+1,mt+1)]s.t.at0,bt0mt+1=atR/Γt+1+θt+1nt+1=btRt+1/Γt+1\begin{split} \wFunc_{t}(\aRat_{t}, \bRat_{t}) & = \Ex_{t} \left[ \PGro_{t+1}^{1-\CRRA} \vFunc_{t+1}(\mRat_{t+1}, \mRat_{t+1}) \right] \\ & \text{s.t.} \quad \aRat_{t} \ge 0, \quad \bRat_{t} \ge 0 \\ \mRat_{t+1} & = \aRat_{t} \Rfree / \PGro_{t+1} + \tShkEmp_{t+1} \\ \nRat_{t+1} & = \bRat_{t} \Risky_{t+1} / \PGro_{t+1} \end{split}

The advantage of conceptualizing this subproblem as a separate stage is that we can construct a function wt\wFunc_{t} 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 bt\bRat_{t} 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 bt\bRat_{t} 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:

vt(mt,nt)=maxdtv~t(mtdt,nt+dt+g(dt))\vFunc_{t}(\mRat_{t}, \nRat_{t}) = \max_{\dRat_{t}} \vOpt_{t}(\mRat_{t} - \dRat_{t}, \nRat_{t} + \dRat_{t} + \gFunc(\dRat_{t}))

The first-order condition is

v~tl(lt,bt)(1)+v~tb(lt,bt)(1+g(dt))=0.\vOpt_{t}^{\lRat}(\lRat_{t}, \bRat_{t})(-1) + \vOpt_{t}^{\bRat}(\lRat_{t}, \bRat_{t})(1+\gFunc'(\dRat_{t})) = 0.

Rearranging this equation gives

g(dt)=v~tl(lt,bt)v~tb(lt,bt)1\gFunc'(\dRat_{t}) = \frac{\vOpt_{t}^{\lRat}(\lRat_{t}, \bRat_{t})}{\vOpt_{t}^{\bRat}(\lRat_{t}, \bRat_{t})} - 1

where

g(d)=χ1+dg1(y)=χ/y1\gFunc'(\dRat) = \frac{\xFer}{1+\dRat} \qquad \gFunc'^{-1}(y) = \xFer/y - 1

Given that g(d)\gFunc'(\dRat) exists and is invertible, we can find

dt(lt,bt)=g1(v~tl(lt,bt)v~tb(lt,bt)1)\dEndFunc_{t}(\lRat_{t}, \bRat_{t}) = \gFunc'^{-1}\left( \frac{\vOpt_{t}^{\lRat}(\lRat_{t}, \bRat_{t})}{\vOpt_{t}^{\bRat}(\lRat_{t}, \bRat_{t})} - 1 \right)

Using this, we can back out nt\nRat_{t} as

nt(lt,bt)=btdt(lt,bt)g(dt(lt,bt))\nEndFunc_{t}(\lRat_{t}, \bRat_{t}) = \bRat_{t} - \dEndFunc_{t}(\lRat_{t}, \bRat_{t}) - \gFunc(\dEndFunc_{t}(\lRat_{t}, \bRat_{t}))

and mt\mRat_{t} as

mt(lt,bt)=lt+dt(lt,bt)\mEndFunc_{t}(\lRat_{t}, \bRat_{t}) = \lRat_{t} + \dEndFunc_{t}(\lRat_{t}, \bRat_{t})

In sum, given an exogenous grid (lt,bt)(\lRat_{t}, \bRat_{t}) we obtain the triple (mt(lt,bt),nt(lt,bt),dt(lt,bt))\left(\mEndFunc_{t}(\lRat_{t}, \bRat_{t}), \nEndFunc_{t}(\lRat_{t}, \bRat_{t}), \dEndFunc_{t}(\lRat_{t}, \bRat_{t})\right), which we can use to create an interpolator for the decision rule dt\dRat_{t}.

To close the solution method, the envelope conditions are

vtm(mt,nt)=v~tl(lt,bt)vtn(mt,nt)=v~tb(lt,bt)\begin{split} \vFunc_{t}^{\mRat}(\mRat_{t}, \nRat_{t}) & = \vOpt_{t}^{\lRat}(\lRat_{t}, \bRat_{t}) \\ \vFunc_{t}^{\nRat}(\mRat_{t}, \nRat_{t}) & = \vOpt_{t}^{\bRat}(\lRat_{t}, \bRat_{t}) \end{split}

3.5Unstructured Grid Interpolation

A regular, rectilinear exogenous grid of pension balances after deposit \bRat_{t} and liquid assets after consumption \lRat_{t}.

Figure 5:A regular, rectilinear exogenous grid of pension balances after deposit bt\bRat_{t} and liquid assets after consumption lt\lRat_{t}.

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 lt\lRat_{t} and pension balances post-deposit bt\bRat_{t}, we obtain Figure 6 which shows an irregular and unstructured endogenous grid of market resources mt\mRat_{t} and pension balances pre-deposit nt\nRat_{t}.

An irregular, unstructured endogenous grid of market resources \mRat_{t} and pension balances before deposit \nRat_{t}.

Figure 6:An irregular, unstructured endogenous grid of market resources mt\mRat_{t} and pension balances before deposit nt\nRat_{t}.

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.

XN(μ,Σ)s.t.xiN(μi,σii)andσij=E[(xiμi)(xjμj)]i,j{1,,n}.\begin{gathered} \mathbf{X} \sim \mathcal{N}(\mathbf{\mu}, \mathbf{\Sigma}) \quad \text{s.t.} \quad x_i \sim \mathcal{N}(\mu_i, \sigma_ {ii}) \\ \text{and} \quad \sigma_{ij} = \Ex[(x_i - \mu_i)(x_j - \mu_j)] \quad \forall i,j \in \{1, \ldots, n\}. \end{gathered}

where

X=[x1x2xn]μ=[μ1μ2μn]Σ=[σ11σ12σ1nσ21σ22σ2nσn1σn2σnn].\mathbf{X} = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix} \quad \mathbf{\mu} = \begin{bmatrix} \mu_1 \\ \mu_2 \\ \vdots \\ \mu_n \end{bmatrix} \quad \mathbf{\Sigma} = \begin{bmatrix} \sigma_{11} & \sigma_{12} & \cdots & \sigma_{1n} \\ \sigma_{21} & \sigma_{22} & \cdots & \sigma_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ \sigma_{n1} & \sigma_{n2} & \cdots & \sigma_{nn} \end{bmatrix}.

Being infinitely dimensional, a Gaussian Process can be used to represent a probability distribution over the space of functions in nn dimensions. Thus, a Gaussian Process Regression is used to find the best fit function to a set of data points.

P(fX)=N(fm,K)\mathbb{P}(\mathbf{f} | \mathbf{X}) = \mathcal{N}(\mathbf{f} | \mathbf{m}, \mathbf{K})

where f\mathbf{f} is the vector of function values at the points X\mathbf{X}, m\mathbf{m} is the mean of the function, and K\mathbf{K} 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

k(xi,xj)=σf2exp(12l2(xixj)(xixj)).k(\mathbf{x}_i, \mathbf{x}_j) = \sigma^2_f \exp\left(-\frac{1}{2l^2} (\mathbf{x}_i - \mathbf{x}_j)' (\mathbf{x}_i - \mathbf{x}_j)\right).

Using GPR to interpolate a function ff, we can both predict the value of the function at a point x\mathbf{x}_* 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.

The true function that we are trying to approximate and a sample of data points.

Figure 7:The true function that we are trying to approximate and a sample of data points.

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.

A random sample of functions from the GPR posterior that fit the data. The goal of GPR is to find the function that best fits the data.

Figure 8:A random sample of functions from the GPR posterior that fit the data. The goal of GPR is to find the function that best fits 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.

GPR finds the function that best fits the data given some hyperparameters. GPR then optimizes over the parameter space to find the function that minimizes the negative log-likelihood of the data.

Figure 9:GPR finds the function that best fits the data given some hyperparameters. GPR then optimizes over the parameter space to find the function that minimizes the negative log-likelihood of the data.

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 nn control variables, then the problem should be split into nn 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 c+a=m\cRat + \aRat = \mRat 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,

v(b,θ)=maxcu(c)+v~(b,θ)s.t.b=bcθ\begin{split} \vFunc(\bRat, \tShkEmp) & = \max_{\cRat} \uFunc(\cRat) + \vOpt(\bRat', \tShkEmp) \\ & \text{s.t.}\\ \bRat' & = \bRat - \cRat \ge - \tShkEmp \end{split}

while the labor-leisure subproblem would have an additional constraint

v~(b,θ)=maxzh(z)+v(a)s.t.0z1a=b+θ(1z)0.\begin{split} \vOpt(\bRat', \tShkEmp) & = \max_{\leisure} \h(\leisure) + \vEnd(\aRat) \\ & \text{s.t.} \\ 0 & \le \leisure \le 1 \\ \aRat & = \bRat' + \tShkEmp(1 - \leisure) \ge 0. \end{split}

Therefore, strategic ordering of subproblems can greatly simplify the solution process and reduce computational the burden.

Consider the utility function of the form

U(y)=ui(yi)+ui(yi)\UFunc( \yRat) = \uFunc_{-i}( \yRat^{-i}) + \uFunc_i(\yRat^i)

where yi\yRat^{i} is the ii-th control variable and yi\yRat^{-i} is the vector of all control variables except the ii-th one.

which is separable in the state and control variables that correspond to the index ii.

Vt(xt,st)=maxytΓt(xt,st)U(yt)+βEt[Vt+1(xt+1,st+1)x~t,st]s.t.x~t=Tt(xt,yt)xt+1=Gt+1(x~t,st)\begin{split} \VFunc_{t}(\xRat_t, \sRat_t) &= \max_{\yRat_t \in \Gamma_t(\xRat_t, \sRat_t)} \UFunc(\yRat_t) + \DiscFac \Ex_{t} \left[ \VFunc_{t+1}(\xRat_{t+1}, \sRat_{t+1}) | \tilde{\xRat}_t, \sRat_t \right] \\ & \text{s.t.} \\ \tilde{\xRat}_t &= \TFunc_t(\xRat_t, \yRat_t) \\ \xRat_{t+1} &= \GFunc_{t+1}(\tilde{\xRat}_t, \sRat_t) \\ \end{split}

For simplicity, define

Wt(x~t,st)=βEt[Vt+1(Gt+1(x~t,st),st+1)x~t,st]\WFunc_t(\tilde{\xRat}_t, \sRat_t) = \DiscFac \Ex_{t} \left[ \VFunc_{t+1}(\GFunc_{t+1}(\tilde{\xRat}_t, \sRat_t), \sRat_{t+1}) | \tilde{\xRat}_t, \sRat_t \right]

then

Vt(xt,st)=maxytΓt(xt,st)U(yt)+Wt(x~t,st)s.t.x~t=Tt(xt,yt)\begin{split} \VFunc_{t}(\xRat_t, \sRat_t) &= \max_{\yRat_t \in \Gamma_t(\xRat_t, \sRat_t)} \UFunc( \yRat_t) + \WFunc_t(\tilde{\xRat}_t, \sRat_t) \\ & \text{s.t.} \\ \tilde{\xRat}_t &= \TFunc_t(\xRat_t, \yRat_t) \end{split}

the first order condition

U(yt)yti+j=1nWt(x~t,st)x~tjTtj(xt,yt)yti=0\frac{\partial \UFunc( \yRat_t)}{\partial \yRat_t^i} + \sum_{j=1}^{n} \frac{\partial \WFunc_t(\tilde{\xRat}_t, \sRat_t)}{\partial \tilde{\xRat}_{t}^j} \frac{\partial \TFunc_{t}^j(\xRat_t, \yRat_t)}{\partial \yRat_t^i} = 0

we require Ttj(xt,yt)yti=0\frac{\partial \TFunc_{t}^j(\xRat_t, \yRat_t)}{\partial \yRat_t^i} = 0 for jij \neq i to be able to solve for yti\yRat_t^i.

U(yt)yti+Wt(x~t,st)x~tiTti(xt,yt)yti=0\frac{\partial \UFunc( \yRat_t)}{\partial \yRat_t^i} + \frac{\partial \WFunc_t(\tilde{\xRat}_t, \sRat_t)}{\partial \tilde{\xRat}_{t}^i} \frac{\partial \TFunc_{t}^i(\xRat_t, \yRat_t)}{\partial \yRat_t^i} = 0

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:

V(x)=maxyΓ(x)U(x,y)+βW(a)s.t.a=T(x,y)\begin{split} \VFunc(\xRat) & = \max_{\yRat \in \PGro(\xRat)} \UFunc(\xRat, \yRat) + \DiscFac \WFunc(\aRat) \\ & \text{s.t.} \\ \aRat & = \TFunc(\xRat,\yRat) \end{split}

For an interior solution, the first-order condition is thus

Uy(x,y)+βW(a)Ty(x,y)=0\UFunc'_{\yRat}(\xRat, \yRat) + \DiscFac \WFunc'(\aRat)\TFunc'_{\yRat}(\xRat,\yRat) = 0

If, as we assumed, the utility function is differentiable and invertible, then the Endogenous Grid Method consists of

y=(Uy(x,y))1[βW(a)Ty(x,y)]\yRat = \left(\UFunc'_{\yRat}(\xRat, \yRat)\right)^{-1} \left[ -\DiscFac \WFunc'(\aRat)\TFunc'_{\yRat}(\xRat,\yRat)\right]

By using an exogenous grid of the post-decision state a\aRat, we can solve for the optimal decision rule y\yRat 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.

V(x)=maxyΓ(x)W(a)s.t.a=T(x,y)\begin{split} \VFunc(\xRat) & = \max_{\yRat \in \PGro(\xRat)} \WFunc(\aRat) \\ & \text{s.t.} \\ \aRat & = \TFunc(\xRat,\yRat) \end{split}

Here, the first-order condition is

W(a)Ty(x,y)=0\WFunc'(\aRat)\TFunc'_{\yRat}(\xRat,\yRat) = 0

and the Endogenous Grid Method step is

y=(Ty(x,y))1[1/W(a)]\yRat = \left(\TFunc'_{\yRat}(\xRat,\yRat)\right)^{-1} \left[ 1 / \WFunc'(\aRat)\right]

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 wt(mt)\wFunc_{t}(\mRat_{t}) the problem of a retired household at time tt with total resources m\mRat. The retired household solves a simple consumption-savings problem with no income uncertainty and a certain next period pension of θ\underline{\tShkEmp}.

wt(mt)=maxctu(ct)+βwt+1(mt)s.t.at=mtctmt+1=Raat+θ\begin{split} \wFunc_{t}(\mRat_{t}) & = \max_{\cRat_{t}} \util(\cRat_{t}) + \DiscFac \wFunc_{t+1}(\mRat_{t}) \\ & \text{s.t.} \\ \aRat_{t} & = \mRat_{t} - \cRat_{t} \\ \mRat_{t+1} & = \Rfree_{\aRat} \aRat_{t} + \underline{\tShkEmp} \end{split}

Notice that there is no uncertainty and the household receives a retirement income θ\underline{\tShkEmp} every period until death.

7.2The problem for a worker household

The value function of a worker household is

Vt(mt,nt)=Eϵmax{vt(mt,nt,W)+σϵϵW,vt(mt,nt,R)+σϵϵR}\VFunc_{t}(\mRat_{t}, \nRat_{t}) = \Ex_\error \max \left\{ \vFunc_{t}(\mRat_{t}, \nRat_{t}, \Work) + \sigma_{\error} \error_{\Work} , \vFunc_{t}(\mRat_{t}, \nRat_{t}, \Retire) + \sigma_{\error} \error_{\Retire} \right\}

where the choice specific problem for a working household that decides to continue working is

vt(mt,nt,W)=maxct,dtu(ct)α+βEt[Vt+1(mt+1,nt+1)]s.t.at=mtctdtbt=nt+dt+g(dt)mt+1=Raat+θt+1nt+1=Rbbt\begin{split} \vFunc_{t}(\mRat_{t}, \nRat_{t}, \Work) & = \max_{\cRat_{t}, \dRat_{t}} \util(\cRat_{t}) - \kapShare + \DiscFac \Ex_{t} \left[ \VFunc_{t+1}(\mRat_{t+1}, \nRat_{t+1}) \right] \\ & \text{s.t.} \\ \aRat_{t} & = \mRat_{t} - \cRat_{t} - \dRat_{t} \\ \bRat_{t} & = \nRat_{t} + \dRat_{t} + \gFunc(\dRat_{t}) \\ \mRat_{t+1} & = \Rfree_{\aRat} \aRat_{t} + \tShkEmp_{t+1} \\ \nRat_{t+1} & = \Rfree_{\bRat} \bRat_{t} \end{split}

and the choice specific problem for a working household that decides to retire is

vt(mt,nt,R)=wt(mt+nt)\vFunc_{t}(\mRat_{t}, \nRat_{t}, \Retire) = \wFunc_{t}(\mRat_{t}+\nRat_{t})

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

vt(at,bt)=βEt[Vt+1(mt+1,nt+1)]s.t.mt+1=Raat+θt+1nt+1=Rbbt\begin{split} \vEnd_{t}(\aRat_{t}, \bRat_{t}) & = \DiscFac \Ex_{t} \left[ \VFunc_{t+1}(\mRat_{t+1}, \nRat_{t+1}) \right] \\ & \text{s.t.} \\ \mRat_{t+1} & = \Rfree_{\aRat} \aRat_{t} + \tShkEmp_{t+1} \\ \nRat_{t+1} & = \Rfree_{\bRat} \bRat_{t} \end{split}

Then redefine the working agent’s problem as

vt(mt,nt,W)=maxct,dtu(ct)α+vt(at,bt)at=mtctdtbt=nt+dt+g(dt)\begin{split} \vFunc_{t}(\mRat_{t}, \nRat_{t}, \Work) & = \max_{\cRat_{t}, \dRat_{t}} \util(\cRat_{t}) - \kapShare + \vEnd_{t}(\aRat_{t}, \bRat_{t}) \\ \aRat_{t} & = \mRat_{t} - \cRat_{t} - \dRat_{t} \\ \bRat_{t} & = \nRat_{t} + \dRat_{t} + \gFunc(\dRat_{t}) \\ \end{split}

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 dt\dRat_{t}, 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 lt\lRat_{t} and pension assets of bt\bRat_{t}.

vt(mt,nt,W)=maxdtv~t(lt,bt)s.t.lt=mtdtbt=nt+dt+g(dt)\begin{split} \vFunc_{t}(\mRat_{t}, \nRat_{t}, \Work) & = \max_{\dRat_{t}} \vOpt_{t}(\lRat_{t}, \bRat_{t}) \\ & \text{s.t.} \\ \lRat_{t} & = \mRat_{t} - \dRat_{t} \\ \bRat_{t} & = \nRat_{t} + \dRat_{t} + \gFunc(\dRat_{t}) \end{split}

Now, the agent can move on to picking their consumption and savings; we can call this the pure consumption problem or inner loop.

v~t(lt,bt)=maxctu(ct)α+vt(at,bt)s.t.at=ltct\begin{split} \vOpt_{t}(\lRat_{t}, \bRat_{t}) & = \max_{\cRat_{t}} \util(\cRat_{t}) - \kapShare + \vEnd_{t}(\aRat_{t}, \bRat_{t}) \\ & \text{s.t.} \\ \aRat_{t} & = \lRat_{t} - \cRat_{t} \\ \end{split}

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

v~t(lt,bt)=maxctu(ct)α+vt(ltct,bt)\vOpt_{t}(\lRat_{t}, \bRat_{t}) = \max_{\cRat_{t}} \util(\cRat_{t}) - \kapShare + \vEnd_{t}(\lRat_{t} - \cRat_{t}, \bRat_{t})

The first-order condition is

u(ct)=vta(ltct,bt)=vta(at,bt)\util'(\cRat_{t}) = \vEnd_{t}^{\aRat}(\lRat_{t}-\cRat_{t}, \bRat_{t}) = \vEnd_{t}^{\aRat}(\aRat_{t}, \bRat_{t})

We can invert this Euler equation as in standard EGM to obtain the consumption function.

ct(at,bt)=u1(vta(at,bt))\cEndFunc_{t}(\aRat_{t}, \bRat_{t}) = \util'^{-1}\left(\vEnd_{t}^{\aRat}(\aRat_{t}, \bRat_{t})\right)

Again as before, lt(at,bt)=ct(at,bt)+at\lEndFunc_{t}(\aRat_{t}, \bRat_{t}) = \cEndFunc_{t}(\aRat_{t}, \bRat_{t}) + \aRat_{t}. To sum up, using an exogenous grid of (at,bt)(\aRat_{t}, \bRat_{t}) we obtain the trio (ct(at,bt),lt(at,bt),bt)(\cEndFunc_{t}(\aRat_{t}, \bRat_{t}), \lEndFunc_{t}(\aRat_{t}, \bRat_{t}), \bRat_{t}) which provides an interpolating function for our optimal consumption decision rule over the (l,b)(\lRat, \bRat) grid. Without loss of generality, assume lt=lt(at,bt)\lEndFunc_{t} = \lEndFunc_{t}(\aRat_{t}, \bRat_{t}) and define the interpolating function as

cˇt(lt,bt)ct(at,bt)\cTarg_{t}(\lEndFunc_{t}, \bRat_{t}) \equiv \cEndFunc_{t}(\aRat_{t}, \bRat_{t})

For completeness, we derive the envelope conditions as well, and as we will see, these will be useful when solving the next section.

v~tl(lt,bt)=vta(at,bt)=u(ct)v~tb(lt,bt)=vtb(at,bt)\begin{split} \vOpt_{t}^{\lRat}(\lRat_{t}, \bRat_{t}) & = \vEnd_{t}^{\aRat}(\aRat_{t}, \bRat_{t}) = \util'(\cRat_{t}) \\ \vOpt_{t}^{\bRat}(\lRat_{t}, \bRat_{t}) & = \vEnd_{t}^{\bRat}(\aRat_{t}, \bRat_{t}) \end{split}

7.4.2Solving the Outer Pension Deposit Problem

Now, we can move on to solving the deposit problem, which we can also summarize as

vt(mt,nt,W)=maxdtv~t(mtdt,nt+dt+g(dt))\vFunc_{t}(\mRat_{t}, \nRat_{t}, \Work) = \max_{\dRat_{t}} \vOpt_{t}(\mRat_{t} - \dRat_{t}, \nRat_{t} + \dRat_{t} + \gFunc(\dRat_{t}))

The first-order condition is

v~tl(lt,bt)(1)+v~tb(lt,bt)(1+g(dt))=0\vOpt_{t}^{\lRat}(\lRat_{t}, \bRat_{t})(-1) + \vOpt_{t}^{\bRat}(\lRat_{t}, \bRat_{t})(1+\gFunc'(\dRat_{t})) = 0

Rearranging this equation gives

g(dt)=v~tl(lt,bt)v~tb(lt,bt)1\gFunc'(\dRat_{t}) = \frac{\vOpt_{t}^{\lRat}(\lRat_{t}, \bRat_{t})}{\vOpt_{t}^{\bRat}(\lRat_{t}, \bRat_{t})} - 1

Assuming that g(d)\gFunc'(\dRat) exists and is invertible, we can find

dt(lt,bt)=g1(v~tl(lt,bt)v~tb(lt,bt)1)\dEndFunc_{t}(\lRat_{t}, \bRat_{t}) = \gFunc'^{-1}\left( \frac{\vOpt_{t}^{\lRat}(\lRat_{t}, \bRat_{t})}{\vOpt_{t}^{\bRat}(\lRat_{t}, \bRat_{t})} - 1 \right)

Using this, we can back out nt\nRat_{t} as

nt(lt,bt)=btdt(lt,bt)g(dt(lt,bt))\nEndFunc_{t}(\lRat_{t}, \bRat_{t}) = \bRat_{t} - \dEndFunc_{t}(\lRat_{t}, \bRat_{t}) - \gFunc(\dEndFunc_{t}(\lRat_{t}, \bRat_{t}))

and mt\mRat_{t} as

mt(lt,bt)=lt+dt(lt,bt)\mEndFunc_{t}(\lRat_{t}, \bRat_{t}) = \lRat_{t} + \dEndFunc_{t}(\lRat_{t}, \bRat_{t})

In sum, given an exogenous grid (lt,bt)(\lRat_{t}, \bRat_{t}) we obtain the triple (mt(lt,bt),nt(lt,bt),dt(lt,bt))\left(\mEndFunc_{t}(\lRat_{t}, \bRat_{t}), \nEndFunc_{t}(\lRat_{t}, \bRat_{t}), \dEndFunc_{t}(\lRat_{t}, \bRat_{t})\right), which we can use to create an interpolator for the decision rule dt\dRat_{t}.

To close the solution method, the envelope conditions are

vtm(mt,nt,W)=v~tl(lt,bt)vtn(mt,nt,W)=v~tb(lt,bt)\begin{split} \vFunc_{t}^{\mRat}(\mRat_{t}, \nRat_{t}, \Work) & = \vOpt_{t}^{\lRat}(\lRat_{t}, \bRat_{t}) \\ \vFunc_{t}^{\nRat}(\mRat_{t}, \nRat_{t}, \Work) & = \vOpt_{t}^{\bRat}(\lRat_{t}, \bRat_{t}) \end{split}

7.5Is g invertible?

We’ve already seen that u()\util'(\cdot) is invertible, but is g\gFunc?

g(d)=χlog(1+d)g(d)=χ1+dg1(y)=χ/y1\gFunc(\dRat) = \xFer \log(1+\dRat) \qquad \gFunc'(\dRat) = \frac{\xFer}{1+\dRat} \qquad \gFunc'^{-1}(y) = \xFer/y - 1

7.6The Post-Decision Value and Marginal Value Functions

vt(a,b)=βEt[V(mt+1,nt+1)]s.t.mt+1=Raat+θt+1nt+1=Rbbt\begin{split} \vEnd_{t}(\aRat, \bRat) & = \DiscFac \Ex_{t} \left[ \VFunc(\mRat_{t+1}, \nRat_{t+1}) \right] \\ & \text{s.t.} \\ \mRat_{t+1} & = \Rfree_{\aRat} \aRat_{t} + \tShkEmp_{t+1} \\ \nRat_{t+1} & = \Rfree_{\bRat} \bRat_{t} \end{split}

and

vta(at,bt)=βRaEt[Vt+1m(mt+1,nt+1)]s.t.mt+1=Raat+θt+1nt+1=Rbbt\begin{split} \vEnd_{t}^{\aRat}(\aRat_{t}, \bRat_{t}) & = \DiscFac \Rfree_{\aRat} \Ex_{t} \left[ \VFunc^{\mRat}_{t+1}(\mRat_{t+1}, \nRat_{t+1}) \right] \\ & \text{s.t.} \\ \mRat_{t+1} & = \Rfree_{\aRat} \aRat_{t} + \tShkEmp_{t+1} \\ \nRat_{t+1} & = \Rfree_{\bRat} \bRat_{t} \end{split}

and

vtb(at,bt)=βRbEt[Vt+1n(mt+1,nt+1)]s.t.mt+1=Raat+θt+1nt+1=Rbbt\begin{split} \vEnd_{t}^{\bRat}(\aRat_{t}, \bRat_{t}) & = \DiscFac \Rfree_{\bRat} \Ex_{t} \left[ \VFunc^{\nRat}_{t+1}(\mRat_{t+1}, \nRat_{t+1}) \right] \\ & \text{s.t.} \\ \mRat_{t+1} & = \Rfree_{\aRat} \aRat_{t} + \tShkEmp_{t+1} \\ \nRat_{t+1} & = \Rfree_{\bRat} \bRat_{t} \end{split}

7.7Taste Shocks

From discrete choice theory and from DCEGM paper, we know that

Et[Vt+1(mt+1,nt+1,ϵt+1)]=σlog[D{W,R}exp(vt+1(mt+1,nt+1,D)σϵ)]\Ex_{t} \left[ \VFunc_{t+1}(\mRat_{t+1}, \nRat_{t+1}, \error_{t+1}) \right] = \sigma \log \left[ \sum_{\Decision \in \{\Work, \Retire\}} \exp \left( \frac{\vFunc_{t+1}(\mRat_{t+1}, \nRat_{t+1}, \Decision)}{\sigma_\error} \right) \right]

and

Pt(D  mt+1,nt+1)=exp(vt+1(mt+1,nt+1,D)/σϵ)D{W,R}exp(vt+1(mt+1,nt+1,D)σϵ)\Prob_{t}(\Decision ~ \lvert ~ \mRat_{t+1}, \nRat_{t+1}) = \frac{\exp \left( \vFunc_{t + 1}(\mRat_{t+1}, \nRat_{t+1}, \Decision) / \sigma_\error \right) }{ \sum\limits_{\Decision \in \{\Work, \Retire\}} \exp \left( \frac{\vFunc_{t+1}(\mRat_{t+1}, \nRat_{t+1}, \Decision)}{\sigma_\error} \right)}

the first-order conditions are therefore

v~ˋtm(mt+1,nt+1)=D{W,R}Pt(D  mt+1,nt+1)vt+1m(mt+1,nt+1,D)\vOptAlt_{t}^{\mRat}(\mRat_{t+1}, \nRat_{t+1}) = \sum_{\Decision \in \{\Work, \Retire\}} \Prob_{t}(\Decision ~ \lvert ~ \mRat_{t+1}, \nRat_{t+1}) \vFunc_{t+1}^{\mRat}(\mRat_{t+1}, \nRat_{t+1}, \Decision)

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

Footnotes
  1. As in Carroll (2009), where the utility of normalized consumption and leisure is defined as

    u(ct,zt)=Pt1ρct1ρ1ρ+(νPt)1ρzt1ζ1ζ\utilFunc(\cRat_{t}, \leisure_{t}) = \PLev_{t}^{1-\CRRA} \frac{\cRat_{t}^{1-\CRRA}}{1-\CRRA} + (\labShare\PLev_{t}) ^{1-\CRRA} \frac{\leisure_{t}^{1-\leiShare}}{1-\leiShare}
  2. For this illustration, we generate zz’s arbitrarily using the function

    f(x,y)=(xy)1/4.f(x,y) = (xy)^{1/4}.
  3. For more examples of the Warped Grid Interpolation method in action, see the github project alanlujan91/multinterp.

  4. Gardner et al. (2018)

  5. For details see notebook.

References
  1. 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
  2. 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
  3. 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
  4. 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
  5. 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.
Content
Introduction