Skip to content

Commit ca9a267

Browse files
committed
update graphs for cons_smooth
1 parent 37f2951 commit ca9a267

File tree

2 files changed

+42
-33
lines changed

2 files changed

+42
-33
lines changed

lectures/cons_smooth.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.16.1
7+
jupytext_version: 1.16.4
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
1111
name: python3
1212
---
1313

14-
1514
# Consumption Smoothing
1615

1716
## Overview
@@ -47,7 +46,6 @@ import matplotlib.pyplot as plt
4746
from collections import namedtuple
4847
```
4948

50-
5149
The model describes a consumer who lives from time $t=0, 1, \ldots, T$, receives a stream $\{y_t\}_{t=0}^T$ of non-financial income and chooses a consumption stream $\{c_t\}_{t=0}^T$.
5250

5351
We usually think of the non-financial income stream as coming from the person's salary from supplying labor.
@@ -147,7 +145,6 @@ def create_consumption_smoothing_model(R=1.05, g1=1, g2=1/2, T=65):
147145
β_seq, T)
148146
```
149147
150-
151148
## Friedman-Hall consumption-smoothing model
152149
153150
A key object is what Milton Friedman called "human" or "non-financial" wealth at time $0$:
@@ -311,14 +308,19 @@ The graphs below show paths of non-financial income, consumption, and financia
311308
# Sequence Length
312309
T = cs_model.T
313310
314-
plt.plot(range(T+1), y_seq, label='non-financial income')
315-
plt.plot(range(T+1), c_seq, label='consumption')
316-
plt.plot(range(T+2), a_seq, label='financial wealth')
317-
plt.plot(range(T+2), np.zeros(T+2), '--')
311+
fig, axes = plt.subplots(1, 2, figsize=(12,5))
312+
313+
axes[0].plot(range(T+1), y_seq, label='non-financial income', lw=2)
314+
axes[0].plot(range(T+1), c_seq, label='consumption', lw=2)
315+
axes[1].plot(range(T+2), a_seq, label='financial wealth', color='green', lw=2)
316+
axes[0].set_ylabel(r'$c_t,y_t$')
317+
axes[1].set_ylabel(r'$a_t$')
318+
319+
for ax in axes:
320+
ax.plot(range(T+2), np.zeros(T+2), '--', lw=1, color='black')
321+
ax.legend()
322+
ax.set_xlabel(r'$t$')
318323
319-
plt.legend()
320-
plt.xlabel(r'$t$')
321-
plt.ylabel(r'$c_t,y_t,a_t$')
322324
plt.show()
323325
```
324326
@@ -353,18 +355,22 @@ def plot_cs(model, # consumption-smoothing model
353355
# Compute optimal consumption
354356
c_seq, a_seq, h0 = compute_optimal(model, a0, y_seq)
355357
356-
# Sequence length
358+
# Sequence Length
357359
T = cs_model.T
358360
359-
# Generate plot
360-
plt.plot(range(T+1), y_seq, label='non-financial income')
361-
plt.plot(range(T+1), c_seq, label='consumption')
362-
plt.plot(range(T+2), a_seq, label='financial wealth')
363-
plt.plot(range(T+2), np.zeros(T+2), '--')
361+
fig, axes = plt.subplots(1, 2, figsize=(12,5))
362+
363+
axes[0].plot(range(T+1), y_seq, label='non-financial income', lw=2)
364+
axes[0].plot(range(T+1), c_seq, label='consumption', lw=2)
365+
axes[1].plot(range(T+2), a_seq, label='financial wealth', color='green', lw=2)
366+
axes[0].set_ylabel(r'$c_t,y_t$')
367+
axes[1].set_ylabel(r'$a_t$')
368+
369+
for ax in axes:
370+
ax.plot(range(T+2), np.zeros(T+2), '--', lw=1, color='black')
371+
ax.legend()
372+
ax.set_xlabel(r'$t$')
364373
365-
plt.legend()
366-
plt.xlabel(r'$t$')
367-
plt.ylabel(r'$c_t,y_t,a_t$')
368374
plt.show()
369375
```
370376
@@ -419,7 +425,7 @@ Now we simulate a $y$ sequence in which a person gets zero for 46 years, and the
419425
```{code-cell} ipython3
420426
# Late starter
421427
y_seq_late = np.concatenate(
422-
[np.zeros(46), np.ones(20)])
428+
[np.ones(46), 2*np.ones(20)])
423429
424430
plot_cs(cs_model, a0, y_seq_late)
425431
```
@@ -461,14 +467,13 @@ What happens when $\lambda$ is negative
461467
```{code-cell} ipython3
462468
λ = -0.95
463469
464-
geo_seq = λ ** np.arange(t_max) * y_0
470+
geo_seq = λ ** np.arange(t_max) * y_0 + 1
465471
y_seq_geo = np.concatenate(
466-
[geo_seq, np.zeros(20)])
472+
[geo_seq, np.ones(20)])
467473
468474
plot_cs(cs_model, a0, y_seq_geo)
469475
```
470476
471-
472477
### Feasible consumption variations
473478
474479
We promised to justify our claim that a constant consumption play $c_t = c_0$ for all
@@ -554,7 +559,6 @@ def compute_variation(model, ξ1, ϕ, a0, y_seq, verbose=1):
554559
return cvar_seq
555560
```
556561
557-
558562
We visualize variations for $\xi_1 \in \{.01, .05\}$ and $\phi \in \{.95, 1.02\}$
559563
560564
```{code-cell} ipython3
@@ -591,7 +595,6 @@ plt.ylabel(r'$c_t$')
591595
plt.show()
592596
```
593597
594-
595598
We can even use the Python `np.gradient` command to compute derivatives of welfare with respect to our two parameters.
596599
597600
We are teaching the key idea beneath the **calculus of variations**.
@@ -615,7 +618,6 @@ def welfare_rel(ξ1, ϕ):
615618
welfare_vec = np.vectorize(welfare_rel)
616619
```
617620
618-
619621
Then we can visualize the relationship between welfare and $\xi_1$ and compute its derivatives
620622
621623
```{code-cell} ipython3
@@ -634,7 +636,6 @@ plt.xlabel(r'$\xi_1$')
634636
plt.show()
635637
```
636638
637-
638639
The same can be done on $\phi$
639640
640641
```{code-cell} ipython3
@@ -785,4 +786,4 @@ Multiplying both sides by inverse of the matrix on the left again provides the
785786
786787
As an exercise, we ask you to represent and solve a **third-order linear difference equation**.
787788
How many initial conditions must you specify?
788-
```
789+
```

lectures/tax_smooth.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,6 @@ for ax in axes:
329329
ax.legend()
330330
ax.set_xlabel(r'$t$')
331331
332-
333-
plt.xlabel(r'$t$')
334332
plt.show()
335333
```
336334
@@ -386,7 +384,6 @@ def plot_ts(model, # tax-smoothing model
386384
ax.set_xlabel(r'$t$')
387385
388386
389-
plt.xlabel(r'$t$')
390387
plt.show()
391388
```
392389
@@ -659,4 +656,15 @@ plt.plot(ξ1_arr, cost_grad)
659656
plt.ylabel('derivative of cost')
660657
plt.xlabel(r'$\phi$')
661658
plt.show()
662-
```
659+
```
660+
661+
<!-- ## Wrapping up the consumption-smoothing model
662+
663+
The consumption-smoothing model of Milton Friedman {cite}`Friedman1956` and Robert Hall {cite}`Hall1978`) is a cornerstone of modern macro that has important ramifications for the size of the Keynesian "fiscal policy multiplier" described briefly in
664+
QuantEcon lecture {doc}`geometric series <geom_series>`.
665+
666+
In particular, it **lowers** the government expenditure multiplier relative to one implied by
667+
the original Keynesian consumption function presented in {doc}`geometric series <geom_series>`.
668+
669+
Friedman's work opened the door to an enlightening literature on the aggregate consumption function and associated government expenditure multipliers that
670+
remains active today. -->

0 commit comments

Comments
 (0)