Skip to content

Commit 083a4f3

Browse files
jstacclaude
andcommitted
Reorganize and rename optimal savings lectures
This commit restructures the cake eating lecture series into a more coherent "Introduction to Optimal Savings" section with clearer naming and terminology. Changes: - Created new "Introduction to Optimal Savings" section in table of contents - Renamed all 6 lectures with "os" prefix for consistency: * cake_eating.md → os.md (Optimal Savings I: Cake Eating) * cake_eating_numerical.md → os_numerical.md (Optimal Savings II: Numerical Cake Eating) * cake_eating_stochastic.md → os_stochastic.md (Optimal Savings III: Stochastic Returns) * cake_eating_time_iter.md → os_time_iter.md (Optimal Savings IV: Time Iteration) * cake_eating_egm.md → os_egm.md (Optimal Savings V: The Endogenous Grid Method) * cake_eating_egm_jax.md → os_egm_jax.md (Optimal Savings VI: EGM with JAX) - Updated all lecture titles to use "Optimal Savings I-VI" naming convention - Replaced "cake eating" terminology with "optimal savings" throughout all lectures - Updated terminology in os_stochastic.md: "cake" → "wealth/harvest" to better reflect stochastic growth - Updated all cross-references across the codebase to use new filenames - Made cross-references robust to future title changes by using {doc}`filename` format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2afed31 commit 083a4f3

File tree

11 files changed

+64
-75
lines changed

11 files changed

+64
-75
lines changed

lectures/_toc.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,18 @@ parts:
7272
- file: jv
7373
- file: odu
7474
- file: mccall_q
75+
- caption: Introduction to Optimal Savings
76+
numbered: true
77+
chapters:
78+
- file: os
79+
- file: os_numerical
80+
- file: os_stochastic
81+
- file: os_time_iter
82+
- file: os_egm
83+
- file: os_egm_jax
7584
- caption: Household Problems
7685
numbered: true
7786
chapters:
78-
- file: cake_eating
79-
- file: cake_eating_numerical
80-
- file: cake_eating_stochastic
81-
- file: cake_eating_time_iter
82-
- file: cake_eating_egm
83-
- file: cake_eating_egm_jax
8487
- file: ifp
8588
- file: ifp_advanced
8689
- caption: LQ Control

lectures/ifp.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ It is an essential sub-problem for many representative macroeconomic models
4545
* {cite}`Huggett1993`
4646
* etc.
4747

48-
It is related to the decision problem in the {doc}`cake eating model <cake_eating_stochastic>` but differs in significant ways.
48+
It is related to the decision problem in {doc}`os_stochastic` but differs in significant ways.
4949

5050
For example,
5151

5252
1. The choice problem for the agent includes an additive income term that leads to an occasionally binding constraint.
5353
2. Shocks affecting the budget constraint are correlated, forcing us to track an extra state variable.
5454

55-
To solve the model we will use the endogenous grid method, which we found to be {doc}`fast and accurate <cake_eating_egm_jax>` in our investigation of cake eating.
55+
To solve the model we will use the endogenous grid method, which we found to be fast and accurate in {doc}`os_egm_jax`.
5656

5757
We'll need the following imports:
5858

@@ -256,7 +256,7 @@ We solve for the optimal consumption policy using time iteration and the
256256
endogenous grid method.
257257

258258
Readers unfamiliar with the endogenous grid method should review the discussion
259-
in {doc}`cake_eating_egm`.
259+
in {doc}`os_egm`.
260260

261261
### Solution Method
262262

lectures/ifp_advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ convergence (as measured by the distance $\rho$).
251251
### Using an Endogenous Grid
252252

253253
In the study of that model we found that it was possible to further
254-
accelerate time iteration via the {doc}`endogenous grid method <cake_eating_egm>`.
254+
accelerate time iteration via the {doc}`endogenous grid method <os_egm>`.
255255

256256
We will use the same method here.
257257

lectures/lqcontrol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ In reading what follows, it will be useful to have some familiarity with
5757

5858
* matrix manipulations
5959
* vectors of random variables
60-
* dynamic programming and the Bellman equation (see for example {doc}`this lecture <intro:short_path>` and {doc}`this lecture <cake_eating_stochastic>`)
60+
* dynamic programming and the Bellman equation (see for example {doc}`this lecture <intro:short_path>` and {doc}`os_stochastic`)
6161

6262
For additional reading on LQ control, see, for example,
6363

lectures/cake_eating.md renamed to lectures/os.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ kernelspec:
99
name: python3
1010
---
1111

12-
# Cake Eating I: Introduction to Optimal Saving
12+
# Optimal Savings I: Cake Eating
1313

1414
```{contents} Contents
1515
:depth: 2

lectures/cake_eating_egm.md renamed to lectures/os_egm.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ kernelspec:
1717
</div>
1818
```
1919

20-
# {index}`Cake Eating V: The Endogenous Grid Method <single: Cake Eating V: The Endogenous Grid Method>`
20+
# {index}`Optimal Savings V: The Endogenous Grid Method <single: Optimal Savings V: The Endogenous Grid Method>`
2121

2222
```{contents} Contents
2323
:depth: 2
@@ -26,10 +26,10 @@ kernelspec:
2626

2727
## Overview
2828

29-
Previously, we solved the stochastic cake eating problem using
29+
Previously, we solved the optimal savings problem using
3030

31-
1. {doc}`value function iteration <cake_eating_stochastic>`
32-
1. {doc}`Euler equation based time iteration <cake_eating_time_iter>`
31+
1. {doc}`value function iteration <os_stochastic>`
32+
1. {doc}`Euler equation based time iteration <os_time_iter>`
3333

3434
We found time iteration to be significantly more accurate and efficient.
3535

@@ -42,7 +42,7 @@ The original reference is {cite}`Carroll2006`.
4242
For now we will focus on a clean and simple implementation of EGM that stays
4343
close to the underlying mathematics.
4444

45-
Then, in {doc}`the next lecture <cake_eating_egm_jax>`, we will construct a fully vectorized and parallelized version of EGM based on JAX.
45+
Then, in {doc}`os_egm_jax`, we will construct a fully vectorized and parallelized version of EGM based on JAX.
4646

4747
Let's start with some standard imports:
4848

@@ -58,7 +58,7 @@ First we remind ourselves of the theory and then we turn to numerical methods.
5858

5959
### Theory
6060

61-
We work with the model set out in {doc}`cake_eating_time_iter`, following the same terminology and notation.
61+
We work with the model set out in {doc}`os_time_iter`, following the same terminology and notation.
6262

6363
The Euler equation is
6464

@@ -84,15 +84,15 @@ u'(c)
8484

8585
### Exogenous Grid
8686

87-
As discussed in {doc}`cake_eating_time_iter`, to implement the method on a
87+
As discussed in {doc}`os_time_iter`, to implement the method on a
8888
computer, we need numerical approximation.
8989

9090
In particular, we represent a policy function by a set of values on a finite grid.
9191

9292
The function itself is reconstructed from this representation when necessary,
9393
using interpolation or some other method.
9494

95-
Our {doc}`previous strategy <cake_eating_time_iter>` for obtaining a finite representation of an updated consumption policy was to
95+
Our previous strategy in {doc}`os_time_iter` for obtaining a finite representation of an updated consumption policy was to
9696

9797
* fix a grid of income points $\{x_i\}$
9898
* calculate the consumption value $c_i$ corresponding to each $x_i$ using
@@ -146,7 +146,7 @@ The name EGM comes from the fact that the grid $\{x_i\}$ is determined **endogen
146146

147147
## Implementation
148148

149-
As in {doc}`cake_eating_time_iter`, we will start with a simple setting where
149+
As in {doc}`os_time_iter`, we will start with a simple setting where
150150

151151
* $u(c) = \ln c$,
152152
* the function $f$ has a Cobb-Douglas specification, and
@@ -172,7 +172,7 @@ def σ_star(x, α, β):
172172
return (1 - α * β) * x
173173
```
174174

175-
We reuse the `Model` structure from {doc}`cake_eating_time_iter`.
175+
We reuse the `Model` structure from {doc}`os_time_iter`.
176176

177177
```{code-cell} python3
178178
from typing import NamedTuple, Callable
@@ -205,7 +205,7 @@ def create_model(u: Callable,
205205
f_prime: Callable = None,
206206
u_prime_inv: Callable = None) -> Model:
207207
"""
208-
Creates an instance of the cake eating model.
208+
Creates an instance of the optimal savings model.
209209
"""
210210
# Set up exogenous savings grid
211211
s_grid = np.linspace(1e-4, grid_max, grid_size)
@@ -257,7 +257,7 @@ Note the lack of any root-finding algorithm.
257257
```{note}
258258
The routine is still not particularly fast because we are using pure Python loops.
259259
260-
But in the next lecture ({doc}`cake_eating_egm_jax`) we will use a fully vectorized and efficient solution.
260+
But in the next lecture ({doc}`os_egm_jax`) we will use a fully vectorized and efficient solution.
261261
```
262262

263263
### Testing
@@ -347,7 +347,7 @@ EGM is faster than time iteration because it avoids numerical root-finding.
347347

348348
Instead, we invert the marginal utility function directly, which is much more efficient.
349349

350-
In the {doc}`next lecture <cake_eating_egm_jax>`, we will use a fully vectorized
350+
In {doc}`os_egm_jax`, we will use a fully vectorized
351351
and efficient version of EGM that is also parallelized using JAX.
352352

353353
This provides an extremely fast way to solve the optimal consumption problem we

lectures/cake_eating_egm_jax.md renamed to lectures/os_egm_jax.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ kernelspec:
1717
</div>
1818
```
1919

20-
# {index}`Cake Eating VI: EGM with JAX <single: Cake Eating VI: EGM with JAX>`
20+
# {index}`Optimal Savings VI: EGM with JAX <single: Optimal Savings VI: EGM with JAX>`
2121

2222
```{contents} Contents
2323
:depth: 2
@@ -28,7 +28,7 @@ kernelspec:
2828

2929
In this lecture, we'll implement the endogenous grid method (EGM) using JAX.
3030

31-
This lecture builds on {doc}`cake_eating_egm`, which introduced EGM using NumPy.
31+
This lecture builds on {doc}`os_egm`, which introduced EGM using NumPy.
3232

3333
By converting to JAX, we can leverage fast linear algebra, hardware accelerators, and JIT compilation for improved performance.
3434

@@ -46,11 +46,11 @@ from typing import NamedTuple
4646

4747
## Implementation
4848

49-
For details on the savings problem and the endogenous grid method (EGM), please see {doc}`cake_eating_egm`.
49+
For details on the savings problem and the endogenous grid method (EGM), please see {doc}`os_egm`.
5050

5151
Here we focus on the JAX implementation of EGM.
5252

53-
We use the same setting as in {doc}`cake_eating_egm`:
53+
We use the same setting as in {doc}`os_egm`:
5454

5555
* $u(c) = \ln c$,
5656
* production is Cobb-Douglas, and
@@ -99,7 +99,7 @@ def create_model(β: float = 0.96,
9999
seed: int = 1234,
100100
α: float = 0.4) -> Model:
101101
"""
102-
Creates an instance of the cake eating model.
102+
Creates an instance of the optimal savings model.
103103
"""
104104
# Set up exogenous savings grid
105105
s_grid = jnp.linspace(1e-4, grid_max, grid_size)
@@ -250,7 +250,7 @@ This speed comes from:
250250
```{exercise}
251251
:label: cake_egm_jax_ex1
252252
253-
Solve the stochastic cake eating problem with CRRA utility
253+
Solve the optimal savings problem with CRRA utility
254254
255255
$$
256256
u(c) = \frac{c^{1 - \gamma} - 1}{1 - \gamma}

lectures/cake_eating_numerical.md renamed to lectures/os_numerical.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ kernelspec:
99
name: python3
1010
---
1111

12-
# Cake Eating II: Numerical Methods
12+
# Optimal Savings II: Numerical Cake Eating
1313

1414
```{contents} Contents
1515
:depth: 2
1616
```
1717

1818
## Overview
1919

20-
In this lecture we continue the study of {doc}`the cake eating problem <cake_eating>`.
20+
In this lecture we continue the study of the problem described in {doc}`os`.
2121

2222
The aim of this lecture is to solve the problem using numerical
2323
methods.
@@ -54,7 +54,7 @@ from typing import NamedTuple
5454

5555
## Reviewing the Model
5656

57-
You might like to {doc}`review the details <cake_eating>` before we start.
57+
You might like to review the details in {doc}`os` before we start.
5858

5959
Recall in particular that the Bellman equation is
6060

@@ -402,7 +402,7 @@ These ideas will be explored over the next few lectures.
402402

403403
Let's try computing the optimal policy.
404404

405-
In the {doc}`first lecture on cake eating <cake_eating>`, the optimal
405+
In {doc}`os`, the optimal
406406
consumption policy was shown to be
407407

408408
$$
@@ -477,7 +477,7 @@ However, both changes will lead to a longer compute time.
477477
Another possibility is to use an alternative algorithm, which offers the
478478
possibility of faster compute time and, at the same time, more accuracy.
479479

480-
We explore this {doc}`soon <cake_eating_time_iter>`.
480+
We explore this in {doc}`os_time_iter`.
481481

482482

483483
## Exercises

lectures/cake_eating_stochastic.md renamed to lectures/os_stochastic.md

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,25 @@ kernelspec:
1818
</div>
1919
```
2020

21-
# {index}`Cake Eating III: Stochastic Dynamics <single: Cake Eating III: Stochastic Dynamics>`
21+
# {index}`Optimal Savings III: Stochastic Returns <single: Optimal Savings III: Stochastic Returns>`
2222

2323
```{contents} Contents
2424
:depth: 2
2525
```
2626

2727
## Overview
2828

29-
In this lecture, we continue our study of the cake eating problem, building on
30-
{doc}`Cake Eating I <cake_eating>` and {doc}`Cake Eating II <cake_eating_numerical>`.
29+
In this lecture, we continue our study of optimal savings problems, building on
30+
{doc}`os` and {doc}`os_numerical`.
3131

32-
The key difference from the previous lectures is that the cake size now evolves
32+
The key difference from the previous lectures is that wealth now evolves
3333
stochastically.
3434

35-
We can think of this cake as a harvest that regrows if we save some seeds.
35+
We can think of wealth as a harvest that regrows if we save some seeds.
3636

3737
Specifically, if we save and invest part of today's harvest $x_t$, it grows into next
3838
period's harvest $x_{t+1}$ according to a stochastic production process.
3939

40-
```{note}
41-
The term "cake eating" is not such a good fit now that we have a stochastic and
42-
potentially growing state.
43-
44-
Nonetheless, we'll continue to refer to cake eating to maintain flow from the
45-
previous lectures.
46-
47-
Soon we'll move to more ambitious optimal savings/consumption problems and adopt
48-
new terminology.
49-
50-
This lecture serves as a bridge between cake eating and the more ambitious
51-
problems.
52-
```
53-
5440
The extensions in this lecture introduce several new elements:
5541

5642
* nonlinear returns to saving, through a production function, and
@@ -87,7 +73,7 @@ from typing import NamedTuple, Callable
8773

8874
## The Model
8975

90-
```{index} single: Stochastic Cake Eating; Model
76+
```{index} single: Optimal Savings; Model
9177
```
9278

9379
Here we described the new model and the optimization problem.
@@ -167,7 +153,7 @@ In the present context
167153

168154
### The Policy Function Approach
169155

170-
```{index} single: Stochastic Cake Eating; Policy Function Approach
156+
```{index} single: Optimal Savings; Policy Function Approach
171157
```
172158

173159
One way to think about solving this problem is to look for the best **policy function**.
@@ -459,7 +445,7 @@ flexibility.
459445
(In subsequent lectures we will focus on efficiency and speed.)
460446

461447
We will use fitted value function iteration, which was
462-
already described in {doc}`cake eating <cake_eating_numerical>`.
448+
already described in {doc}`os_numerical`.
463449

464450

465451
### Scalar Maximization
@@ -520,7 +506,7 @@ def create_model(u: Callable,
520506
shock_size: int = 250,
521507
seed: int = 1234) -> Model:
522508
"""
523-
Creates an instance of the cake eating model.
509+
Creates an instance of the optimal savings model.
524510
"""
525511
# Set up grid
526512
grid = np.linspace(1e-4, grid_max, grid_size)
@@ -778,7 +764,7 @@ The figure shows that we are pretty much on the money.
778764

779765
### The Policy Function
780766

781-
```{index} single: Stochastic Cake Eating; Policy Function
767+
```{index} single: Optimal Savings; Policy Function
782768
```
783769

784770
The policy `v_greedy` computed above corresponds to an approximate optimal policy.
@@ -816,7 +802,7 @@ u(c) = \frac{c^{1 - \gamma}} {1 - \gamma}
816802
$$
817803
818804
Maintaining the other defaults, including the Cobb-Douglas production
819-
function, solve the stochastic cake eating model with this
805+
function, solve the optimal savings model with this
820806
utility specification.
821807
822808
Setting $\gamma = 1.5$, compute and plot an estimate of the optimal policy.

0 commit comments

Comments
 (0)