Skip to content

Commit dd1945e

Browse files
mmckyclaude
andauthored
[ak2, ak_aiyagari, two_computation] Add figure captions and lw=2 (#1081)
Give every code-generated figure in the main text a mystnb caption and name, and set lw=2 on line charts, per the figures page of the style guide. Figures inside exercises and solutions are left uncaptioned so the PDF build is unaffected. See #1080 Co-authored-by: Claude Fable 5.1 <[email protected]>
1 parent 3bc9168 commit dd1945e

3 files changed

Lines changed: 192 additions & 48 deletions

File tree

‎lectures/ak2.md‎

Lines changed: 75 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -681,23 +681,23 @@ class ClosedFormTrans:
681681
# quantities
682682
for i, name in enumerate(['K', 'Y', 'Cy', 'Co']):
683683
ax = axs[i//3, i%3]
684-
ax.plot(range(T+1), quant_seq[:T+1, i], label=name)
684+
ax.plot(range(T+1), quant_seq[:T+1, i], label=name, lw=2)
685685
ax.hlines(init_ss[i], 0, T+1, color='r', linestyle='--')
686686
ax.legend()
687687
ax.set_xlabel('t')
688688
689689
# prices
690690
for i, name in enumerate(['W', 'r']):
691691
ax = axs[(i+4)//3, (i+4)%3]
692-
ax.plot(range(T+1), price_seq[:T+1, i], label=name)
692+
ax.plot(range(T+1), price_seq[:T+1, i], label=name, lw=2)
693693
ax.hlines(init_ss[i+4], 0, T+1, color='r', linestyle='--')
694694
ax.legend()
695695
ax.set_xlabel('t')
696696
697697
# policies
698698
for i, name in enumerate(['τ', 'D', 'G']):
699699
ax = axs[(i+6)//3, (i+6)%3]
700-
ax.plot(range(T+1), policy_seq[:T+1, i], label=name)
700+
ax.plot(range(T+1), policy_seq[:T+1, i], label=name, lw=2)
701701
ax.hlines(init_ss[i+6], 0, T+1, color='r', linestyle='--')
702702
ax.legend()
703703
ax.set_xlabel('t')
@@ -756,6 +756,12 @@ Let's use the `simulate` method of `closed` to compute dynamic transitions.
756756
Note that we leave `τ_pol` as `None`, since the tax rates need to be determined to satisfy the government budget constraint.
757757
758758
```{code-cell} ipython3
759+
---
760+
mystnb:
761+
figure:
762+
caption: Transition after a tax cut
763+
name: ak2_exp1_tax_cut
764+
---
759765
quant_seq1, price_seq1, policy_seq1 = closed.simulate(T, init_ss,
760766
D_pol=D_seq,
761767
G_pol=G_seq)
@@ -779,31 +785,37 @@ quant_seq2, price_seq2, policy_seq2 = closed.simulate(T, init_ss,
779785
```
780786
781787
```{code-cell} ipython3
788+
---
789+
mystnb:
790+
figure:
791+
caption: Tax cut transitions for two tax rates
792+
name: ak2_exp1_two_rates
793+
---
782794
fig, axs = plt.subplots(3, 3, figsize=(14, 10))
783795
784796
# quantities
785797
for i, name in enumerate(['K', 'Y', 'Cy', 'Co']):
786798
ax = axs[i//3, i%3]
787-
ax.plot(range(T+1), quant_seq1[:T+1, i], label=f'{name}, 1/3')
788-
ax.plot(range(T+1), quant_seq2[:T+1, i], label=f'{name}, 0.2')
799+
ax.plot(range(T+1), quant_seq1[:T+1, i], label=f'{name}, 1/3', lw=2)
800+
ax.plot(range(T+1), quant_seq2[:T+1, i], label=f'{name}, 0.2', lw=2)
789801
ax.hlines(init_ss[i], 0, T+1, color='r', linestyle='--')
790802
ax.legend()
791803
ax.set_xlabel('t')
792804
793805
# prices
794806
for i, name in enumerate(['W', 'r']):
795807
ax = axs[(i+4)//3, (i+4)%3]
796-
ax.plot(range(T+1), price_seq1[:T+1, i], label=f'{name}, 1/3')
797-
ax.plot(range(T+1), price_seq2[:T+1, i], label=f'{name}, 0.2')
808+
ax.plot(range(T+1), price_seq1[:T+1, i], label=f'{name}, 1/3', lw=2)
809+
ax.plot(range(T+1), price_seq2[:T+1, i], label=f'{name}, 0.2', lw=2)
798810
ax.hlines(init_ss[i+4], 0, T+1, color='r', linestyle='--')
799811
ax.legend()
800812
ax.set_xlabel('t')
801813
802814
# policies
803815
for i, name in enumerate(['τ', 'D', 'G']):
804816
ax = axs[(i+6)//3, (i+6)%3]
805-
ax.plot(range(T+1), policy_seq1[:T+1, i], label=f'{name}, 1/3')
806-
ax.plot(range(T+1), policy_seq2[:T+1, i], label=f'{name}, 0.2')
817+
ax.plot(range(T+1), policy_seq1[:T+1, i], label=f'{name}, 1/3', lw=2)
818+
ax.plot(range(T+1), policy_seq2[:T+1, i], label=f'{name}, 0.2', lw=2)
807819
ax.hlines(init_ss[i+6], 0, T+1, color='r', linestyle='--')
808820
ax.legend()
809821
ax.set_xlabel('t')
@@ -823,6 +835,12 @@ The government targets the same tax rate $\tau_t=\hat{\tau}$ and to accumulate
823835
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.
824836
825837
```{code-cell} ipython3
838+
---
839+
mystnb:
840+
figure:
841+
caption: Transition after a permanent expenditure cut
842+
name: ak2_exp2_expenditure_cut
843+
---
826844
# government expenditure cut by a half
827845
G_seq = τ_hat * 0.5 * Y_hat * np.ones(T+1)
828846
@@ -844,7 +862,7 @@ mystnb:
844862
caption: Ratio of government assets to capital
845863
name: ak2_asset_capital_ratio
846864
---
847-
plt.plot(range(T+1), -closed.policy_seq[:-1, 1] / closed.quant_seq[:, 0])
865+
plt.plot(range(T+1), -closed.policy_seq[:-1, 1] / closed.quant_seq[:, 0], lw=2)
848866
plt.xlabel('t')
849867
plt.ylabel('-D/K')
850868
plt.show()
@@ -878,6 +896,12 @@ But now the cut lasts for one period only: the government sets $G_0 = 0$ and ret
878896
From $t \geq 1$, government expenditures return to $\hat{G}$ and $\tau_t$ adjusts to maintain the asset level $-D_t = -D_1$.
879897
880898
```{code-cell} ipython3
899+
---
900+
mystnb:
901+
figure:
902+
caption: Transition after a temporary expenditure cut
903+
name: ak2_exp3_temporary_cut
904+
---
881905
# sequence of government purchase
882906
G_seq = τ_hat * Y_hat * np.ones(T+1)
883907
G_seq[0] = 0
@@ -1059,11 +1083,11 @@ class AK2():
10591083
if verbose:
10601084
# plot current prices at ith iteration
10611085
for i, name in enumerate(['W', 'r']):
1062-
axs[i].plot(range(T+1), price_seq[:T+1, i])
1086+
axs[i].plot(range(T+1), price_seq[:T+1, i], lw=2)
10631087
axs[i].set_title(name)
10641088
axs[i].set_xlabel('t')
10651089
axs[2].plot(range(T+1), policy_seq[:T+1, 0],
1066-
label=f'{i_iter}th iteration')
1090+
label=f'{i_iter}th iteration', lw=2)
10671091
axs[2].legend(bbox_to_anchor=(1.05, 1), loc='upper left')
10681092
axs[2].set_title('τ')
10691093
axs[2].set_xlabel('t')
@@ -1141,23 +1165,23 @@ class AK2():
11411165
# quantities
11421166
for i, name in enumerate(['K', 'Y', 'Cy', 'Co']):
11431167
ax = axs[i//3, i%3]
1144-
ax.plot(range(T+1), quant_seq[:T+1, i], label=name)
1168+
ax.plot(range(T+1), quant_seq[:T+1, i], label=name, lw=2)
11451169
ax.hlines(init_ss[i], 0, T+1, color='r', linestyle='--')
11461170
ax.legend()
11471171
ax.set_xlabel('t')
11481172
11491173
# prices
11501174
for i, name in enumerate(['W', 'r']):
11511175
ax = axs[(i+4)//3, (i+4)%3]
1152-
ax.plot(range(T+1), price_seq[:T+1, i], label=name)
1176+
ax.plot(range(T+1), price_seq[:T+1, i], label=name, lw=2)
11531177
ax.hlines(init_ss[i+4], 0, T+1, color='r', linestyle='--')
11541178
ax.legend()
11551179
ax.set_xlabel('t')
11561180
11571181
# policies
11581182
for i, name in enumerate(['τ', 'D', 'G']):
11591183
ax = axs[(i+6)//3, (i+6)%3]
1160-
ax.plot(range(T+1), policy_seq[:T+1, i], label=name)
1184+
ax.plot(range(T+1), policy_seq[:T+1, i], label=name, lw=2)
11611185
ax.hlines(init_ss[i+6], 0, T+1, color='r', linestyle='--')
11621186
ax.legend()
11631187
ax.set_xlabel('t')
@@ -1186,13 +1210,25 @@ D_pol[1:] = D1
11861210
```
11871211
11881212
```{code-cell} ipython3
1213+
---
1214+
mystnb:
1215+
figure:
1216+
caption: Price iterations of the fixed point algorithm
1217+
name: ak2_fixed_point_iterations
1218+
---
11891219
quant_seq3, price_seq3, policy_seq3 = ak2.simulate(T, init_ss,
11901220
δy_seq, δo_seq,
11911221
D_pol=D_pol, G_pol=G_pol,
11921222
verbose=True)
11931223
```
11941224
11951225
```{code-cell} ipython3
1226+
---
1227+
mystnb:
1228+
figure:
1229+
caption: Tax cut transition computed with AK2
1230+
name: ak2_exp1_ak2
1231+
---
11961232
ak2.plot()
11971233
```
11981234
@@ -1215,31 +1251,37 @@ quant_seq4, price_seq4, policy_seq4 = ak2.simulate(T, init_ss,
12151251
Note how "crowding out" has been mitigated.
12161252
12171253
```{code-cell} ipython3
1254+
---
1255+
mystnb:
1256+
figure:
1257+
caption: Transitions with and without lump sum taxes
1258+
name: ak2_exp1_lump_sum
1259+
---
12181260
fig, axs = plt.subplots(3, 3, figsize=(14, 10))
12191261
12201262
# quantities
12211263
for i, name in enumerate(['K', 'Y', 'Cy', 'Co']):
12221264
ax = axs[i//3, i%3]
1223-
ax.plot(range(T+1), quant_seq3[:T+1, i], label=rf'{name}, $\delta$s=0')
1224-
ax.plot(range(T+1), quant_seq4[:T+1, i], label=rf'{name}, $\delta$s=0.005')
1265+
ax.plot(range(T+1), quant_seq3[:T+1, i], label=rf'{name}, $\delta$s=0', lw=2)
1266+
ax.plot(range(T+1), quant_seq4[:T+1, i], label=rf'{name}, $\delta$s=0.005', lw=2)
12251267
ax.hlines(init_ss[i], 0, T+1, color='r', linestyle='--')
12261268
ax.legend()
12271269
ax.set_xlabel('t')
12281270
12291271
# prices
12301272
for i, name in enumerate(['W', 'r']):
12311273
ax = axs[(i+4)//3, (i+4)%3]
1232-
ax.plot(range(T+1), price_seq3[:T+1, i], label=rf'{name}, $\delta$s=0')
1233-
ax.plot(range(T+1), price_seq4[:T+1, i], label=rf'{name}, $\delta$s=0.005')
1274+
ax.plot(range(T+1), price_seq3[:T+1, i], label=rf'{name}, $\delta$s=0', lw=2)
1275+
ax.plot(range(T+1), price_seq4[:T+1, i], label=rf'{name}, $\delta$s=0.005', lw=2)
12341276
ax.hlines(init_ss[i+4], 0, T+1, color='r', linestyle='--')
12351277
ax.legend()
12361278
ax.set_xlabel('t')
12371279
12381280
# policies
12391281
for i, name in enumerate(['τ', 'D', 'G']):
12401282
ax = axs[(i+6)//3, (i+6)%3]
1241-
ax.plot(range(T+1), policy_seq3[:T+1, i], label=rf'{name}, $\delta$s=0')
1242-
ax.plot(range(T+1), policy_seq4[:T+1, i], label=rf'{name}, $\delta$s=0.005')
1283+
ax.plot(range(T+1), policy_seq3[:T+1, i], label=rf'{name}, $\delta$s=0', lw=2)
1284+
ax.plot(range(T+1), policy_seq4[:T+1, i], label=rf'{name}, $\delta$s=0.005', lw=2)
12431285
ax.hlines(init_ss[i+6], 0, T+1, color='r', linestyle='--')
12441286
ax.legend()
12451287
ax.set_xlabel('t')
@@ -1281,31 +1323,37 @@ quant_seq5, price_seq5, policy_seq5 = ak2.simulate(T, init_ss,
12811323
```
12821324
12831325
```{code-cell} ipython3
1326+
---
1327+
mystnb:
1328+
figure:
1329+
caption: Tax cut versus social security transfer
1330+
name: ak2_exp4_social_security
1331+
---
12841332
fig, axs = plt.subplots(3, 3, figsize=(14, 10))
12851333
12861334
# quantities
12871335
for i, name in enumerate(['K', 'Y', 'Cy', 'Co']):
12881336
ax = axs[i//3, i%3]
1289-
ax.plot(range(T+1), quant_seq3[:T+1, i], label=f'{name}, tax cut')
1290-
ax.plot(range(T+1), quant_seq5[:T+1, i], label=f'{name}, transfer')
1337+
ax.plot(range(T+1), quant_seq3[:T+1, i], label=f'{name}, tax cut', lw=2)
1338+
ax.plot(range(T+1), quant_seq5[:T+1, i], label=f'{name}, transfer', lw=2)
12911339
ax.hlines(init_ss[i], 0, T+1, color='r', linestyle='--')
12921340
ax.legend()
12931341
ax.set_xlabel('t')
12941342
12951343
# prices
12961344
for i, name in enumerate(['W', 'r']):
12971345
ax = axs[(i+4)//3, (i+4)%3]
1298-
ax.plot(range(T+1), price_seq3[:T+1, i], label=f'{name}, tax cut')
1299-
ax.plot(range(T+1), price_seq5[:T+1, i], label=f'{name}, transfer')
1346+
ax.plot(range(T+1), price_seq3[:T+1, i], label=f'{name}, tax cut', lw=2)
1347+
ax.plot(range(T+1), price_seq5[:T+1, i], label=f'{name}, transfer', lw=2)
13001348
ax.hlines(init_ss[i+4], 0, T+1, color='r', linestyle='--')
13011349
ax.legend()
13021350
ax.set_xlabel('t')
13031351
13041352
# policies
13051353
for i, name in enumerate(['τ', 'D', 'G']):
13061354
ax = axs[(i+6)//3, (i+6)%3]
1307-
ax.plot(range(T+1), policy_seq3[:T+1, i], label=f'{name}, tax cut')
1308-
ax.plot(range(T+1), policy_seq5[:T+1, i], label=f'{name}, transfer')
1355+
ax.plot(range(T+1), policy_seq3[:T+1, i], label=f'{name}, tax cut', lw=2)
1356+
ax.plot(range(T+1), policy_seq5[:T+1, i], label=f'{name}, transfer', lw=2)
13091357
ax.hlines(init_ss[i+6], 0, T+1, color='r', linestyle='--')
13101358
ax.legend()
13111359
ax.set_xlabel('t')

0 commit comments

Comments
 (0)