Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

DCEGM Upper Envelope

“The endogenous grid method for discrete-continuous dynamic choice models with (or without) taste shocks”

For the following badges: GitHub does not allow click-through redirects; right-click to get the link, then paste into navigation bar

This notebook provides a simple introduction to the “DCEGM” algorithm . DCEGM extends the EGM method proposed in to problems with both continuous (e.g. consumption) and discrete (e.g. retirement) decisions.

The main challenge for the EGM algorithm in discrete-continuous problems is that the discrete decisions generate “kinks” in the value function, making it non-concave and rendering the first order condition used by EGM a necessary but not sufficient for optimality. In practice, this causes the EGM inversion step to produce (resource, consumption) points that are not optimal. DCEGM incorporates a method to filter the points produced by EGM so that only the truly optimal ones are used in producing an approximation to the solution.

This filtering process consists mainly of computing “upper-envelopes” of the candidate points: lines that are made up only of the points with the higher values.

This notebook presents HARK’s tool for calculating upper-envelopes and then uses it to solve a simple three-period discrete-continuous problem using DCEGM.

Upper envelopes

Start by importing the tools.

Applying EGM to value functions with kinks, as the ones that result from discrete-continuous problems, will often result in grids for market resources that are not monotonic and candidate choices at those points that are sub-optimal. Consider the following example output.

<Figure size 640x480 with 1 Axes>

There are two main issues:

  • The line implied by the points “goes backwards” at some points. This is because the m-grid is not monotonic.

  • Some segments of the line are under other segments of the line. This means that we have sub-optimal points.

A first step in filtering out sub-optimal points is to split the previous line in its non-decreasing segments. This is achieved by HARK’s function calc_segments.

<Figure size 640x480 with 1 Axes>

The next step is to produce the upper-envelope of these segments: a line comprised of the points that are not under any other segment. This is done by HARK’s upper_envelopefunction. We now apply it and plot the result

<Figure size 640x480 with 1 Axes>

And there we have it! a monotonic value without the sub-optimal points or reverse jumps!

Having introduced the main tools, we are now ready to apply DCEGM to a simple example.

An example: writing a will

Author: Mateo Velásquez-Giraldo

We now present a basic example to illustrate the use of the previous tools in solving dynamic optimization problems with discrete and continuous decisions.

The model represents an agent that lives for three periods and decides how much of his resources to consume in each of them. On the second period, he must additionally decide whether to hire a lawyer to write a will. Having a will has the upside of allowing the agent to leave a bequest in his third and last period of life, which gives him utility, but has the downside that the lawyer will charge a fraction of his period 3 resources.

On each period, the agent receives a deterministic amount of resources w. The problem, therefore, is fully deterministic.

I now present the model formally, solving it backwards.

But first, some setup and calibration:

The third (last) period of life

In the last period of life, the agent’s problem is determined by his total amount of resources m3 and a state variable W that indicates whether he wrote a will (W=1) or not (W=0).

The agent without a will

An agent who does not have a will simply consumes all of his available resources. Therefore, his value and consumption functions will be:

V3(m3,W=0)=u(m3)
c3(m3,W=0)=m3

Where u(⋅) gives the utility from consumption. We assume a CRRA specification u(c)=c1−ρ1−ρ.

The agent with a will

An agent who wrote a will decides how to allocate his available resources m3 between his consumption and a bequest. We assume an additive specification for the utility of a given consumption-bequest combination that follows a particular case in Carroll (2000). The component of utility from leaving a bequest x is assumed to be ln⁡(x+1). Therefore, the agent’s value function is

V3(m3,W=1)=max0≤c3≤m3⁡u(c3)+ln⁡(m3−c3+1)

For ease of exposition we consider the case ρ=2, where Carroll (2000) shows that the optimal consumption level is given by

c3(m3,W=1)=min⁡[m3,−1+1+4(m3+1)2].

The consumption function shows that m3=1 is the level of resources at which an important change of behavior occurs: agents leave bequests only for m3>1. Since an important change of behavior happens at this point, we call it a ‘kink-point’ and add it to our grids.

<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>

The second period

On the second period, the agent takes his resources as given (the only state variable) and makes two decisions:

  • Whether to write a will or not.

  • What fraction of his resources to consume.

These decisions can be seen as happening sequentially: the agent first decides whether to write a will or not, and then consumes optimally in accordance with his previous decision. Since we solve the model backwards in time, we first explore the consumption decision, conditional on the choice of writing a will or not.

An agent who decides not to write a will

After deciding not to write a will, an agent solves the optimization problem expressed in the following conditional value function

ν(m2|w=0)=max0≤c≤m2⁡u(c)+βV3(m3,W=0)s.t.m3=m2−c+w

We can approximate a solution to this problem through the method of endogenous gridpoints. This yields approximations to ν(⋅|w=0) and c2(⋅|w=0)

An agent who decides to write a will

An agent who decides to write a will also solves for his consumption dinamically. We assume that the lawyer that helps the agent write his will takes some fraction τ of his total resources in period 3. Therefore, the evolution of resources is given by m3=(1−τ)(m2−c2+w). The conditional value function of the agent is therefore:

ν(m2|w=1)=max0≤c≤m2⁡u(c)+βV3(m3,W=1)s.t.m3=(1−τ)(m2−c+w)

We also approximate a solution to this problem using the EGM. This yields approximations to ν(⋅|w=1) and c2(⋅|w=1).

The decision whether to write a will or not

With the conditional value functions at hand, we can now express and solve the decision of whether to write a will or not, and obtain the unconditional value and consumption functions.

V2(m2)=max⁡{ν(m2|w=0),ν(m2|w=1)}
w∗(m2)=arg⁡maxw∈{0,1}⁡{ν(m2|w=w)}
c2(m2)=c2(m2|w=w∗(m2))

We now construct these objects.

<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>

The first period

In the first period, the agent simply observes his market resources and decides what fraction of them to consume. His problem is represented by the following value function

V(m1)=max0≤c≤m1⁡u(c)+βV2(m2)s.t.m2=m1−c+w.

Although this looks like a simple problem, there are complications introduced by the kink in V2(⋅), which is clearly visible in the plot from the previous block. Particularly, note that V2′(⋅) and c2(⋅) are not monotonic: there are now multiple points m for which the slope of V2(m) is equal. Thus, the Euler equation becomes a necessary but not sufficient condition for optimality and the traditional EGM inversion step can generate non-monotonic endogenous m gridpoints.

We now illustrate this phenomenon.

<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>

The previous cell applies the endogenous gridpoints method to the first period problem. The plots illustrate that the sequence of resulting endogenous gridpoints {mi}i=1N is not monotonic. This results in intervals of market resources over which we have multiple candidate values for the value function. This is the point where we must apply the upper envelope function illustrated above.

We finally use the resulting consumption and value grid points to create the first period value and consumption functions.

<Figure size 640x480 with 1 Axes>
<Figure size 640x480 with 1 Axes>

References

[1] Iskhakov, F. , Jørgensen, T. H., Rust, J. and Schjerning, B. (2017), The endogenous grid method for discrete‐continuous dynamic choice models with (or without) taste shocks. Quantitative Economics, 8: 317-365. doi:10.3982/QE643

[2] Carroll, C. D. (2006). The method of endogenous gridpoints for solving dynamic stochastic optimization problems. Economics letters, 91(3), 312-320.

References
  1. Iskhakov, F., Jørgensen, T. H., Rust, J., & Schjerning, B. (2017). The endogenous grid method for discrete-continuous dynamic choice models with (or without) taste shocks: DC-EGM method for dynamic choice models. Quantitative Economics, 8(2), 317–365. 10.3982/qe643