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++.
Similar content being viewed by others
Notes
The code is available at github.com/NumEconCopenhagen/ConsumptionSavingNotebooks. The Python code is optimized with just-in-time compilation from the Numba package.
See Hull (2015) for some extensions and an application in economics.
An alternative would be time iteration, see Rendahl (2015).
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.
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\).
See the detailed discussion in Ludwig and Schön (2018) regarding triangulazation and Delaunay interpolation.
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})]\).
See Druedahl and Jørgensen (2017) for additional details.
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.
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.
Comparing various approaches to parallelization on CPUs Fernandez-Villaverde and Valencia (2018) found C++ with either OpenMP or MPI to be the fastest.
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.
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}\).
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.
Berger, D., & Vavra, J. (2015). Consumption dynamics during recessions. Econometrica, 83(1), 101–154.
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.
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.
Fella, G. (2014). A generalized endogenous grid method for non-smooth and non-concave problems. Review of Economic Dynamics, 17(2), 329–344.
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.
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.
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.
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.
Judd, K. L. (1992). Projection methods for solving aggregate growth models. Journal of Economic Theory, 58(2), 410–452.
Judd, K. L., Maliar, L., & Maliar, S. (2017). How to solve dynamic stochastic models computing expectations just once. Quantitative Economics, 8(3), 851–893.
Low, H., & Meghir, C. (2017). The use of structural models in econometrics. Journal of Economic Perspectives, 31(2), 33–58.
Ludwig, A., & Schön, M. (2018). Endogenous grids in higher dimensions: Delaunay interpolation and hybrid methods. Computational Economics, 51, 1–30.
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.
Rendahl, P. (2015). Inequality constraints and Euler equation-based solution methods. The Economic Journal, 125(585), 1110–1135.
Santos, M. S. (2000). Accuracy of numerical solutions using the Euler equation residuals. Econometrica, 68(6), 1377–1402.
Svanberg, K. (2002). A class of globally convergent optimization methods based on conservative convex separable approximations. SIAM Journal on Optimization, 12(2), 555–573.
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.
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
Corresponding author
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
where
and
and
and
1.2 Nesting
Defining the post-decision value function
the keeper and adjuster value functions can be re-formulated as
and
and
and
1.3 EGM
Define the post-decision marginal value of cash by
The Euler-equation for \(c_{t}\) is then given by
This implies that EGM can be performed as follows
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:
Rights and permissions
About this article
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
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10614-020-10045-x
Keywords
- Endogenous grid method
- Post-decision states
- Stochastic dynamic programming
- Continuous and discrete choices
- Occasionally binding constraints