Skip to content

Commit 370ecb1

Browse files
Tom's edits of the ak_aiyagari lecture, September 4
1 parent e98bf44 commit 370ecb1

File tree

1 file changed

+71
-35
lines changed

1 file changed

+71
-35
lines changed

lectures/ak_aiyagari.md

Lines changed: 71 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,20 @@ $V_{J,t}(a, γ) = 0$
185185
The joint probability density function $μ_{j,t}(a,γ)$ of asset holdings and idiosyncratic labor evolves according to
186186

187187
- For newborns $(j=0)$:
188-
$$μ_{0,t+1}(a',γ') = π(γ')\text{ if }a'=0\text{, }0\text{ otherwise}$$
188+
189+
$$
190+
μ_{0,t+1}(a',γ') =\begin{cases}
191+
π(γ') &\text{ if }a'=0\text{, }\\
192+
0, & \text{otherwise}
193+
\end{cases}
194+
$$
195+
189196

190197
- For other cohorts:
191-
$$\mu_{j+1,t+1}(a',\gamma') = \int 1\{\sigma_{j,t}(a,\gamma)=a'\}\Pi(\gamma,\gamma')\mu_{j,t}(a,\gamma)d(a,\gamma)$$
198+
199+
$$
200+
\mu_{j+1,t+1}(a',\gamma') = \int {\bf 1}_{\sigma_{j,t}(a,\gamma)=a'}\Pi(\gamma,\gamma')\mu_{j,t}(a,\gamma)d(a,\gamma)
201+
$$
192202

193203
where $σ_{j,t}(a,γ)$ is the optimal saving policy function.
194204

@@ -225,13 +235,16 @@ Using tools in [discrete state dynamic programming lecture](https://python-adva
225235

226236
A sensible approach is to nest a discrete DP solver inside an outer loop that searches for market-clearing prices.
227237

228-
For each candidate sequence of prices (interest rates $r$ and wages $w$), we can solve individual households' dynamic programming problems using either value function iteration or policy function iteration to obtain optimal policy functions, then deduce associated stationary joint probability distributions of asset holdings and idiosyncratic labor efficiency units for each age cohort.
238+
For a candidate sequence of prices interest rates $r_t$ and wages $w_t$, we can
239+
240+
* solve individual households' dynamic programming problems using either value function iteration or policy function iteration to obtain optimal policy functions
241+
* then deduce associated stationary joint probability distributions of asset holdings and idiosyncratic labor efficiency units for each age cohort
229242

230-
That will give us an aggregate capital supply (from household savings) and a labor supply (from the age-efficiency profile and productivity shocks).
243+
* that will give us an aggregate capital supply (from household savings) and a labor supply (from the age-efficiency profile and productivity shocks)
231244

232-
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.
245+
* 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
233246

234-
For transition dynamics, we can compute sequences of time-varying prices by
247+
To contruct transition dynamics, we can compute sequences of time-varying prices by
235248

236249
* using backward induction to compute value and policy functions,
237250
* forward iteration for the distributions of agents across states.
@@ -310,7 +323,7 @@ def create_firm(α=0.3, Z=1):
310323
firm = create_firm()
311324
```
312325

313-
The following helper functions describe relationship between the aggregates ($K, L$) and the prices ($w, r$) that emerge from the representative firm's first-order necessary conditions.
326+
The following helper functions link aggregates ($K, L$) and prices ($w, r$) that emerge from the representative firm's first-order necessary conditions.
314327

315328
```{code-cell} ipython3
316329
@jax.jit
@@ -328,7 +341,7 @@ def KL_to_w(K, L, firm):
328341
return Z * (1 - α) * (K / L) ** α
329342
```
330343

331-
We use a function `find_τ` to find flat tax rates that balance the government budget constraint given other policy variables that include s debt levels, government spending, and transfers.
344+
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.
332345

333346
```{code-cell} ipython3
334347
@jax.jit
@@ -344,7 +357,7 @@ def find_τ(policy, price, aggs):
344357
return num / denom
345358
```
346359

347-
We also use a namedtuple `Household` to store all the relevant parameters that characterize the household problems.
360+
We use a namedtuple `Household` to store parameters that characterize households' problems.
348361

349362
```{code-cell} ipython3
350363
Household = namedtuple("Household", ("j_grid", "a_grid", "γ_grid",
@@ -386,9 +399,9 @@ def create_household(
386399
hh = create_household()
387400
```
388401

389-
We solve household optimization problems using discrete state dynamic programming tools.
402+
We apply discrete state dynamic programming tools.
390403

391-
Initial steps involve preparing rewards and transition matrices, $R$ and $Q$, for our discretized Bellman equations.
404+
Initial steps involve preparing rewards and transition matrices $R$ and $Q$ for our discretized Bellman equations.
392405

393406
```{code-cell} ipython3
394407
@jax.jit
@@ -422,7 +435,7 @@ def populate_R(j, r, w, τ, δ, household):
422435
(num_state, num_action))
423436
```
424437

425-
## Steady State Computation
438+
## Computing a Steady State
426439

427440
We first compute steady state.
428441

@@ -478,8 +491,7 @@ V, σ = backwards_opt([r, w], [τ, δ], hh, Q)
478491
%time backwards_opt([r, w], [τ, δ], hh, Q)
479492
```
480493

481-
Given optimal consumption and saving choices by each cohorts, we can compute the stationary joint probability distribution
482-
of asset levels and idiosyncratic productivity levels in the steady state.
494+
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.
483495

484496
```{code-cell} ipython3
485497
@jax.jit
@@ -513,11 +525,8 @@ def popu_dist(σ, household, Q):
513525
%time popu_dist(σ, hh, Q)
514526
```
515527

516-
Here we plot the distribution over savings by each age group.
528+
Below we plot the marginal distribution of savings for each age group.
517529

518-
It makes sense that young cohorts enter the economy with no asset holdings, then gradually accumulate assets as they age.
519-
520-
As they approach the end of life, they deplete their asset holdings -- they leave no bequests.
521530

522531
```{code-cell} ipython3
523532
for j in [0, 5, 20, 45, 49]:
@@ -533,7 +542,27 @@ plt.ylim([0, 0.1])
533542
plt.show()
534543
```
535544

536-
It is also intuitive to investigate the optimal saving policies.
545+
546+
These marginal distributions confirm that new agents enter the economy with no asset holdings.
547+
548+
* the blue $j=0$ distribution has mass only at $a=0$.
549+
550+
As agents age, at first they gradually accumulate assets.
551+
552+
* the orange $j=5$ distribution puts positive mass on positive but low asset levels
553+
* the green $j=20$ distribution puts positive mass on a much wider range of asset levels.
554+
* the red $j=45$ distibution is even wider
555+
556+
At a later age, they gradually deplete their asset holdings.
557+
558+
* the purple $j=49$ distribution illustrates this
559+
560+
At the end of life, they will have drawn down all of their assets.
561+
562+
Let's now look at age-specific optimal saving policies that generate the preceding marginal
563+
distributions of assets at different ages.
564+
565+
We'll plot some saving functions with the following Python code.
537566

538567
```{code-cell} ipython3
539568
σ_reshaped = σ.reshape(hh.j_grid.size, hh.a_grid.size, hh.γ_grid.size)
@@ -714,7 +743,7 @@ r_ss1, w_ss1
714743

715744
We compute transition dynamics using a function `path_iteration`.
716745

717-
We iterate over guesses of prices and taxes in our outer loop.
746+
In an outer loop, we iterate over guesses of prices and taxes.
718747

719748
In an inner loop, we compute the optimal consumption and saving choices by each cohort $j$ in each time $t$, then find the implied evolution of the joint distribution of assets and productivities.
720749

@@ -972,7 +1001,7 @@ def path_iteration(ss1, ss2, pol_target, household, firm, Q, tol=1e-4, verbose=F
9721001
return V_seq, σ_seq, μ_seq, K_seq, L_seq, r_seq, w_seq, τ_seq, D_seq, G_seq, δ_seq
9731002
```
9741003

975-
We now have tools for computing equilibrium transition dynamics ignited by fiscal policy reforms, in the spirit of the {doc}`Transitions in an Overlapping Generations Model<ak2>`.
1004+
We can now compute equilibrium transitions that are ignited by fiscal policy reforms.
9761005

9771006
## Experiment 1: Immediate Tax Cut
9781007

@@ -1016,7 +1045,7 @@ Setting the key argument `verbose=True` tells the function `path_iteration` to
10161045
paths = path_iteration(ss1, ss2, [D_seq, G_seq, δ_seq], hh, firm, Q, verbose=True)
10171046
```
10181047

1019-
After successfully computing transition dynamics, let's study them.
1048+
Having successfully computing transition dynamics, let's study them.
10201049

10211050
```{code-cell} ipython3
10221051
V_seq, σ_seq, μ_seq = paths[:3]
@@ -1050,7 +1079,7 @@ c = inc - ap
10501079
c_mean0 = (c * μ_seq[t]).sum(axis=1)
10511080
```
10521081

1053-
We care about how such policy change impacts consumption levels of cohorts at different times.
1082+
We care about how the policy change affects consumption across cohorts and across time.
10541083

10551084
We can study age-specific average consumption levels.
10561085

@@ -1076,11 +1105,13 @@ plt.title(r'Δmean(C(j))')
10761105

10771106
To summarize the transition, we can plot paths as we did in {doc}`Transitions in an Overlapping Generations Model<ak2>`.
10781107

1079-
Unlike the AK setup, we no longer have representative old and young agents.
1108+
But unlike the setup in that two-period lived overlapping generations model, we no longer have representative old and young agents.
10801109

1081-
Instead we have agents from 50 cohorts coexisting simultaneously.
1110+
* now we have 50 cohorts of different ages at each time
10821111

1083-
To get a counterpart of AK lectures we can construct two age groups with equal size, setting a threshold at age 25.
1112+
To proceed, we construct two age groups of equal size -- young and old.
1113+
1114+
* at age 25, someone moves from being young to become old
10841115

10851116
```{code-cell} ipython3
10861117
ap = hh.a_grid[σ_ss1]
@@ -1148,7 +1179,7 @@ axs[2, 2].set_ylim([ss1[9]-0.1, ss1[9]+0.1])
11481179
plt.show()
11491180
```
11501181

1151-
To look into the evolution of consumption distribution over age in more detail, let's compute the mean and variance of consumption conditional on age in each time $t$.
1182+
Now let's compute the mean and variance of consumption conditional on age at each time $t$.
11521183

11531184
```{code-cell} ipython3
11541185
Cmean_seq = np.empty((T, J))
@@ -1194,11 +1225,11 @@ plt.show()
11941225
## Experiment 2: Preannounced Tax Cut
11951226

11961227

1197-
Instead of implementing a tax rate cut immediately as it did in Experiment 1, now the government announces a tax rate cut at time $0$ but delays implementing it for 20 periods.
1228+
Now the government announces a permanent tax rate cut at time $0$ but implements it only after 20 periods.
11981229

11991230
We will use the same key toolkit `path_iteration`.
12001231

1201-
We only need to specify `D_seq` appropriately.
1232+
We must specify `D_seq` appropriately.
12021233

12031234
```{code-cell} ipython3
12041235
T = 150
@@ -1250,7 +1281,7 @@ for t in range(T):
12501281

12511282
Below we plot the transition paths of the economy.
12521283

1253-
Notice how prices and quantities respond to the foreseen tax rate increase.
1284+
12541285

12551286
```{code-cell} ipython3
12561287
fig, axs = plt.subplots(3, 3, figsize=(14, 10))
@@ -1284,7 +1315,9 @@ axs[2, 2].set_ylim([ss1[9]-0.1, ss1[9]+0.1])
12841315
plt.show()
12851316
```
12861317

1287-
Let's zoom in and look at how the capital stock responds to the future tax cut.
1318+
Notice how prices and quantities respond immediately to the anticipated tax rate increase.
1319+
1320+
Let's zoom in on how the capital stock responds.
12881321

12891322
```{code-cell} ipython3
12901323
# K
@@ -1301,13 +1334,16 @@ plt.xlabel("t")
13011334

13021335
After the tax cut policy is implemented after $t=20$, the aggregate capital will decrease because of the crowding out effect.
13031336

1304-
Forseeing the increase in the interest rate, individuals living in a few periods before $t=20$ will save more. This will cause a temporary decrease in the interest rate because of the increase in capital supply.
1337+
Having foreseen an increase in the interest rate, individuals few periods before $t=20$ start saving more.
1338+
1339+
Because that increases the capital, a temporary decrease in the interest rate ensues.
1340+
1341+
For agents living in much earlier periods, that lower interest rate causes them to save less.
1342+
13051343

1306-
For agents living in earlier periods, they will consequently save less because the lower interest rate.
13071344

1308-
This manifests interesting dynamics of the economy between the annoucement of a policy and its actual implementation, with agents holding rational expectations.
1345+
We can also plot evolutions of means and variances of consumption by different cohorts along a transition path.
13091346

1310-
As above, we could also plot the evolution of mean and variance of consumption by different cohorts along the transition path.
13111347
```{code-cell} ipython3
13121348
Cmean_seq = np.empty((T, J))
13131349
Cvar_seq = np.empty((T, J))

0 commit comments

Comments
 (0)