Skip to content

Commit 84e0a2f

Browse files
committed
update feedback for the second section
1 parent 47286bd commit 84e0a2f

File tree

1 file changed

+57
-69
lines changed

1 file changed

+57
-69
lines changed

lectures/cagan_ree.md

Lines changed: 57 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ $$
296296
\mu_t = \mu^* , \quad t \geq T_1
297297
$$
298298
299-
so that, in terms of our notation and formula for $\theta_{T+1}^*$ above, $\tilde \gamma = 1$.
299+
so that, in terms of our notation and formula for $\pi_{T+1}^*$ above, $\tilde \gamma = 1$.
300300
301301
#### Experiment 1: Foreseen sudden stabilization
302302
@@ -464,7 +464,7 @@ path for $\pi_t$ has $\pi_t = \mu_0$.
464464
by setting $\mu_s = \mu^*$ for all $s \geq T_1$. The perfect foresight continuation path for
465465
$\pi$ is $\pi_s = \mu^*$
466466
467-
To capture a "completely unanticipated permanent shock to the $\{\mu\}$ process at time $T_1$, we simply glue the $\mu_t, \pi_t$
467+
To capture a "completely unanticipated permanent shock to the $\{\mu_t\}$ process at time $T_1$, we simply glue the $\mu_t, \pi_t$
468468
that emerges under path 2 for $t \geq T_1$ to the $\mu_t, \pi_t$ path that had emerged under path 1 for $ t=0, \ldots,
469469
T_1 -1$.
470470
@@ -482,6 +482,7 @@ are identical to those for experiment 1, the foreseen sudden stabilization.
482482
The following code does the calculations and plots outcomes.
483483
484484
```{code-cell} ipython3
485+
:tags: [hide-cell]
485486
# path 1
486487
μ_seq_2_path1 = μ0 * np.ones(T+1)
487488
@@ -522,44 +523,43 @@ T_seq = range(T+2)
522523
# plot both regimes
523524
fig, ax = plt.subplots(5, 1, figsize=[5, 12], dpi=200)
524525
525-
ax[0].plot(T_seq[:-1], μ_seq_2)
526-
ax[0].set_ylabel(r'$\mu$')
527-
528-
ax[1].plot(T_seq, π_seq_2)
529-
ax[1].set_ylabel(r'$\pi$')
530-
531-
ax[2].plot(T_seq, m_seq_2_regime1 - p_seq_2_regime1)
532-
ax[2].set_ylabel(r'$m - p$')
533-
534-
ax[3].plot(T_seq, m_seq_2_regime1,
535-
label='Smooth $m_{T_1}$')
536-
ax[3].plot(T_seq, m_seq_2_regime2,
537-
label='Jumpy $m_{T_1}$')
538-
ax[3].set_ylabel(r'$m$')
539-
540-
ax[4].plot(T_seq, p_seq_2_regime1,
541-
label='Smooth $m_{T_1}$')
542-
ax[4].plot(T_seq, p_seq_2_regime2,
543-
label='Jumpy $m_{T_1}$')
544-
ax[4].set_ylabel(r'$p$')
545-
546-
for i in range(5):
547-
ax[i].set_xlabel(r'$t$')
548-
549-
for i in [3, 4]:
550-
ax[i].legend()
526+
# Data configuration for each subplot
527+
plot_configs = [
528+
{'data': [(T_seq[:-1], μ_seq_2)], 'ylabel': r'$\mu$'},
529+
{'data': [(T_seq, π_seq_2)], 'ylabel': r'$\pi$'},
530+
{'data': [(T_seq, m_seq_2_regime1 - p_seq_2_regime1)],
531+
'ylabel': r'$m - p$'},
532+
{'data': [(T_seq, m_seq_2_regime1, 'Smooth $m_{T_1}$'),
533+
(T_seq, m_seq_2_regime2, 'Jumpy $m_{T_1}$')],
534+
'ylabel': r'$m$'},
535+
{'data': [(T_seq, p_seq_2_regime1, 'Smooth $p_{T_1}$'),
536+
(T_seq, p_seq_2_regime2, 'Jumpy $p_{T_1}$')],
537+
'ylabel': r'$p$'}
538+
]
539+
540+
# Loop through each subplot configuration
541+
for axi, config in zip(ax, plot_configs):
542+
for data in config['data']:
543+
if len(data) == 3: # Plot with label for legend
544+
axi.plot(data[0], data[1], label=data[2])
545+
else: # Plot without label
546+
axi.plot(data[0], data[1])
547+
axi.set_ylabel(config['ylabel'])
548+
axi.set_xlabel(r'$t$')
549+
if 'label' in config: # If there's a label, add a legend
550+
axi.legend()
551551
552552
plt.tight_layout()
553553
plt.show()
554554
```
555555
556556
We invite you to compare these graphs with corresponding ones for the foreseen stabilization analyzed in experiment 1 above.
557557
558-
Note how the inflation graph in the top middle panel is now identical to the
559-
money growth graph in the top left panel, and how now the log of real balances portrayed in the top right panel jumps upward at time $T_1$.
558+
Note how the inflation graph in the second panel is now identical to the
559+
money growth graph in the top panel, and how now the log of real balances portrayed in the third panel jumps upward at time $T_1$.
560560
561-
The bottom panels plot $m$ and $p$ under two possible ways that $m_{T_1}$ might adjust
562-
as required by the upward jump in $m - p$ at $T_1$.
561+
The bottom two panels plot $m$ and $p$ under two possible ways that $m_{T_1}$ might adjust
562+
as required by the upward jump in $m - p$ at $T_1$.
563563
564564
* the orange line lets $m_{T_1}$ jump upward in order to make sure that the log price level $p_{T_1}$ does not fall.
565565
@@ -578,43 +578,31 @@ unanticipated, as in experiment 2.
578578
# compare foreseen vs unforeseen shock
579579
fig, ax = plt.subplots(5, figsize=[5, 12], dpi=200)
580580
581-
ax[0].plot(T_seq[:-1], μ_seq_2)
582-
ax[0].set_ylabel(r'$\mu$')
583-
584-
ax[1].plot(T_seq, π_seq_2,
585-
label='Unforeseen')
586-
ax[1].plot(T_seq, π_seq_1,
587-
label='Foreseen', color='tab:green')
588-
ax[1].set_ylabel(r'$\pi$')
589-
590-
ax[2].plot(T_seq,
591-
m_seq_2_regime1 - p_seq_2_regime1,
592-
label='Unforeseen')
593-
ax[2].plot(T_seq, m_seq_1 - p_seq_1,
594-
label='Foreseen', color='tab:green')
595-
ax[2].set_ylabel(r'$m - p$')
596-
597-
ax[3].plot(T_seq, m_seq_2_regime1,
598-
label=r'Unforeseen (Smooth $m_{T_1}$)')
599-
ax[3].plot(T_seq, m_seq_2_regime2,
600-
label=r'Unforeseen ($m_{T_1}$ jumps)')
601-
ax[3].plot(T_seq, m_seq_1,
602-
label='Foreseen shock')
603-
ax[3].set_ylabel(r'$m$')
604-
605-
ax[4].plot(T_seq, p_seq_2_regime1,
606-
label=r'Unforeseen (Smooth $m_{T_1}$)')
607-
ax[4].plot(T_seq, p_seq_2_regime2,
608-
label=r'Unforeseen ($m_{T_1}$ jumps)')
609-
ax[4].plot(T_seq, p_seq_1,
610-
label='Foreseen')
611-
ax[4].set_ylabel(r'$p$')
612-
613-
for i in range(5):
614-
ax[i].set_xlabel(r'$t$')
615-
616-
for i in range(1, 5):
617-
ax[i].legend()
581+
plot_data = [
582+
(T_seq[:-1], [μ_seq_2], r'$\mu$', ['']),
583+
(T_seq, [π_seq_2, π_seq_1], r'$\pi$', ['Unforeseen', 'Foreseen']),
584+
(T_seq, [m_seq_2_regime1 - p_seq_2_regime1, m_seq_1 - p_seq_1],
585+
r'$m - p$', ['Unforeseen', 'Foreseen']),
586+
(T_seq, [m_seq_2_regime1, m_seq_2_regime2, m_seq_1], r'$m$',
587+
['Unforeseen (Smooth $m_{T_1}$)',
588+
'Unforeseen ($m_{T_1}$ jumps)',
589+
'Foreseen shock']),
590+
(T_seq, [p_seq_2_regime1, p_seq_2_regime2, p_seq_1], r'$p$',
591+
['Unforseen (Smooth $m_{T_1}$)',
592+
'Unforseen ($m_{T_1}$ jumps)',
593+
'Foreseen shock'])
594+
]
595+
596+
for i, (times, sequences, ylabel, labels) in enumerate(plot_data):
597+
for seq, label in zip(sequences, labels):
598+
ax[i].plot(times, seq, label=label)
599+
ax[i].set_ylabel(ylabel)
600+
if labels[0]:
601+
ax[i].legend()
602+
603+
# Set the x-axis label for all subplots
604+
for axis in ax:
605+
axis.set_xlabel(r'$t$')
618606
619607
plt.tight_layout()
620608
plt.show()

0 commit comments

Comments
 (0)