@@ -30,14 +30,15 @@ progressively more challenging---and useful---problems.
30303131The main tool we will use to solve the cake eating problem is dynamic programming.
323233-Readers might find it helpful to review the following lectures before reading this one:
33+The following lectures contain background on dynamic programming and might be
34+worth reviewing:
34353536* The {doc}`shortest paths lecture <intro:short_path>`
3637* The {doc}`basic McCall model <mccall_model>`
3738* The {doc}`McCall model with separation <mccall_model_with_separation>`
3839* The {doc}`McCall model with separation and a continuous wage distribution <mccall_fitted_vfi>`
394040-In what follows, we require the following imports:
41+We require the following imports:
41424243```{code-cell} ipython
4344import matplotlib.pyplot as plt
@@ -46,7 +47,7 @@ import numpy as np
46474748## The model
484949-We consider an infinite time horizon $t=0, 1, 2, 3..$
50+We consider a discrete time model with an infinite time horizon.
50515152At $t=0$ the agent is given a complete cake with size $\bar x$.
5253@@ -55,13 +56,12 @@ so that, in particular, $x_0=\bar x$.
55565657We choose how much of the cake to eat in any given period $t$.
575858-After choosing to consume $c_t$ of the cake in period $t$ there is
59+After choosing to consume $c_t$ of the cake in period $t$, the amount left in period $t+1$ is
59606061$$
61-x_{t+1} = x_t - c_t
62+ x_{t+1} = x_t - c_t
6263$$
636464-left in period $t+1$.
65656666Consuming quantity $c$ of the cake gives current utility $u(c)$.
6767@@ -98,15 +98,14 @@ subject to
9898```{math}
9999:label: cake_feasible
100100101-x_{t+1} = x_t - c_t
102-\quad \text{and} \quad
103-0\leq c_t\leq x_t
101+ x_{t+1} = x_t - c_t
102+ \quad \text{and} \quad
103+ 0\leq c_t\leq x_t
104104```
105105106106for all $t$.
107107108-A consumption path $\{c_t\}$ satisfying {eq}`cake_feasible` where
109-$x_0 = \bar x$ is called **feasible**.
108+A consumption path $\{c_t\}$ satisfying {eq}`cake_feasible` where $x_0 = \bar x$ is called **feasible**.
110109111110In this problem, the following terminology is standard:
112111@@ -122,7 +121,7 @@ The key trade-off in the cake-eating problem is this:
122121* But delaying some consumption is also attractive because $u$ is concave.
123122124123The concavity of $u$ implies that the consumer gains value from
125-*consumption smoothing*, which means spreading consumption out over time.
124+**consumption smoothing**, which means spreading consumption out over time.
126125127126This is because concavity implies diminishing marginal utility---a progressively smaller gain in utility for each additional spoonful of cake consumed within one period.
128127@@ -132,18 +131,16 @@ The reasoning given above suggests that the discount factor $\beta$ and the curv
132131133132Here's an educated guess as to what impact these parameters will have.
134133135-First, higher $\beta$ implies less discounting, and hence the agent is more patient, which should reduce the rate of consumption.
136-137-Second, higher $\gamma$ implies that marginal utility $u'(c) =
138-c^{-\gamma}$ falls faster with $c$.
134+1. Higher $\beta$ implies less discounting, and hence the agent is more patient, which should reduce the rate of consumption.
135+2. Higher $\gamma$ implies that marginal utility $u'(c) = c^{-\gamma}$ falls faster with $c$.
139136140137This suggests more smoothing, and hence a lower rate of consumption.
141138142-In summary, we expect the rate of consumption to be *decreasing in both
143-parameters*.
139+In summary, we expect the rate of consumption to be decreasing in both parameters.
144140145141Let's see if this is true.
146142143+147144## The value function
148145149146The first step of our dynamic programming treatment is to obtain the Bellman
@@ -182,7 +179,7 @@ v(x) = \max_{0\leq c \leq x} \{u(c) + \beta v(x-c)\}
182179\quad \text{for any given } x \geq 0.
183180```
184181185-The intuition here is essentially the same it was for the McCall model.
182+The intuition here is essentially the same as it was for the McCall model.
186183187184Choosing $c$ optimally means trading off current vs future rewards.
188185@@ -198,31 +195,34 @@ If $c$ is chosen optimally using this trade off strategy, then we obtain maximal
198195199196Hence, $v(x)$ equals the right hand side of {eq}`bellman-cep`, as claimed.
200197198+199+201200### An analytical solution
202201203-It has been shown that, with $u$ as the CRRA utility function in
204-{eq}`crra_utility`, the function
202+It has been shown that, with $u$ as the CRRA utility function in {eq}`crra_utility`, the function
203+$v^*$ given by
205204206205```{math}
207206:label: crra_vstar
208207209-v^*(x_t) = \left( 1-\beta^{1/\gamma} \right)^{-\gamma}u(x_t)
208+ v^*(x) = \left( 1-\beta^{1/\gamma} \right)^{-\gamma}u(x)
210209```
211210212211solves the Bellman equation and hence is equal to the value function.
213212214213You are asked to confirm that this is true in the exercises below.
215214215+```{note}
216216The solution {eq}`crra_vstar` depends heavily on the CRRA utility function.
217217218-In fact, if we move away from CRRA utility, usually there is no analytical
219-solution at all.
218+In fact, if we move away from CRRA utility, usually there is no analytical solution at all.
220219221220In other words, beyond CRRA utility, we know that the value function still
222221satisfies the Bellman equation, but we do not have a way of writing it
223222explicitly, as a function of the state variable and the parameters.
224223225-We will deal with that situation numerically when the time comes.
224+We will deal with that situation numerically in the following lectures.
225+```
226226227227Here is a Python representation of the value function:
228228@@ -248,26 +248,24 @@ ax.legend(fontsize=12)
248248plt.show()
249249```
250250251+251252## The optimal policy
252253253-Now that we have the value function, it is straightforward to calculate the
254-optimal action at each state.
254+Now that we have the value function, it is straightforward to calculate the optimal action at each state.
255255256-We should choose consumption to maximize the
257-right hand side of the Bellman equation {eq}`bellman-cep`.
256+We should choose consumption to maximize the right hand side of the Bellman equation {eq}`bellman-cep`.
258257259258$$
260-c^* = \arg \max_{c} \{u(c) + \beta v(x - c)\}
259+ c^* = \arg \max_{c} \{u(c) + \beta v(x - c)\}
261260$$
262261263-We can think of this optimal choice as a function of the state $x$, in
264-which case we call it the **optimal policy**.
262+We can think of this optimal choice as a function of the state $x$, in which case we call it the **optimal policy**.
265263266264We denote the optimal policy by $\sigma^*$, so that
267265268266$$
269-\sigma^*(x) := \arg \max_{c} \{u(c) + \beta v(x - c)\}
270-\quad \text{for all } x
267+ \sigma^*(x) := \arg \max_{c} \{u(c) + \beta v(x - c)\}
268+ \quad \text{for all } x
271269$$
272270273271If we plug the analytical expression {eq}`crra_vstar` for the value function
@@ -276,16 +274,16 @@ into the right hand side and compute the optimum, we find that
276274```{math}
277275:label: crra_opt_pol
278276279-\sigma^*(x) = \left( 1-\beta^{1/\gamma} \right) x
277+ \sigma^*(x) = \left( 1-\beta^{1/\gamma} \right) x
280278```
281279282280Now let's recall our intuition on the impact of parameters.
283281284-We guessed that the consumption rate would be decreasing in both parameters.
282+We guessed that consumption would be decreasing in both parameters.
285283286284This is in fact the case, as can be seen from {eq}`crra_opt_pol`.
287285288-Here's some plots that illustrate.
286+Here are some plots that illustrate.
289287290288```{code-cell} python3
291289def c_star(x, β, γ):
@@ -332,7 +330,7 @@ The Euler equation for the present problem can be stated as
332330u^{\prime} (c^*_{t})=\beta u^{\prime}(c^*_{t+1})
333331```
334332335-This is necessary condition for the optimal path.
333+This is a necessary condition for the optimal path.
336334337335It says that, along the optimal path, marginal rewards are equalized across time, after appropriate discounting.
338336@@ -447,6 +445,11 @@ This is just the Euler equation.
447445448446Another way to derive the Euler equation is to use the Bellman equation {eq}`bellman-cep`.
449447448+```{note}
449+The argument that follows assumes that the value function is differentiable.
450+A proof of differentiability of the value function can be found in [EDTC](https://johnstachurski.net/edtc.html), theorem 10.1.13.
451+```
452+450453Taking the derivative on the right hand side of the Bellman equation with
451454respect to $c$ and setting it to zero, we get
452455@@ -611,3 +614,66 @@ $$
611614612615Our claims are now verified.
613616```
617+618+```{exercise}
619+:label: cep_ex2
620+621+Verify that the optimal policy {eq}`crra_opt_pol` satisfies the Euler equation {eq}`euler_pol`.
622+```
623+624+```{solution} cep_ex2
625+:class: dropdown
626+627+Recall that the optimal policy is
628+629+$$
630+ \sigma^*(x) = (1 - \beta^{1/\gamma})x
631+$$
632+633+and the Euler equation in policy form is
634+635+$$
636+ u'(\sigma(x)) = \beta u'(\sigma(x - \sigma(x)))
637+$$
638+639+With CRRA utility $u(c) = \frac{c^{1-\gamma}}{1-\gamma}$, the marginal utility is
640+641+$$
642+ u'(c) = c^{-\gamma}
643+$$
644+645+Now let's verify the Euler equation. The left-hand side is
646+647+$$
648+ u'(\sigma^*(x))
649+ = [\sigma^*(x)]^{-\gamma}
650+ = [(1 - \beta^{1/\gamma})x]^{-\gamma}
651+ = (1 - \beta^{1/\gamma})^{-\gamma} x^{-\gamma}
652+$$
653+654+For the right-hand side, we first compute the state in the next period:
655+656+$$
657+ x - \sigma^*(x) = x - (1 - \beta^{1/\gamma})x = x\beta^{1/\gamma}
658+$$
659+660+Next period's consumption under the optimal policy is
661+662+$$
663+ \sigma^*(x - \sigma^*(x)) = \sigma^*(x\beta^{1/\gamma}) = (1 - \beta^{1/\gamma}) \cdot x\beta^{1/\gamma}
664+$$
665+666+Therefore, the right-hand side of the Euler equation is
667+668+$$
669+\begin{aligned}
670+\beta u'(\sigma^*(x - \sigma^*(x)))
671+ &= \beta [(1 - \beta^{1/\gamma}) \cdot x\beta^{1/\gamma}]^{-\gamma} \\
672+ &= \beta (1 - \beta^{1/\gamma})^{-\gamma} x^{-\gamma} (\beta^{1/\gamma})^{-\gamma} \\
673+ &= \beta (1 - \beta^{1/\gamma})^{-\gamma} x^{-\gamma} \beta^{-1} \\
674+ &= (1 - \beta^{1/\gamma})^{-\gamma} x^{-\gamma}
675+\end{aligned}
676+$$
677+678+Since the left-hand side equals the right-hand side, the optimal policy $\sigma^*$ satisfies the Euler equation.
679+```