You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lectures/ak_aiyagari.md
+54-41Lines changed: 54 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,14 @@ kernelspec:
14
14
15
15
# A Long-Lived, Heterogeneous Agent, Overlapping Generations Model
16
16
17
+
In addition to what's in Anaconda, this lecture will need the following library
18
+
19
+
```{code-cell} ipython3
20
+
:tags: [skip-execution]
21
+
22
+
!pip install jax
23
+
```
24
+
17
25
## Overview
18
26
19
27
This lecture describes an overlapping generations model with these features:
@@ -22,7 +30,7 @@ This lecture describes an overlapping generations model with these features:
22
30
- Agents live many periods as in {cite}`auerbach1987dynamic`
23
31
- Agents receive idiosyncratic labor productivity shocks that cannot be fully insured as in {cite}`Aiyagari1994`
24
32
- Government fiscal policy instruments include tax rates, debt, and transfers as in chapter 2 of {cite}`auerbach1987dynamic` and {doc}`Transitions in an Overlapping Generations Model<ak2>`
25
-
- Among other equilibrium objects, a competitive determines a sequence of cross-section densities of heterogeneous agents' consumptions, labor incomes, and savings
33
+
- Among other equilibrium objects, a competitive equilibrium determines a sequence of cross-section densities of heterogeneous agents' consumptions, labor incomes, and savings
26
34
27
35
28
36
We use the model to study:
@@ -40,7 +48,7 @@ As prerequisites for this lecture, we recommend two quantecon lectures:
40
48
41
49
as well as the optional reading {doc}`aiyagari`
42
50
43
-
As usual, let's start by importing some Python modules.
51
+
As usual, let's start by importing some Python modules
44
52
45
53
```{code-cell} ipython3
46
54
from collections import namedtuple
@@ -53,6 +61,8 @@ import jax
53
61
54
62
## Environment
55
63
64
+
We start by introducing the economic environment we are operating in.
65
+
56
66
### Demographics and time
57
67
58
68
We work in discrete time indexed by $t = 0, 1, 2, ...$.
@@ -75,7 +85,7 @@ An agent with productivity $\gamma_{i,j,t}$ supplies $l(j)\gamma_{i,j,t}$ effici
75
85
76
86
$l(j)$ is a deterministic age-specific labor efficiency units profile.
77
87
78
-
An agent's effective labor supply depends on a life-cycle efficiency profile and an idiosyncratic stochastic process.
88
+
An agent's effective labor supply depends on a life-cycle efficiency profile and an idiosyncratic stochastic process.
79
89
80
90
### Initial conditions
81
91
@@ -199,7 +209,7 @@ $V_{J,t}(a, \gamma) = 0$
199
209
200
210
## Population dynamics
201
211
202
-
The joint probability density function $\mu_{j,t}(a,\gamma)$ of asset holdings and idiosyncratic labor evolves according to
212
+
The joint probability density function $\mu_{j,t}(a,\gamma)$ of asset holdings and idiosyncratic labor productivity evolves according to
203
213
204
214
- For newborns $(j=0)$:
205
215
@@ -245,19 +255,19 @@ Relative to the model presented in {doc}`Transitions in an Overlapping Generati
245
255
246
256
## Implementation
247
257
248
-
Using tools in {doc}`discrete_dp`, we solve our model by combining value function iteration with equilibrium price determination.
258
+
Using tools in {doc}`advanced:discrete_dp`, we solve our model by combining value function iteration with equilibrium price determination.
249
259
250
260
A sensible approach is to nest a discrete DP solver inside an outer loop that searches for market-clearing prices.
251
261
252
262
For a candidate sequence of prices interest rates $r_t$ and wages $w_t$, we can solve individual households' dynamic programming problems using either value function iteration or policy iteration to obtain optimal policy functions.
253
263
254
264
We then deduce associated stationary joint probability distributions of asset holdings and idiosyncratic labor efficiency units for each age cohort.
255
265
256
-
That will give us an aggregate capital supply (from household savings) and a labor supply (from the age-efficiency profile and productivity shocks).
266
+
This will give us an aggregate capital supply (from household savings) and a labor supply (from the age-efficiency profile and productivity shocks).
257
267
258
268
We can then compare these with capital and labor demand from firms, compute deviations between factor market supplies and demands, then update price guesses until we find market-clearing prices.
259
269
260
-
To construct transition dynamics, we can compute sequences of time-varying prices by using _backward induction_ to compute value and policy functions, and _forward iteration_ for the distributions of agents across states.
270
+
To construct transition dynamics, we can compute sequences of time-varying prices by using _backward induction_ to compute value and policy functions, and _forward iteration_ for the distributions of agents across states:
261
271
262
272
1. Outer loop (market clearing)
263
273
* Guess initial prices ($r_t, w_t$)
@@ -319,7 +329,7 @@ def l(j):
319
329
return l1 + l2 * j + l3 * j ** 2
320
330
```
321
331
322
-
Let's define a `Firm` namedtuple that contains parameters governing the production technology.
332
+
Let's define a `Firm` namedtuple that contains parameters governing the production technology.
323
333
324
334
```{code-cell} ipython3
325
335
Firm = namedtuple("Firm", ("α", "Z"))
@@ -333,7 +343,7 @@ def create_firm(α=0.3, Z=1):
333
343
firm = create_firm()
334
344
```
335
345
336
-
The following helper functions link aggregates ($K, L$) and prices ($w, r$) that emerge from the representative firm's first-order necessary conditions.
346
+
The following helper functions link aggregates ($K, L$) and prices ($w, r$) that emerge from the representative firm's first-order necessary conditions.
337
347
338
348
```{code-cell} ipython3
339
349
@jax.jit
@@ -351,7 +361,7 @@ def KL_to_w(K, L, firm):
351
361
return Z * (1 - α) * (K / L) ** α
352
362
```
353
363
354
-
We use a function `find_τ` to find flat tax rates that balance the government budget constraint given other policy variables that include debt levels, government spending, and transfers.
364
+
We use a function `find_τ` to find flat tax rates that balance the government budget constraint given other policy variables that include debt levels, government spending, and transfers.
Given guesses of prices and taxes, we can use backwards induction to solve for value functions and optimal consumption and saving policies at all ages.
452
462
453
-
The function `backwards_opt`solve for optimal values by applying the discretized bellman operator backwards.
463
+
The function `backwards_opt`solves for optimal values by applying the discretized bellman operator backwards.
454
464
455
465
We use `jax.lax.scan` to facilitate sequential and recurrent computations efficiently.
456
466
@@ -500,11 +510,13 @@ Q = populate_Q(hh)
500
510
V, σ = backwards_opt([r, w], [τ, δ], hh, Q)
501
511
```
502
512
513
+
Let's time the computation with `block_until_ready()` to ensure that all JAX operations are complete
From optimal consumption and saving choices by each cohort, we can compute a joint probability distribution of asset levels and idiosyncratic productivity levels in a steady state.
519
+
From the optimal consumption and saving choices by each cohort, we can compute a joint probability distribution of asset levels and idiosyncratic productivity levels in a steady state.
0 commit comments