Skip to content

Commit 33d8f79

Browse files
committed
add_plot
1 parent f39311a commit 33d8f79

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

lectures/olg.md

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ kernelspec:
1111
name: python3
1212
---
1313

14-
15-
1614
# The Overlapping Generations Model
1715

1816
In this lecture we study the overlapping generations (OLG) model.
@@ -58,8 +56,6 @@ import matplotlib.pyplot as plt
5856
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
5957
```
6058

61-
62-
6359
## Environment
6460

6561
TODO add timing and basic ideas of OLG
@@ -361,8 +357,6 @@ R_star, K_star = E_star
361357
plot_ad_as(aggregate_capital_demand, aggregate_capital_supply, m, K_prev=50, E_star=E_star)
362358
```
363359

364-
365-
366360
Let's observe the dynamics of the equilibrium price $R^*_{t+1}$.
367361

368362
```{code-cell} ipython3
@@ -378,8 +372,6 @@ ax.set_xlabel("$K_{t}$")
378372
plt.show()
379373
```
380374

381-
382-
383375
## Dynamics and steady state
384376

385377
Let $k_t := K_t / L$.
@@ -444,7 +436,7 @@ def plot_45(m, k_update, kstar=None):
444436
ymin, ymax = np.min(k_grid_next), np.max(k_grid_next)
445437
446438
ax.plot(k_grid, k_grid_next, lw=2, alpha=0.6, label='$g$')
447-
ax.plot(k_grid, k_grid, 'k-', lw=1, alpha=0.7, label='45')
439+
ax.plot(k_grid, k_grid, 'k-', lw=1, alpha=0.7, label='$45^{\circ}$')
448440
449441
if kstar:
450442
fps = (kstar,)
@@ -480,8 +472,6 @@ def k_star(model):
480472
plot_45(m, k_update, kstar=k_star(m))
481473
```
482474

483-
484-
485475
## Another special case: CRRA preference
486476

487477

@@ -497,8 +487,6 @@ def crra(c, γ=0.5):
497487
m_crra = create_olg_model(u=crra, u_params={'γ': 0.5})
498488
```
499489

500-
501-
502490
### New aggregate supply
503491

504492

@@ -570,8 +558,6 @@ def aggregate_supply_capital_crra(R, model, K_prev):
570558
plot_ad_as(aggregate_capital_demand, aggregate_supply_capital_crra, m_crra, K_prev=50, E_star=None) # John this is to be fixed.
571559
```
572560

573-
574-
575561
Let's plot the aggregate supply with different values of utility parameter $\gamma$ and observe it's behaviour.
576562

577563
```{code-cell} ipython3
@@ -593,8 +579,6 @@ ax.legend()
593579
plt.show()
594580
```
595581

596-
597-
598582
When $\gamma <1$ the supply curve is downward sloping. When $\gamma > 1$ the supply curve is upward sloping.
599583

600584
TODO: Do we need to add some explanation?
@@ -657,8 +641,6 @@ def f(k_prime, k, model):
657641
return p - z
658642
```
659643

660-
661-
662644
Let's define a function `k_next` that finds the value of $k_{t+1}$.
663645

664646
```{code-cell} ipython3
@@ -670,8 +652,6 @@ def k_next(k_prime, model):
670652
plot_45(m_crra, k_next, kstar=None)
671653
```
672654

673-
674-
675655
Unlike the log preference case now a steady state cannot be solved analytically.
676656

677657
To see this recall that, a steady state can be obtained by setting [](law_of_motion_capital_crra) to $k_{t+1} = k_t = k^*$, i.e.,
@@ -709,8 +689,6 @@ print(f"k_star = {k_star}")
709689
plot_45(m_crra, k_next, k_star)
710690
```
711691

712-
713-
714692
The next figure shows three time paths for capital, from
715693
three distinct initial conditions, under the parameterization listed above.
716694

@@ -752,8 +730,6 @@ def simulate_ts(m, x0_values, ts_length):
752730
simulate_ts(m_crra, x0, ts_length)
753731
```
754732

755-
756-
757733
## Exercises
758734

759735

@@ -795,8 +771,6 @@ def find_Kstar(R_star, model):
795771
return model.L * (R_star / model.α)**(1/(model.α-1))
796772
```
797773

798-
799-
800774
The following function plots the equilibrium quantity and equilibrium price.
801775

802776
```{code-cell} ipython3
@@ -837,8 +811,6 @@ m_crra = create_olg_model(u=crra, u_params={'γ': 0.5})
837811
plot_ks_rs(K_t_vals, m_crra)
838812
```
839813

840-
841-
842814
```{solution-end}
843815
```
844816

@@ -885,8 +857,6 @@ def u_quasilinear(c, θ=3):
885857
return c + c**θ
886858
```
887859

888-
889-
890860
The function `find_k_next` is used to find $k_{t+1}$ by finding
891861
the root of equation [](euler_quasilinear1) using the helper
892862
function `solve_for_k_next` for a given value of $k_t$.
@@ -923,8 +893,6 @@ def find_k_star_q(model):
923893
# return optimize.newton(solve_for_k_star_q, 0.2, args=(model,))
924894
```
925895

926-
927-
928896
Let's simulate and plot the time path capital $\{k_t\}$.
929897

930898
```{code-cell} ipython3
@@ -959,5 +927,9 @@ m_quasilinear = create_olg_model(u=u_quasilinear, u_params={'θ': 3})
959927
simulate_ts(k0_values, m_quasilinear)
960928
```
961929

930+
```{code-cell} ipython3
931+
plot_45(m_quasilinear, find_k_next, kstar=None)
932+
```
933+
962934
```{solution-end}
963935
```

0 commit comments

Comments
 (0)