Skip to main content
Log in

A Guide on Solving Non-convex Consumption-Saving Models

  • Published:
Computational Economics Aims and scope Submit manuscript

Abstract

Consumption-saving models with adjustment costs or discrete choices are typically hard to solve numerically due to the presence of non-convexities. This paper provides a number of tools to speed up the solution of such models. Firstly, I use that many consumption models have a nesting structure implying that the continuation value can be efficiently pre-computed and the consumption choice solved separately before the remaining choices. Secondly, I use that an endogenous grid method extended with an upper envelope step can be used to solve efficiently for the consumption choice. Thirdly, I use that the required pre-computations can be optimized by a novel loop reordering when interpolating the next-period value function. As an illustrative example, I solve a model with non-durable consumption and durable consumption subject to adjustment costs. Combining the provided tools, the model is solved almost 50 times faster than with standard value function iteration for a given level of accuracy. Software is provided in both Python and C++.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

Notes

  1. Jørgensen (2013) and Low and Meghir (2017) shows that EGM is orders of magnitude faster than VFI in one dimensional models.

  2. The code is available at github.com/NumEconCopenhagen/ConsumptionSavingNotebooks. The Python code is optimized with just-in-time compilation from the Numba package.

  3. See Hull (2015) for some extensions and an application in economics.

  4. An alternative would be time iteration, see Rendahl (2015).

  5. An alternative is to instead interpolate the keepers consumption function and then calculate the implied value of choice by evaluating the utility function and the post-decision value function. This could in principle improve precision, but the effect seems minor in practice.

  6. Assume that K evaluations of the value-of-choice is needed when solving the keeper problem for each node in the state space, and Q is the number of integration nodes needed to calculate the expectation in the continuation value. In NVFI we then need \(K+\vartheta Q\) interpolations for each node in the state grid, where \(\vartheta \) is the ratio of nodes in the post-decision grid relative to the state grid. In VFI we need KQ interpolations for each node. We have \(KQ>K+\vartheta Q\Leftrightarrow \vartheta <K(1-Q^{-1})\), which for reasonable Q roughly implies that fewer interpolations is needed whenever \(\vartheta <K\).

  7. See the detailed discussion in Ludwig and Schön (2018) regarding triangulazation and Delaunay interpolation.

  8. The first upper envelope algorithms were developed by Fella (2014) and Iskhakov et al. (2017) for one dimensional models, and were thus not designed to deliver regular grids in multi-dimensional models.

  9. Due to the envelope theorem, we have that \(v_{t,m}(p_{t},n_{t},m_{t})=u_{c}(c_{t},d_{t})\), and therefore we could instead have used the definition \(q_{t}(p_{t},d_{t},a_{t})\equiv w_{t,a}(p_{t},d_{t},q_{t})=\beta R{{\mathbb {E}}}_{t}[v_{t+1,m}(p_{t+1},n_{t+1},m_{t+1})]\).

  10. See Druedahl and Jørgensen (2017) for additional details.

  11. A slight further speed-up is possible by using that the interpolations in lines 12–13 in Algorithm 5 is for the same vector of next-period states. Lines 1–9 of Algorithm 4 can therefore be skipped when calling the interpolation algorithm for the second time in line 13 of Algorithm 5.

  12. The value for \({\overline{x}}={\overline{m}}+{\overline{n}}\) ensures that the grid is wide enough for comparing the adjust and keep cases. The value for \({\overline{a}}<{\overline{x}}\) is chosen somewhat lower because the household will always choose to consume some it’s resources.

  13. Comparing various approaches to parallelization on CPUs Fernandez-Villaverde and Valencia (2018) found C++ with either OpenMP or MPI to be the fastest.

  14. If \({\mathcal {T}}_{m}\) is not differentiable everywhere in \(a_{t}\) there will be multiple Euler-equations. If there are k kinks where \({\mathcal {T}}_{m}\) is not differentiable in \(a_{t}\), there will be \(k+1\) intervals where \({\mathcal {T}}_{m}\) is differentiable in \(a_{t}\). Consequently there will be \(k+1\) mutually exclusive Euler-equations. Interior optimal consumption choices not at kinks must still satisfy one of these, and the proposed NEGM can therefore still be applied.

  15. If \({\mathcal {T}}_{n}\) is continuous and differentiable wrt. to \(a_{t}\) it will still be possible to derive an equation like the standard Euler-equation. The fast vectorized interpolation scheme can, however, not be straightforwardly used as changes in \(a_{t}\) then affect both \(m_{t+1}\) and \(n_{t+1}\).

  16. A serial implementation is used because the two dimensional upper envelope of \({\hbox {G}}^{2}\)EGM is not straightforward to parallellize in Python when there is no exogenous states.

References

  • Barillas, F., & Fernández-Villaverde, J. (2007). A generalization of the endogenous grid method. Journal of Economic Dynamics and Control, 31(8), 2698–2712.

    Article  Google Scholar 

  • Berger, D., & Vavra, J. (2015). Consumption dynamics during recessions. Econometrica, 83(1), 101–154.

    Article  Google Scholar 

  • Bertsekas, D. P. (2012) Dynamic programming and optimal control: Approximate dynamic programming. Athena Scientific

  • Carroll, C. D. (2006). The method of endogenous gridpoints for solving dynamic stochastic optimization problems. Economics Letters, 91(3), 312–320.

    Article  Google Scholar 

  • Druedahl, J., & Jørgensen, T. H. (2017). A general endogenous grid method for multi-dimensional models with non-convexities and constraints. Journal of Economic Dynamics and Control, 74, 87–107.

    Article  Google Scholar 

  • Fella, G. (2014). A generalized endogenous grid method for non-smooth and non-concave problems. Review of Economic Dynamics, 17(2), 329–344.

    Article  Google Scholar 

  • Fernandez-Villaverde, J., & Valencia, D. Z. (2018). A practical guide to parallization in economics. Technical report.

  • Harmenberg, K., & Oberg, E. (2017). Consumption dynamics under time-varying unemployment risk. Working Paper.

  • Hintermaier, T., & Koeniger, W. (2010). The method of endogenous gridpoints with occasionally binding constraints among endogenous variables. Journal of Economic Dynamics and Control, 34(10), 2074–2088.

    Article  Google Scholar 

  • Hull, I. (2015). Approximate dynamic programming with post-decision states as a solution method for dynamic economic models. Journal of Economic Dynamics and Control, 55, 57–70.

    Article  Google Scholar 

  • 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. Quantitative Economics, 8(2), 317–365.

    Article  Google Scholar 

  • Johnson, S. G. (2014). The NLopt nonlinear-optimization package

  • Jørgensen, T. H. (2013). Structural estimation of continuous choice models: Evaluating the EGM and MPEC. Economics Letters, 119(3), 287–290.

    Article  Google Scholar 

  • Judd, K. L. (1992). Projection methods for solving aggregate growth models. Journal of Economic Theory, 58(2), 410–452.

    Article  Google Scholar 

  • Judd, K. L., Maliar, L., & Maliar, S. (2017). How to solve dynamic stochastic models computing expectations just once. Quantitative Economics, 8(3), 851–893.

    Article  Google Scholar 

  • Low, H., & Meghir, C. (2017). The use of structural models in econometrics. Journal of Economic Perspectives, 31(2), 33–58.

    Article  Google Scholar 

  • Ludwig, A., & Schön, M. (2018). Endogenous grids in higher dimensions: Delaunay interpolation and hybrid methods. Computational Economics, 51, 1–30.

    Article  Google Scholar 

  • Ma, Q., & Stachurski, J. (2018). Dynamic programming deconstructed. Technical report.

  • Powell, W. B. (2011). Approximate dynamic programming: Solving the curses of dimensionality. New York: Wiley.

    Book  Google Scholar 

  • Rendahl, P. (2015). Inequality constraints and Euler equation-based solution methods. The Economic Journal, 125(585), 1110–1135.

    Article  Google Scholar 

  • Santos, M. S. (2000). Accuracy of numerical solutions using the Euler equation residuals. Econometrica, 68(6), 1377–1402.

    Article  Google Scholar 

  • Svanberg, K. (2002). A class of globally convergent optimization methods based on conservative convex separable approximations. SIAM Journal on Optimization, 12(2), 555–573.

    Article  Google Scholar 

  • Van Roy, B., Bertsekas, D.P., Lee, Y., & Tsitsiklis, J.N. (1997). A neuro-dynamic programming approach to retailer inventory management. In Decision and control, 1997., Proceedings of the 36th IEEE conference on (Vol. 4, pp. 4052–4057). IEEE.

  • White, M. N. (2015). The method of endogenous gridpoints in theory and practice. Journal of Economic Dynamics and Control, 60, 26–41.

    Article  Google Scholar 

Download references

Acknowledgements

I thank Anders Munk-Nielsen, Bertel Schjerning, Alessandro Martinello, Giulio Fella, Matthew White and especially Thomas Høgholm Jørgensen for fruitful discussions and suggestions. The usual disclaimer applies. An earlier version of this paper has been circulated under the title “A fast nested endogenous grid method for solving general consumption-saving models”. Financial support from the Danish Council for Independent Research in Social Sciences (Grant No. 5052-00086) is gratefully acknowledged.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jeppe Druedahl.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendix: Model in Sect. 3.1

Appendix: Model in Sect. 3.1

1.1 Bellman Equation

Defining the vector of state variables by \(s_{t}=(p_{t},n_{t}^{1},n_{t}^{2},m_{t})\). The recursive Bellman equation for the extended benchmark model with two durable stocks can be written

$$\begin{aligned} v_{t}(s_{t})= & {} \max \left\{ \begin{array}{c} v_{t}^{keep}(p_{t},n_{t}^{1},n_{t}^{2},m_{t})\\ v_{t}^{adj.}(p_{t},x_{t})\\ v_{t}^{adj.,1}(p_{t},n_{t}^{2},x_{t}^{1})\\ v_{t}^{adj.,2}(p_{t},n_{t}^{2},x_{t}^{2}) \end{array}\right\} \nonumber \\&{\text {s.t.}}\nonumber \\ x_{t}= & {} m_{t}+(1-\tau _{1})n_{t}^{1}+(1-\tau _{2})n_{t}^{2}\nonumber \\ x_{t}^{1}= & {} m_{t}+(1-\tau _{1})n_{t}^{1},\nonumber \\ x_{t}^{2}= & {} m_{t}+(1-\tau _{2})n_{t}^{2}, \end{aligned}$$
(6.1)

where

$$\begin{aligned} v_{t}^{keep}(p_{t},n_{t}^{1},n_{t}^{2},m_{t})= & {} \max _{c_{t}}u(c_{t},n_{t}^{1},n_{t}^{2})+\beta {{\mathbb {E}}}_{t}[v_{t+1}(s_{t+1})]\nonumber \\&{\text {s.t.}}\nonumber \\ a_{t}= & {} m_{t}-c_{t}\nonumber \\ m_{t+1}= & {} (1+r)a_{t}+y_{t+1}\nonumber \\ n_{t+1}^{1}= & {} (1-\delta _{1})n_{t}^{1}\nonumber \\ n_{t+1}^{2}= & {} (1-\delta _{2})n_{t}^{2}\nonumber \\ a_{t}\ge & {} 0, \end{aligned}$$
(6.2)

and

$$\begin{aligned} v_{t}^{adj.}(p_{t},x_{t})= & {} \max _{c_{t},d_{t}^{1},d_{t}^{2}}u(c_{t},d_{t}^{1},n_{t}^{2})+\beta {{\mathbb {E}}}_{t}[v_{t+1}(s_{t+1})]\nonumber \\&{\text {s.t.}}\nonumber \\ a_{t}= & {} x_{t}-c_{t}-d_{t}^{1}-d_{t}^{2}\nonumber \\ m_{t+1}= & {} (1+r)a_{t}+y_{t+1}\nonumber \\ n_{t+1}^{1}= & {} (1-\delta _{1})d_{t}^{1}\nonumber \\ n_{t+1}^{2}= & {} (1-\delta _{2})d_{t}^{2}\nonumber \\ a_{t}\ge & {} 0, \end{aligned}$$
(6.3)

and

$$\begin{aligned} v_{t}^{adj.,1}(p_{t},n_{1}^{2},x_{t}^{1})= & {} \max _{c_{t},d_{t}^{1}}u(c_{t},d_{t}^{1},n_{t}^{2})+\beta {{\mathbb {E}}}_{t}[v_{t+1}(s_{t+1})]\nonumber \\&{\text {s.t.}}\nonumber \\ a_{t}= & {} x_{t}^{1}-c_{t}-d_{t}^{1}\nonumber \\ m_{t+1}= & {} (1+r)a_{t}+y_{t+1}\nonumber \\ n_{t+1}^{1}= & {} (1-\delta _{1})d_{t}^{1}\nonumber \\ n_{t+1}^{2}= & {} (1-\delta _{2})n_{t}^{2}\nonumber \\ a_{t}\ge & {} 0, \end{aligned}$$
(6.4)

and

$$\begin{aligned} v_{t}^{adj.,2}(p_{t},n_{1}^{1},x_{t}^{2})= & {} \max _{c_{t},d_{t}^{2}}u(c_{t},n_{t}^{1},d_{t}^{2})+\beta {{\mathbb {E}}}_{t}[v_{t+1}(s_{t+1})]\nonumber \\&{\text {s.t.}}\nonumber \\ a_{t}= & {} x_{t}^{2}-c_{t}-d_{t}^{2}\nonumber \\ m_{t+1}= & {} (1+r)a_{t}+y_{t+1}\nonumber \\ n_{t+1}^{1}= & {} (1-\delta _{1})n_{t}^{1}\nonumber \\ n_{t+1}^{2}= & {} (1-\delta _{2})d_{t}^{2}\nonumber \\ a_{t}\ge & {} 0. \end{aligned}$$
(6.5)

1.2 Nesting

Defining the post-decision value function

$$\begin{aligned} w_{t}(p_{t},d_{t}^{1},d_{t}^{2},a_{t})=\beta {{\mathbb {E}}}_{t}[v_{t+1}(p_{t+1},n_{t+1}^{1},n_{t+1}^{1},m_{t+1})], \end{aligned}$$

the keeper and adjuster value functions can be re-formulated as

$$\begin{aligned} v_{t}^{keep}(p_{t},n_{t}^{1},n_{t}^{2},m_{t})= & {} \max _{c_{t}}u(c_{t},n_{t}^{1},n_{t}^{2})+w_{t}(p_{t},d_{t}^{1},d_{t}^{2},a_{t})\nonumber \\&{\text {s.t.}}\nonumber \\ a_{t}= & {} m_{t}-c_{t}\nonumber \\ m_{t+1}= & {} (1+r)a_{t}+y_{t+1}\nonumber \\ n_{t+1}^{1}= & {} (1-\delta _{1})n_{t}^{1}\nonumber \\ n_{t+1}^{2}= & {} (1-\delta _{1})n_{t}^{2}\nonumber \\ a_{t}\ge & {} 0, \end{aligned}$$
(6.6)

and

$$\begin{aligned} v_{t}^{adj.}(p_{t},x_{t})= & {} \max _{d_{t}^{1},d_{t}^{2}}v_{t}^{keep}(p_{t},d_{t}^{1},d_{t}^{2},m_{t})\nonumber \\&{\text {s.t.}}\nonumber \\ m_{t}= & {} x_{t}-d_{t}^{1}-d_{t}^{2}\nonumber \\ d_{t}^{1}+d_{t}^{2}\in & {} [0,x_{t}], \end{aligned}$$
(6.7)

and

$$\begin{aligned} v_{t}^{adj.,1}(p_{t},n_{1}^{2},x_{t}^{1})= & {} \max _{d_{t}^{1},}v_{t}^{keep}(p_{t},d_{t}^{1},n_{t}^{2},m_{t})\nonumber \\&{\text {s.t.}}\nonumber \\ m_{t}= & {} x_{t}^{1}-m_{t}-d_{t}^{1}\nonumber \\ d_{t}^{1}\in & {} [0,x_{t}^{1}], \end{aligned}$$
(6.8)

and

$$\begin{aligned} v_{t}^{adj.,2}(p_{t},n_{1}^{1},x_{t}^{2})= & {} \max _{d_{t}^{2}}v_{t}^{keep}(p_{t},n_{t}^{1},d_{t}^{2},m_{t})\nonumber \\&{\text {s.t.}}\nonumber \\ m_{t}= & {} x_{t}^{2}-d_{t}^{2}\nonumber \\ d_{t}^{2}\in & {} [0,x_{t}^{2}]. \end{aligned}$$
(6.9)

1.3 EGM

Define the post-decision marginal value of cash by

$$\begin{aligned} q(p_{t},d_{t},a_{t}) =\beta R{{\mathbb {E}}}_{t}\left[ \alpha c_{t+1}^{\alpha (1-\rho )-1}((d_{t+1}^{1}+\underline{d}^{1})^{\gamma }(d_{t+1}^{2}+\underline{d}^{2})^{1-\gamma })^{(1-\alpha )(1-\rho )}\right] . \end{aligned}$$
(6.10)

The Euler-equation for \(c_{t}\) is then given by

$$\begin{aligned} u_{c}(c_{t},d_{t}^{1},d_{t}^{2})=q(p_{t},d_{t}^{1},d_{t}^{2},a_{t}). \end{aligned}$$
(6.11)

This implies that EGM can be performed as follows

$$\begin{aligned} c_{t} =z(a_{t},d_{t}^{1},d_{t}^{2},p_{t}) \end{aligned}$$
(6.12)
$$\begin{aligned}&=\left( \frac{q_{t}(p_{t},d_{t},a_{t})}{\alpha ((d_{t}^{1}+\underline{d}_{1})^{\gamma }(d_{t}^{2}+\underline{d}_{2})^{1-\gamma })^{(1-\alpha )(1-\rho )}}\right) ^{\frac{1}{\alpha (1-\rho )-1}}\nonumber \\ m_{t}&=a_{t}+c_{t}. \end{aligned}$$
(6.13)

The upper envelope algorithm is unchanged.

1.4 Implementation

Parametrization The chosen parameters are \(\beta =0.965\), \(\rho =2\), \(\alpha =0.9\) \(\underline{d}_{1}=\underline{d}_{2}=10^{-2}\), \(R=1.03\), \(\tau _{1}=0.08\), \(\tau _{1}=0.12\), \(\delta _{1}=0.10\), \(\delta _{2}=0.20\), \(\gamma =0.5\), \(\sigma _{\psi }=\sigma _{\xi }=0.1\), and \(\lambda =1\).

Grids Constructed as in the benchmark model, but with the following changes \(\#_{p}=50\), \({\overline{n}}=2\), \(\#_{n}=50\), \({\overline{m}}=10\), \(\#_{m}=100,\) \({\overline{x}}=12\), \(\#_{x}=100\), \(\#_{a}=100\).

Interpolation Done as in the benchmark model.

Simulation The initial values in the simulation are drawn as:

$$\begin{aligned} \log p_{0}&\sim {\mathcal {N}}(\log (1),0.2)\\ \log d_{0}^{1}&\sim {\mathcal {N}}(\log (0.4),0.2)\\ \log d_{0}^{1}&\sim {\mathcal {N}}(\log (0.4),0.2)\\ \log a_{0}&\sim {\mathcal {N}}(\log (0.2),0.1). \end{aligned}$$

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Druedahl, J. A Guide on Solving Non-convex Consumption-Saving Models. Comput Econ 58, 747–775 (2021). https://doi.org/10.1007/s10614-020-10045-x

Download citation

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10614-020-10045-x

Keywords

JEL Classification

Navigation