Skip to content

Commit 8d4597f

Browse files
committed
addressing editorial suggestions to the ak2 lecture
1 parent 73f315b commit 8d4597f

File tree

1 file changed

+44
-47
lines changed

1 file changed

+44
-47
lines changed

Diff for: lectures/ak2.md

+44-47
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.14.1
7+
jupytext_version: 1.16.1
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
@@ -15,8 +15,9 @@ kernelspec:
1515

1616
In addition to what’s in Anaconda, this lecture will need the following libraries:
1717

18-
```{code-cell} ipython3
18+
```{code-cell}
1919
:tags: [hide-output]
20+
2021
!pip install --upgrade quantecon
2122
```
2223

@@ -29,6 +30,7 @@ This lecture presents a life-cycle model consisting of overlapping generations
2930
We'll present the version that was analyzed in chapter 2 of Auerbach and
3031
Kotlikoff (1987) {cite}`auerbach1987dynamic`.
3132

33+
3234
Auerbach and Kotlikoff (1987) used their two period model as a warm-up for their analysis of overlapping generation models of long-lived people that is the main topic of their book.
3335

3436
Their model of two-period lived overlapping generations is a useful starting point because
@@ -214,10 +216,10 @@ We take output at time $t$ as *numeraire*, so the price of output at time $t$ is
214216
The firm's profits at time $t$ are
215217
216218
$$
217-
K_t^\alpha L_t^{1-\alpha} - r_t K_t - W_t L_t .
219+
\pi_t = K_t^\alpha L_t^{1-\alpha} - r_t K_t - W_t L_t .
218220
$$
219221
220-
To maximize profits a firm equates marginal products to rental rates:
222+
To maximize profits a firm equates marginal products to rental rates, which can be done by taking the first-order derivatives of the profit function $\pi_t$:
221223
222224
$$
223225
\begin{aligned}
@@ -289,7 +291,7 @@ $$
289291
C_{yt} + \frac{C_{ot+1}}{1 + r_{t+1}(1 - \tau_{t+1})} = W_t (1 - \tau_t) - \delta_{yt} - \frac{\delta_{ot}}{1 + r_{t+1}(1 - \tau_{t+1})}
290292
$$ (eq:onebudgetc)
291293
292-
To solve the young person's choice problem, form a Lagrangian
294+
To solve the young person's choice problem, form a [Lagrangian](https://en.wikipedia.org/wiki/Lagrange_multiplier)
293295
294296
$$
295297
\begin{aligned}
@@ -405,17 +407,15 @@ $$
405407
406408
### Implementation
407409
408-
```{code-cell} ipython3
410+
```{code-cell}
409411
import numpy as np
410412
import matplotlib.pyplot as plt
411-
from numba import njit
412413
from quantecon.optimize import brent_max
413414
```
414415
415-
416416
For parameters $\alpha = 0.3$ and $\beta = 0.5$, let's compute $\hat{K}$:
417417
418-
```{code-cell} ipython3
418+
```{code-cell}
419419
# parameters
420420
α = 0.3
421421
β = 0.5
@@ -428,27 +428,28 @@ D_hat = 0.
428428
K_hat = ((1 - τ_hat) * (1 - α) * (1 - β)) ** (1 / (1 - α))
429429
K_hat
430430
```
431+
431432
Knowing $\hat K$, we can calculate other equilibrium objects.
432433
433434
Let's first define some Python helper functions.
434435
435-
```{code-cell} ipython3
436-
@njit
436+
```{code-cell}
437+
437438
def K_to_Y(K, α):
438439
439440
return K ** α
440441
441-
@njit
442+
442443
def K_to_r(K, α):
443444
444445
return α * K ** (α - 1)
445446
446-
@njit
447+
447448
def K_to_W(K, α):
448449
449450
return (1 - α) * K ** α
450451
451-
@njit
452+
452453
def K_to_C(K, D, τ, r, α, β):
453454
454455
# optimal consumption for the old when δ=0
@@ -464,35 +465,34 @@ def K_to_C(K, D, τ, r, α, β):
464465
465466
We can use these helper functions to obtain steady state values $\hat{Y}$, $\hat{r}$, and $\hat{W}$ associated with steady state values $\hat{K}$ and $\hat{r}$.
466467
467-
```{code-cell} ipython3
468+
```{code-cell}
468469
Y_hat, r_hat, W_hat = K_to_Y(K_hat, α), K_to_r(K_hat, α), K_to_W(K_hat, α)
469470
Y_hat, r_hat, W_hat
470471
```
471472
472473
Since steady state government debt $\hat{D}$ is $0$, all taxes are used to pay for government expenditures
473474
474-
```{code-cell} ipython3
475+
```{code-cell}
475476
G_hat = τ_hat * Y_hat
476477
G_hat
477478
```
478479
479480
We use the optimal consumption plans to find steady state consumptions for young and old
480481
481-
```{code-cell} ipython3
482+
```{code-cell}
482483
Cy_hat, Co_hat = K_to_C(K_hat, D_hat, τ_hat, r_hat, α, β)
483484
Cy_hat, Co_hat
484485
```
485486
486-
Let's store the steady state quantities and prices using an array called `init_ss`
487+
Let's store the steady state quantities and prices using an array called `init_ss`
487488
488-
```{code-cell} ipython3
489+
```{code-cell}
489490
init_ss = np.array([K_hat, Y_hat, Cy_hat, Co_hat, # quantities
490491
W_hat, r_hat, # prices
491492
τ_hat, D_hat, G_hat # policies
492493
])
493494
```
494495
495-
496496
### Transitions
497497
498498
<!--
@@ -534,9 +534,9 @@ In each policy experiment below, we will pass two out of three as inputs require
534534
535535
We'll then compute the single remaining undetermined policy variable from the government budget constraint.
536536
537-
When we simulate transition paths, it is useful to distinguish **state variables** at time $t$ such as $K_t, Y_t, D_t, W_t, r_t$ from **control variables** that include $C_{yt}, C_{ot}, \tau_{t}, G_t$.
537+
When we simulate transition paths, it is useful to distinguish **state variables** at time $t$ such as $K_t, Y_t, D_t, W_t, r_t$ from **control variables** that include $C_{yt}, C_{ot}, \tau_{t}, G_t$.
538538
539-
```{code-cell} ipython3
539+
```{code-cell}
540540
class ClosedFormTrans:
541541
"""
542542
This class simulates length T transitional path of a economy
@@ -681,8 +681,7 @@ class ClosedFormTrans:
681681
682682
We can create an instance `closed` for model parameters $\{\alpha, \beta\}$ and use it for various fiscal policy experiments.
683683
684-
685-
```{code-cell} ipython3
684+
```{code-cell}
686685
closed = ClosedFormTrans(α, β)
687686
```
688687
@@ -712,7 +711,7 @@ The first step is to prepare sequences of policy variables that describe fiscal
712711
713712
We must define sequences of government expenditure $\{G_t\}_{t=0}^{T}$ and debt level $\{D_t\}_{t=0}^{T+1}$ in advance, then pass them to the solver.
714713
715-
```{code-cell} ipython3
714+
```{code-cell}
716715
T = 20
717716
718717
# tax cut
@@ -731,16 +730,16 @@ Let's use the `simulate` method of `closed` to compute dynamic transitions.
731730
732731
Note that we leave `τ_pol` as `None`, since the tax rates need to be determined to satisfy the government budget constraint.
733732
734-
```{code-cell} ipython3
733+
```{code-cell}
735734
quant_seq1, price_seq1, policy_seq1 = closed.simulate(T, init_ss,
736735
D_pol=D_seq,
737736
G_pol=G_seq)
738737
closed.plot()
739738
```
740739
741-
We can also experiment with a lower tax cut rate, such as $0.2$.
740+
We can also experiment with a lower tax cut rate, such as $0.2$.
742741
743-
```{code-cell} ipython3
742+
```{code-cell}
744743
# lower tax cut rate
745744
τ0 = 0.15 * (1 - 0.2)
746745
@@ -754,7 +753,7 @@ quant_seq2, price_seq2, policy_seq2 = closed.simulate(T, init_ss,
754753
G_pol=G_seq)
755754
```
756755
757-
```{code-cell} ipython3
756+
```{code-cell}
758757
fig, axs = plt.subplots(3, 3, figsize=(14, 10))
759758
760759
# quantities
@@ -798,7 +797,7 @@ The government targets the same tax rate $\tau_t=\hat{\tau}$ and to accumulate
798797
799798
To conduct this experiment, we pass `τ_seq` and `G_seq` as inputs and let `D_pol` be determined along the path by satisfying the government budget constraint.
800799
801-
```{code-cell} ipython3
800+
```{code-cell}
802801
# government expenditure cut by a half
803802
G_seq = τ_hat * 0.5 * Y_hat * np.ones(T+1)
804803
@@ -813,7 +812,7 @@ As the government accumulates the asset and uses it in production, the rental r
813812
814813
As a result, the ratio $-\frac{D_t}{K_t}$ of the government asset to physical capital used in production will increase over time
815814
816-
```{code-cell} ipython3
815+
```{code-cell}
817816
plt.plot(range(T+1), -closed.policy_seq[:-1, 1] / closed.quant_seq[:, 0])
818817
plt.xlabel('t')
819818
plt.title('-D/K');
@@ -840,7 +839,7 @@ But now let the government cut its expenditures only at $t=0$.
840839
841840
From $t \geq 1$, the government expeditures return to $\hat{G}$ and $\tau_t$ adjusts to maintain the asset level $-D_t = -D_1$.
842841
843-
```{code-cell} ipython3
842+
```{code-cell}
844843
# sequence of government purchase
845844
G_seq = τ_hat * Y_hat * np.ones(T+1)
846845
G_seq[0] = 0
@@ -912,8 +911,7 @@ Let's implement this "guess and verify" approach
912911
913912
We start by defining the Cobb-Douglas utility function
914913
915-
```{code-cell} ipython3
916-
@njit
914+
```{code-cell}
917915
def U(Cy, Co, β):
918916
919917
return (Cy ** β) * (Co ** (1-β))
@@ -923,8 +921,7 @@ We use `Cy_val` to compute the lifetime value of an arbitrary consumption plan,
923921
924922
Note that it requires knowing future prices $r_{t+1}$ and tax rate $\tau_{t+1}$.
925923
926-
```{code-cell} ipython3
927-
@njit
924+
```{code-cell}
928925
def Cy_val(Cy, W, r_next, τ, τ_next, δy, δo_next, β):
929926
930927
# Co given by the budget constraint
@@ -937,7 +934,7 @@ An optimal consumption plan $C_y^*$ can be found by maximizing `Cy_val`.
937934
938935
Here is an example that computes optimal consumption $C_y^*=\hat{C}_y$ in the steady state with $\delta_{yt}=\delta_{ot}=0,$ like one that we studied earlier
939936
940-
```{code-cell} ipython3
937+
```{code-cell}
941938
W, r_next, τ, τ_next = W_hat, r_hat, τ_hat, τ_hat
942939
δy, δo_next = 0, 0
943940
@@ -953,7 +950,7 @@ Let's define a Python class `AK2` that computes the transition paths with the
953950
954951
It can handle nonzero lump sum taxes
955952
956-
```{code-cell} ipython3
953+
```{code-cell}
957954
class AK2():
958955
"""
959956
This class simulates length T transitional path of a economy
@@ -1124,13 +1121,13 @@ class AK2():
11241121
11251122
We can initialize an instance of class `AK2` with model parameters $\{\alpha, \beta\}$ and then use it to conduct fiscal policy experiments.
11261123
1127-
```{code-cell} ipython3
1124+
```{code-cell}
11281125
ak2 = AK2(α, β)
11291126
```
11301127
11311128
We first examine that the "guess and verify" method leads to the same numerical results as we obtain with the closed form solution when lump sum taxes are muted
11321129
1133-
```{code-cell} ipython3
1130+
```{code-cell}
11341131
δy_seq = np.ones(T+2) * 0.
11351132
δo_seq = np.ones(T+2) * 0.
11361133
@@ -1144,22 +1141,22 @@ D_pol[0] = D_hat
11441141
D_pol[1:] = D1
11451142
```
11461143
1147-
```{code-cell} ipython3
1144+
```{code-cell}
11481145
quant_seq3, price_seq3, policy_seq3 = ak2.simulate(T, init_ss,
11491146
δy_seq, δo_seq,
11501147
D_pol=D_pol, G_pol=G_pol,
11511148
verbose=True)
11521149
```
11531150
1154-
```{code-cell} ipython3
1151+
```{code-cell}
11551152
ak2.plot()
11561153
```
11571154
11581155
Next, we activate lump sum taxes.
11591156
1160-
Let's alter our {ref}`exp-tax-cut` fiscal policy experiment by assuming that the government also increases lump sum taxes for both young and old people $\delta_{yt}=\delta_{ot}=0.005, t\geq0$.
1157+
Let's alter our {ref}`exp-tax-cut` fiscal policy experiment by assuming that the government also increases lump sum taxes for both young and old people $\delta_{yt}=\delta_{ot}=0.005, t\geq0$.
11611158
1162-
```{code-cell} ipython3
1159+
```{code-cell}
11631160
δy_seq = np.ones(T+2) * 0.005
11641161
δo_seq = np.ones(T+2) * 0.005
11651162
@@ -1173,7 +1170,7 @@ quant_seq4, price_seq4, policy_seq4 = ak2.simulate(T, init_ss,
11731170
11741171
Note how "crowding out" has been mitigated.
11751172
1176-
```{code-cell} ipython3
1173+
```{code-cell}
11771174
fig, axs = plt.subplots(3, 3, figsize=(14, 10))
11781175
11791176
# quantities
@@ -1227,7 +1224,7 @@ We can use our code to compute the transition ignited by launching this system
12271224
12281225
Let's compare the results to the {ref}`exp-tax-cut`.
12291226
1230-
```{code-cell} ipython3
1227+
```{code-cell}
12311228
δy_seq = np.ones(T+2) * Cy_hat * 0.1
12321229
δo_seq = np.ones(T+2) * -Cy_hat * 0.1
12331230
@@ -1238,7 +1235,7 @@ quant_seq5, price_seq5, policy_seq5 = ak2.simulate(T, init_ss,
12381235
D_pol=D_pol, G_pol=G_pol)
12391236
```
12401237
1241-
```{code-cell} ipython3
1238+
```{code-cell}
12421239
fig, axs = plt.subplots(3, 3, figsize=(14, 10))
12431240
12441241
# quantities

0 commit comments

Comments
 (0)