Skip to content

Commit 848ba34

Browse files
committed
revert changes but add stylesheet compliance enforcement
1 parent b93204b commit 848ba34

File tree

1 file changed

+75
-101
lines changed

1 file changed

+75
-101
lines changed

lectures/mccall_model_with_separation.md

Lines changed: 75 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.17.3
7+
jupytext_version: 1.17.2
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
@@ -34,7 +34,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
3434
```{code-cell} ipython3
3535
:tags: [hide-output]
3636
37-
!pip install quantecon
37+
!pip install quantecon jax myst-nb
3838
```
3939

4040
## Overview
@@ -65,7 +65,7 @@ from quantecon.distributions import BetaBinomial
6565
from myst_nb import glue
6666
```
6767

68-
## The Model
68+
## The model
6969

7070
The model is similar to the {doc}`baseline McCall job search model <mccall_model>`.
7171

@@ -94,7 +94,7 @@ Wage offers $\{ W_t \}$ are IID with common distribution $q$.
9494

9595
The set of possible wage values is denoted by $\mathbb W$.
9696

97-
### Timing and Decisions
97+
### Timing and decisions
9898

9999
At the start of each period, the agent can be either
100100

@@ -118,7 +118,7 @@ The process then repeats.
118118
We do not allow for job search while employed---this topic is taken up in a {doc}`later lecture <jv>`.
119119
```
120120

121-
## Solving the Model
121+
## Solving the model
122122

123123
We drop time subscripts in what follows and primes denote next period values.
124124

@@ -135,7 +135,7 @@ the worker makes optimal decisions at all future points in time.
135135
As we now show, obtaining these functions is key to solving the model.
136136

137137

138-
### The Bellman Equations
138+
### The Bellman equations
139139

140140
We recall that, in {doc}`the original job search model <mccall_model>`, the
141141
value function (the value of being unemployed with a given wage offer) satisfied
@@ -200,7 +200,7 @@ enough information to solve for both $v_e$ and $v_u$.
200200
Once we have them in hand, we will be able to make optimal choices.
201201

202202

203-
### The Reservation Wage
203+
### The reservation wage
204204

205205

206206
Let
@@ -234,7 +234,7 @@ Let's now implement a solution method based on the two Bellman equations
234234
{eq}`bell2_mccall` and {eq}`bell1_mccall`.
235235

236236

237-
### Set Up
237+
### Set up
238238

239239
The default utility function is a CRRA utility function
240240

@@ -266,6 +266,7 @@ class Model(NamedTuple):
266266
q: jnp.ndarray = q_default # probabilities over wage offers
267267
```
268268

269+
269270
### Operators
270271

271272
We'll use a similar iterative approach to solving the Bellman equations that we
@@ -298,6 +299,7 @@ def T_e(model, v_u, v_e):
298299
return v_e_new
299300
```
300301

302+
301303
### Iteration
302304

303305
Now we write an iteration routine, which updates the pair of arrays $v_u$, $v_e$ until convergence.
@@ -308,8 +310,8 @@ than some small tolerance level.
308310
```{code-cell} ipython3
309311
def solve_full_model(
310312
model,
311-
tol: float=1e-6,
312-
max_iter: int=1_000,
313+
tol: float = 1e-6,
314+
max_iter: int = 1_000,
313315
):
314316
"""
315317
Solves for both value functions v_u and v_e iteratively.
@@ -333,7 +335,9 @@ def solve_full_model(
333335
return v_u, v_e
334336
```
335337

336-
### Computing the Reservation Wage
338+
339+
340+
### Computing the reservation wage
337341

338342
Now that we can solve for both value functions, let's investigate the reservation wage.
339343

@@ -386,7 +390,7 @@ This value seems close to where the two lines meet.
386390

387391

388392
(ast_mcm)=
389-
## A Simplifying Transformation
393+
## A simplifying transformation
390394

391395
The approach above works, but iterating over two vector-valued functions is computationally expensive.
392396

@@ -424,7 +428,7 @@ useful.
424428
But we can go further, but eliminating $v_e$ from the above equation.
425429

426430

427-
### Simplifying to a Single Equation
431+
### Simplifying to a single equation
428432

429433
As a first step, we rearrange the expression defining $h$ (see {eq}`defh_mm`) to obtain
430434

@@ -481,7 +485,7 @@ If we can solve this for $h$, we can easily recover $v_e$ using
481485
Then we have enough information to compute the reservation wage.
482486

483487

484-
### Solving the Bellman Equations
488+
### Solving the Bellman equations
485489

486490
To solve {eq}`bell_scalar`, we use the iteration rule
487491

@@ -591,141 +595,119 @@ However, the simplified method is far more efficient.
591595
Next we will investigate how the reservation wage varies with parameters.
592596

593597

594-
## Impact of Parameters
598+
## Impact of parameters
595599

596-
In each instance below, we'll investigate how the reservation wage $\bar w$ varies
597-
with a particular parameter of interest, holding the other parameters fixed at their default values.
600+
In each instance below, we'll show you a figure and then ask you to reproduce it in the exercises.
598601

599-
### The Reservation Wage and Unemployment Compensation
602+
### The reservation wage and unemployment compensation
600603

601604
First, let's look at how $\bar w$ varies with unemployment compensation.
602605

603-
In the exercise below, we use the default parameters in the `Model` class, apart from
604-
$c$ (which takes the values given on the horizontal axis).
606+
In the figure below, we use the default parameters in the `Model` class, apart from
607+
c (which takes the values given on the horizontal axis)
608+
609+
```{glue:figure} mccall_resw_c
610+
:figwidth: 600px
605611
606-
```{exercise-start}
607-
:label: mmws_ex1
608612
```
609613

610-
Generate a figure showing how $\bar w$ varies with unemployment compensation $c$.
614+
As expected, higher unemployment compensation causes the worker to hold out for higher wages.
611615

612-
Use the following values for unemployment compensation on the horizontal axis:
616+
In effect, the cost of continuing job search is reduced.
613617

614-
```{code-cell} ipython3
615-
grid_size = 25
616-
c_vals = jnp.linspace(2, 12, grid_size) # unemployment compensation
617-
```
618+
### The reservation wage and discounting
618619

619-
Interpret the results.
620+
Next, let's investigate how $\bar w$ varies with the discount factor.
620621

621-
```{exercise-end}
622-
```
622+
The next figure plots the reservation wage associated with different values of
623+
$\beta$
624+
625+
```{glue:figure} mccall_resw_beta
626+
:figwidth: 600px
623627
624-
```{solution-start} mmws_ex1
625-
:class: dropdown
626628
```
627629

628-
```{code-cell} ipython3
629-
def compute_res_wage_given_c(c):
630-
model = Model(c=c)
631-
w_bar = compute_reservation_wage(model)
632-
return w_bar
630+
Again, the results are intuitive: More patient workers will hold out for higher wages.
633631

634-
w_bar_vals = jax.vmap(compute_res_wage_given_c)(c_vals)
632+
### The reservation wage and job destruction
635633

636-
fig, ax = plt.subplots()
637-
ax.set(xlabel='unemployment compensation', ylabel='reservation wage')
638-
ax.plot(c_vals, w_bar_vals, label=r'$\bar w$ as a function of $c$')
639-
ax.legend()
640-
glue("mccall_resw_c", fig, display=False)
641-
plt.show()
642-
```
634+
Finally, let's look at how $\bar w$ varies with the job separation rate $\alpha$.
643635

644-
As expected, higher unemployment compensation causes the worker to hold out for higher wages.
636+
Higher $\alpha$ translates to a greater chance that a worker will face termination in each period once employed.
645637

646-
In effect, the cost of continuing job search is reduced.
638+
```{glue:figure} mccall_resw_alpha
639+
:figwidth: 600px
647640
648-
```{solution-end}
649641
```
650642

651-
### The Reservation Wage and Discounting
643+
Once more, the results are in line with our intuition.
652644

653-
Next, let's investigate how $\bar w$ varies with the discount factor.
645+
If the separation rate is high, then the benefit of holding out for a higher wage falls.
654646

655-
The next exercise considers the reservation wage associated with different values of
656-
$\beta$.
647+
Hence the reservation wage is lower.
648+
649+
## Exercises
657650

658651
```{exercise-start}
659-
:label: mmws_ex2
652+
:label: mmws_ex1
660653
```
661654

662-
Generate a figure showing how $\bar w$ varies with the discount factor $\beta$.
655+
Reproduce all the reservation wage figures shown above.
663656

664-
Use the following values for the discount factor on the horizontal axis:
657+
Regarding the values on the horizontal axis, use
665658

666659
```{code-cell} ipython3
667660
grid_size = 25
661+
c_vals = jnp.linspace(2, 12, grid_size) # unemployment compensation
668662
β_vals = jnp.linspace(0.8, 0.99, grid_size) # discount factors
663+
α_vals = jnp.linspace(0.05, 0.5, grid_size) # separation rate
669664
```
670665

671-
Interpret the results.
672-
673666
```{exercise-end}
674667
```
675668

676-
```{solution-start} mmws_ex2
669+
```{solution-start} mmws_ex1
677670
:class: dropdown
678671
```
679672

673+
Here's the first figure.
674+
680675
```{code-cell} ipython3
681-
def compute_res_wage_given_beta(β):
682-
model = Model(β=β)
676+
def compute_res_wage_given_c(c):
677+
model = Model(c=c)
683678
w_bar = compute_reservation_wage(model)
684679
return w_bar
685680
686-
w_bar_vals = jax.vmap(compute_res_wage_given_beta)(β_vals)
681+
w_bar_vals = jax.vmap(compute_res_wage_given_c)(c_vals)
687682
688683
fig, ax = plt.subplots()
689-
ax.set(xlabel='discount factor', ylabel='reservation wage')
690-
ax.plot(β_vals, w_bar_vals, label=r'$\bar w$ as a function of $\beta$')
684+
ax.set(xlabel='unemployment compensation', ylabel='reservation wage')
685+
ax.plot(c_vals, w_bar_vals, lw=2, label=r'$\bar w$ as a function of $c$')
691686
ax.legend()
692-
glue("mccall_resw_beta", fig, display=False)
687+
glue("mccall_resw_c", fig, display=False)
693688
plt.show()
694689
```
695690

696-
Again, the results are intuitive: More patient workers will hold out for higher wages.
697-
698-
699-
```{solution-end}
700-
```
701-
702-
### The Reservation Wage and Job Destruction
703-
704-
Finally, let's look at how $\bar w$ varies with the job separation rate $\alpha$.
705-
706-
Higher $\alpha$ translates to a greater chance that a worker will face termination in each period once employed.
707-
708-
```{exercise-start}
709-
:label: mmws_ex3
710-
```
711-
712-
Generate a figure showing how $\bar w$ varies with the separation rate $\alpha$.
713-
714-
Use the following values for the separation rate on the horizontal axis:
691+
Here's the second one.
715692

716693
```{code-cell} ipython3
717-
grid_size = 25
718-
α_vals = jnp.linspace(0.05, 0.5, grid_size) # separation rate
719-
```
694+
def compute_res_wage_given_beta(β):
695+
model = Model(β=β)
696+
w_bar = compute_reservation_wage(model)
697+
return w_bar
720698
721-
Interpret the results.
722-
```{exercise-end}
723-
```
699+
w_bar_vals = jax.vmap(compute_res_wage_given_beta)(β_vals)
724700
725-
```{solution-start} mmws_ex3
726-
:class: dropdown
701+
fig, ax = plt.subplots()
702+
ax.set(xlabel='discount factor', ylabel='reservation wage')
703+
ax.plot(β_vals, w_bar_vals, lw=2, label=r'$\bar w$ as a function of $\beta$')
704+
ax.legend()
705+
glue("mccall_resw_beta", fig, display=False)
706+
plt.show()
727707
```
728708

709+
Here's the third.
710+
729711
```{code-cell} ipython3
730712
def compute_res_wage_given_alpha(α):
731713
model = Model(α=α)
@@ -736,19 +718,11 @@ w_bar_vals = jax.vmap(compute_res_wage_given_alpha)(α_vals)
736718
737719
fig, ax = plt.subplots()
738720
ax.set(xlabel='separation rate', ylabel='reservation wage')
739-
ax.plot(α_vals, w_bar_vals, label=r'$\bar w$ as a function of $\alpha$')
721+
ax.plot(α_vals, w_bar_vals, lw=2, label=r'$\bar w$ as a function of $\alpha$')
740722
ax.legend()
741723
glue("mccall_resw_alpha", fig, display=False)
742724
plt.show()
743725
```
744726

745-
746-
Once more, the results are in line with our intuition.
747-
748-
If the separation rate is high, then the benefit of holding out for a higher wage falls.
749-
750-
Hence the reservation wage is lower.
751-
752-
753727
```{solution-end}
754728
```

0 commit comments

Comments
 (0)