Skip to content

Commit 1c7689a

Browse files
shlffSmit-create
authored andcommitted
fix_way1
1 parent 470e8c5 commit 1c7689a

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

lectures/olg.md

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ kernelspec:
1111
name: python3
1212
---
1313

14-
1514
# The Overlapping Generations Model
1615

1716
In this lecture we study the overlapping generations (OLG) model.
@@ -57,7 +56,6 @@ import matplotlib.pyplot as plt
5756
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
5857
```
5958

60-
6159
## Environment
6260

6361
TODO add timing and basic ideas of OLG
@@ -359,7 +357,6 @@ R_star, K_star = E_star
359357
plot_ad_as(aggregate_capital_demand, aggregate_capital_supply, m, K_prev=50, E_star=E_star)
360358
```
361359

362-
363360
Let's observe the dynamics of the equilibrium price $R^*_{t+1}$.
364361

365362
```{code-cell} ipython3
@@ -375,7 +372,6 @@ ax.set_xlabel("$K_{t}$")
375372
plt.show()
376373
```
377374

378-
379375
## Dynamics and steady state
380376

381377
Let $k_t := K_t / L$.
@@ -476,7 +472,6 @@ def k_star(model):
476472
plot_45(m, k_update, kstar=k_star(m))
477473
```
478474

479-
480475
## Another special case: CRRA preference
481476

482477

@@ -563,7 +558,6 @@ def aggregate_supply_capital_crra(R, model, K_prev):
563558
plot_ad_as(aggregate_capital_demand, aggregate_supply_capital_crra, m_crra, K_prev=50, E_star=None) # John this is to be fixed.
564559
```
565560

566-
567561
Let's plot the aggregate supply with different values of utility parameter $\gamma$ and observe it's behaviour.
568562

569563
```{code-cell} ipython3
@@ -585,7 +579,6 @@ ax.legend()
585579
plt.show()
586580
```
587581

588-
589582
When $\gamma <1$ the supply curve is downward sloping. When $\gamma > 1$ the supply curve is upward sloping.
590583

591584
TODO: Do we need to add some explanation?
@@ -649,7 +642,6 @@ def f(k_prime, k, model):
649642
return p - z
650643
```
651644

652-
653645
Let's define a function `k_next` that finds the value of $k_{t+1}$.
654646

655647
```{code-cell} ipython3
@@ -661,7 +653,6 @@ def k_next(k_prime, model):
661653
plot_45(m_crra, k_next, kstar=None)
662654
```
663655

664-
665656
Unlike the log preference case now a steady state cannot be solved analytically.
666657

667658
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.,
@@ -699,7 +690,6 @@ print(f"k_star = {k_star}")
699690
plot_45(m_crra, k_next, k_star)
700691
```
701692

702-
703693
The next figure shows three time paths for capital, from
704694
three distinct initial conditions, under the parameterization listed above.
705695

@@ -741,7 +731,6 @@ def simulate_ts(m, x0_values, ts_length):
741731
simulate_ts(m_crra, x0, ts_length)
742732
```
743733

744-
745734
## Exercises
746735

747736

@@ -783,7 +772,6 @@ def find_Kstar(R_star, model):
783772
return model.L * (R_star / model.α)**(1/(model.α-1))
784773
```
785774

786-
787775
The following function plots the equilibrium quantity and equilibrium price.
788776

789777
```{code-cell} ipython3
@@ -810,7 +798,9 @@ def plot_ks_rs(K_t_vals, model):
810798
---
811799
mystnb:
812800
figure:
813-
caption: "Equilibrium price and quantity\n"
801+
caption: 'Equilibrium price and quantity
802+
803+
'
814804
name: equi_ps_q_crra
815805
image:
816806
alt: equi_ps_q_crra
@@ -822,14 +812,13 @@ m_crra = create_olg_model(u=crra, u_params={'γ': 0.5})
822812
plot_ks_rs(K_t_vals, m_crra)
823813
```
824814

825-
826815
```{solution-end}
827816
```
828817

829818
```{exercise}
830819
:label: olg_ex2
831820
832-
Let's keep the model the same except for replacing the utility function $u(c)$ in {eq}`eq_crra` with a quasilinear form $u(c)=c + c^{\theta}$.
821+
Let's keep the model the same except for replacing the utility function $u(c)$ in {eq}`eq_crra` with a nonlinear form $u(c)=c + c^{\theta}$.
833822
834823
Like what we did in the CRRA case we don't have an analytical solution.
835824
@@ -842,7 +831,7 @@ Try to compute the time path capital $\{k_t\}$ in this case.
842831

843832
To get the time path capital $\{k_t\}$ first we need to solve the household's utility maximization problem for the optimal consumption and optimal saving.
844833

845-
With the quasilinear preference the Euler equation becomes
834+
With the quasilinear preference the Euler equation [](euler_2_olg) becomes
846835

847836
```{math}
848837
:label: euler_quasilinear
@@ -855,7 +844,7 @@ Since [](aggregate_supply_capital_log_olg), [](wage_2) and [](interest_rate_2) t
855844

856845
```{math}
857846
:label: euler_quasilinear1
858-
1 + \theta ((1-\alpha)k^{\alpha}_t - k_{t+1})^{\theta-1} = \beta \alpha k^{\alpha - 1}_t + \beta (\alpha k^{\alpha - 1}_t)^{\theta} \theta k_{t+1}^{\theta - 1}
847+
1 + \theta ((1-\alpha)k^{\alpha}_t - k_{t+1})^{\theta-1} = \beta \alpha k^{\alpha - 1}_{t+1} + \beta \theta \alpha^{\theta} k^{\alpha \theta - 1}_{t+1}
859848
```
860849

861850
Obviously $k_{t+1}$ cannot be solved by pencil and paper.
@@ -865,11 +854,10 @@ To solve for $k_{t+1}$ we need to turn to the newton's method.
865854
Let's start by defining the utility function.
866855

867856
```{code-cell} ipython3
868-
def u_quasilinear(c, θ=4):
857+
def u_quasilinear(c, θ=6):
869858
return c + c**θ
870859
```
871860

872-
873861
The function `find_k_next` is used to find $k_{t+1}$ by finding
874862
the root of equation [](euler_quasilinear1) using the helper
875863
function `solve_for_k_next` for a given value of $k_t$.
@@ -878,8 +866,8 @@ function `solve_for_k_next` for a given value of $k_t$.
878866
def solve_for_k_next(x, k_t, model):
879867
α, β, L, θ = model.α, model.β, model.L, model.u_params['θ']
880868
l = 1 + θ * ((1 - α) * k_t**α - x)**(θ - 1)
881-
r = β * α * k_t**(α - 1)
882-
r += β * * k_t**(α - 1))**θ * θ * x**(θ - 1)
869+
r = β * α * x**(α - 1)
870+
r += β * θ * α**θ * x**(α * θ - 1)
883871
return l - r
884872
```
885873

@@ -893,15 +881,13 @@ def solve_for_k_star_q(x, model):
893881
α, β, L, θ = model.α, model.β, model.L, model.u_params['θ']
894882
l = 1 + θ * ((1 - α) * x**α - x)**(θ - 1)
895883
r = β * α * x**(α - 1)
896-
r += β * * x**(α - 1))**θ * θ * x**(θ - 1)
884+
r += β * θ * α**θ * x**(α * θ - 1)
897885
return l - r
898886
899887
def find_k_star_q(model):
900888
return optimize.newton(solve_for_k_star_q, 0.3, args=(model,))
901-
902889
```
903890

904-
905891
Let's simulate and plot the time path capital $\{k_t\}$.
906892

907893
```{code-cell} ipython3
@@ -932,9 +918,14 @@ def simulate_ts(k0_values, model, ts_length=10):
932918

933919
```{code-cell} ipython3
934920
k0_values = [0.2, 10, 50, 100]
935-
m_quasilinear = create_olg_model(u=u_quasilinear, u_params={'θ': 4})
921+
m_quasilinear = create_olg_model(u=u_quasilinear, u_params={'θ': 6})
936922
simulate_ts(k0_values, m_quasilinear)
937923
```
938924

939-
```{solution-end}
925+
```{code-cell} ipython3
926+
927+
```
928+
929+
```{code-cell} ipython3
930+
940931
```

0 commit comments

Comments
 (0)