GitHub

@@ -101,14 +101,12 @@ At the start of each period, the agent can be either

101101

* unemployed or

102102

* employed at some existing wage level $w$.

103103104-

At the start of a given period, the current wage offer $w_t$ is observed.

104+

If currently employed at wage $w$, the worker

105105106-

If currently employed, the worker

106+

1. receives utility $u(w)$ from their current wage and

107+

1. is fired with some (small) probability $\alpha$, becoming unemployed next period.

107108108-

1. receives utility $u(w)$ and

109-

1. is fired with some (small) probability $\alpha$.

110-111-

If currently unemployed, the worker either accepts or rejects the current offer $w_t$.

109+

If currently unemployed, the worker receives random wage offer $w_t$ and either accepts or rejects.

112110113111

If he accepts, then he begins work immediately at wage $w_t$.

114112

@@ -126,16 +124,17 @@ We drop time subscripts in what follows and primes denote next period values.

126124127125

Let

128126129-

* $v_e(w)$ be maximum lifetime value accruing to a worker who enters the current

130-

period *employed* with existing wage $w$

131-

* $v_u(w)$ be maximum lifetime value accruing to a worker who who enters the

132-

current period *unemployed* and receives wage offer $w$.

127+

* $v_e(w)$ be maximum lifetime value for a worker who enters the current

128+

period employed with wage $w$

129+

* $v_u(w)$ be maximum lifetime for a worker who who enters the

130+

current period unemployed and receives wage offer $w$.

133131134-

Here **maximum lifetime value** means the value of {eq}`objective` when

132+

Here, **maximum lifetime value** means the value of {eq}`objective` when

135133

the worker makes optimal decisions at all future points in time.

136134137135

As we now show, obtaining these functions is key to solving the model.

138136137+139138

### The Bellman Equations

140139141140

We recall that, in {doc}`the original job search model <mccall_model>`, the

@@ -160,7 +159,8 @@ $w/(1-\beta)$.

160159161160

We have to make this change because jobs are not permanent.

162161163-

Accepting transitions the worker to employment and hence yields reward $v_e(w)$.

162+

Accepting transitions the worker to employment and hence yields reward $v_e(w)$,

163+

which we discuss below.

164164165165

Rejecting leads to unemployment compensation and unemployment tomorrow.

166166

@@ -211,18 +211,16 @@ Let

211211

h := u(c) + \beta \sum_{w' \in \mathbb W} v_u(w') q(w')

212212

```

213213214-

This is the continuation value for an unemployed agent (the value of rejecting the current offer).

215-216-

If we know $v_u$ then we can easily compute $h$.

214+

This is the **continuation value** for an unemployed agent -- the value of rejecting the current offer and then making optimal choices.

217215218216

From {eq}`bell2_mccall`, we see that an unemployed agent accepts current offer $w$ if $v_e(w) \geq h$.

219217220218

This means precisely that the value of accepting is higher than the value of rejecting.

221219222-

It is clear that $v_e$ is (at least weakly) increasing in $w$, since the agent is never made worse off by a higher wage offer.

220+

The function $v_e$ is increasing in $w$, since an employed agent is never made worse off by a higher current wage.

223221224222

Hence, we can express the optimal choice as accepting wage offer $w$ if and only if $w \geq \bar w$,

225-

where the **reservation wage** $\bar w$ is the first wage level $w$ such that

223+

where the **reservation wage** $\bar w$ is the first wage level $w \in \mathbb W$ such that

226224227225

$$

228226

v_e(w) \geq h

@@ -232,14 +230,11 @@ $$

232230233231

## Code

234232235-

Let's now implement a solution method based on the two Bellman equations.

233+

Let's now implement a solution method based on the two Bellman equations

234+

{eq}`bell2_mccall` and {eq}`bell1_mccall`.

236235237-

### Set Up

238-239-

In the code, you'll see that we use a class to store the various parameters and other

240-

objects associated with a given model.

241236242-

This helps to tidy up the code and provides an object that's easy to pass to functions.

237+

### Set Up

243238244239

The default utility function is a CRRA utility function

245240

@@ -274,25 +269,29 @@ class Model(NamedTuple):

274269275270

### Operators

276271277-

To iterate on the Bellman equations, we define two operators, one for each value function.

272+

We'll use a similar iterative approach to solving the Bellman equations that we

273+

adopted in the {doc}`first job search lecture <mccall_model>`.

274+275+

As a first step, to iterate on the Bellman equations, we define two operators, one for each value function.

278276279277

These operators take the current value functions as inputs and return updated versions.

280278281279

```{code-cell} ipython3

282280

def T_u(model, v_u, v_e):

283281

"""

284-

Apply the unemployment Bellman update rule.

282+

Apply the unemployment Bellman update rule and return new guess of v_u.

285283286284

"""

287285

α, β, γ, c, w, q = model

288286

h = u(c, γ) + β * (v_u @ q)

289-

return jnp.maximum(v_e, h)

287+

v_u_new = jnp.maximum(v_e, h)

288+

return v_u_new

290289

```

291290292291

```{code-cell} ipython3

293292

def T_e(model, v_u, v_e):

294293

"""

295-

Apply the employment Bellman update rule.

294+

Apply the employment Bellman update rule and return new guess of v_e.

296295297296

"""

298297

α, β, γ, c, w, q = model

@@ -301,12 +300,12 @@ def T_e(model, v_u, v_e):

301300

```

302301303302304-305303

### Iteration

306304307-

Here's our iteration routine, which alternates between updating $v_u$ and $v_e$ until convergence.

305+

Now we write an iteration routine, which updates the pair of arrays $v_u$, $v_e$ until convergence.

308306309-

We iterate until successive realizations are closer together than some small tolerance level.

307+

More precisely, we iterate until successive realizations are closer together

308+

than some small tolerance level.

310309311310

```{code-cell} ipython3

312311

def solve_full_model(

@@ -340,10 +339,10 @@ def solve_full_model(

340339341340

### Computing the Reservation Wage

342341343-

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

342+

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

344343345-

Recall from above that the reservation wage $\bar w$ solves

346-

$v_e(\bar w) = h$, where $h$ is the continuation value defined in {eq}`defh_mm`.

344+

Recall from above that the reservation wage $\bar w$ is the first $w \in \mathbb

345+

W$ satisfying $v_e(w) \geq h$, where $h$ is the continuation value defined in {eq}`defh_mm`.

347346348347

Let's compare $v_e$ and $h$ to see what they look like.

349348

@@ -377,60 +376,67 @@ def compute_reservation_wage_full(model):

377376

α, β, γ, c, w, q = model

378377

v_u, v_e = solve_full_model(model)

379378

h = u(c, γ) + β * (v_u @ q)

380-

# Find the first w such that v_e(w) >= h

379+

# Find the first w such that v_e(w) >= h, or +inf if none exist

381380

accept = v_e >= h

382-

i = jnp.argmax(accept)

381+

i = jnp.argmax(accept) # returns first accept index

383382

w_bar = jnp.where(jnp.any(accept), w[i], jnp.inf)

384383

return w_bar

385384386385

w_bar_full = compute_reservation_wage_full(model)

387386

print(f"Reservation wage (full model): {w_bar_full:.4f}")

388387

```

389388390-389+

This value seems close to where the two lines meet.

391390392391393392

(ast_mcm)=

394393

## A Simplifying Transformation

395394396395

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

397396398-

Let's return to the key equations and see if we can simplify them to reduce the problem to a single scalar equation.

397+

With some mathematics and some brain power, we can form a solution method that

398+

is far more efficient.

399399400400

(This process will be analogous to our {ref}`second pass <mm_op2>` at the plain vanilla

401401

McCall model, where we reduced the Bellman equation to an equation in an unknown

402402

scalar value, rather than an unknown vector.)

403403404-

First, recall $h$ as defined in {eq}`defh_mm`.

405-406-

Using $h$, we can now write {eq}`bell2_mccall` as

404+

First, we use the continuation value $h$, as defined in {eq}`defh_mm`, to write {eq}`bell2_mccall` as

407405408406

$$

409-

v_u(w) = \max \left\{ v_e(w), \, h \right\}

407+

v_u(w) = \max \left\{ v_e(w), \, h \right\}

410408

$$

411409412-

or, shifting time forward one period

410+

Taking the expectation of both sides and then discounting, this becomes

413411414412

$$

415-

\sum_{w' \in \mathbb W} v_u(w') q(w')

416-

= \sum_{w' \in \mathbb W} \max \left\{ v_e(w'), \, h \right\} q(w')

413+

\beta \sum_{w'} v_u(w') q(w')

414+

= \beta \sum_{w'} \max \left\{ v_e(w'), \, h \right\} q(w')

417415

$$

418416419-

Using {eq}`defh_mm` again now gives

417+

Adding $u(c)$ to both sides and using {eq}`defh_mm` again gives

420418421419

```{math}

422420

:label: bell02_mccall

423421424-

h = u(c) + \beta \sum_{w' \in \mathbb W} \max \left\{ v_e(w'), \, h \right\} q(w')

422+

h = u(c) + \beta \sum_{w'} \max \left\{ v_e(w'), \, h \right\} q(w')

425423

```

426424427-

Finally, from {eq}`defh_mm` we have

425+

This is a nice scalar equation in the continuation value, which is already

426+

useful.

427+428+

But we can go further, but eliminating $v_e$ from the above equation.

429+430+431+

### Simplifying to a Single Equation

432+433+

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

428434429435

$$

430-

\sum_{w' \in \mathbb W} v_u(w') q(w') = \frac{h - u(c)}{\beta}

436+

\sum_{w'} v_u(w') q(w') = \frac{h - u(c)}{\beta}

431437

$$

432438433-

so {eq}`bell1_mccall` can now be rewritten as

439+

Using this, the Bellman equation for $v_e$, as given in {eq}`bell1_mccall`, can now be rewritten as

434440435441

```{math}

436442

:label: bell01_mccall

@@ -441,28 +447,26 @@ v_e(w) = u(w) + \beta

441447

\right]

442448

```

443449444-

### Simplifying to a Single Equation

445-446-

We can simplify further by solving {eq}`bell01_mccall` for $v_e$ as a function of $h$.

450+

Our next step is to solve {eq}`bell01_mccall` for $v_e$ as a function of $h$.

447451448452

Rearranging {eq}`bell01_mccall` gives

449453450454

$$

451-

v_e(w) = u(w) + \beta(1-\alpha)v_e(w) + \alpha(h - u(c))

455+

v_e(w) = u(w) + \beta(1-\alpha)v_e(w) + \alpha(h - u(c))

452456

$$

453457454458

or

455459456460

$$

457-

v_e(w) - \beta(1-\alpha)v_e(w) = u(w) + \alpha(h - u(c))

461+

v_e(w) - \beta(1-\alpha)v_e(w) = u(w) + \alpha(h - u(c))

458462

$$

459463460-

Solving for $v_e(w)$:

464+

Solving for $v_e(w)$ gives

461465462466

```{math}

463467

:label: v_e_closed

464468465-

v_e(w) = \frac{u(w) + \alpha(h - u(c))}{1 - \beta(1-\alpha)}

469+

v_e(w) = \frac{u(w) + \alpha(h - u(c))}{1 - \beta(1-\alpha)}

466470

```

467471468472

Substituting this into {eq}`bell02_mccall` yields

@@ -473,18 +477,17 @@ Substituting this into {eq}`bell02_mccall` yields

473477

h = u(c) + \beta \sum_{w' \in \mathbb W} \max \left\{ \frac{u(w') + \alpha(h - u(c))}{1 - \beta(1-\alpha)}, \, h \right\} q(w')

474478

```

475479476-

This is a single scalar equation in $h$.

480+

Finally we have a single scalar equation in $h$!

477481482+

If we can solve this for $h$, we can easily recover $v_e$ using

483+

{eq}`v_e_closed`.

478484485+

Then we have enough information to compute the reservation wage.

479486480-

### Solving the Bellman Equations

481-482-

We'll use the same iterative approach to solving the Bellman equations that we

483-

adopted in the {doc}`first job search lecture <mccall_model>`.

484487485-

In this case we only need to iterate on the single scalar equation {eq}`bell_scalar`.

488+

### Solving the Bellman Equations

486489487-

The iteration rule is

490+

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

488491489492

```{math}

490493

:label: bell_iter

@@ -495,24 +498,15 @@ h_{n+1} = u(c) + \beta \sum_{w' \in \mathbb W}

495498496499

starting from some initial condition $h_0$.

497500498-

Once convergence is achieved, we can compute $v_e$ from {eq}`v_e_closed`.

499501500502

(It is possible to prove that {eq}`bell_iter` converges via the Banach contraction mapping theorem.)

501503502504503505504506

## Implementation

505507506-

First, we define a function to compute $v_e$ from $h$ using {eq}`v_e_closed`.

507-508-

```{code-cell} ipython3

509-

def compute_v_e(model, h):

510-

" Compute v_e from h using the closed-form expression. "

511-

α, β, γ, c, w, q = model

512-

return (u(w, γ) + α * (h - u(c, γ))) / (1 - β * (1 - α))

513-

```

514-515-

Now we implement the iteration on $h$ only:

508+

To implement iteration on $h$, we provide a function that provides one update,

509+

from $h_n$ to $h_{n+1}$

516510517511

```{code-cell} ipython3

518512

def update_h(model, h):

@@ -523,7 +517,18 @@ def update_h(model, h):

523517

return h_new

524518

```

525519526-

Using this iteration rule, we can write our model solver.

520+

Also, we provide a function to compute $v_e$ from {eq}`v_e_closed`.

521+522+

```{code-cell} ipython3

523+

def compute_v_e(model, h):

524+

" Compute v_e from h using the closed-form expression. "

525+

α, β, γ, c, w, q = model

526+

return (u(w, γ) + α * (h - u(c, γ))) / (1 - β * (1 - α))

527+

```

528+529+

This function will be applied once convergence is achieved.

530+531+

Now we can write our model solver.

527532528533

```{code-cell} ipython3

529534

@jax.jit

@@ -555,9 +560,8 @@ def solve_model(model, tol=1e-5, max_iter=2000):

555560

return v_e_final, h_final

556561

```

557562558-559-

Here's a function `compute_reservation_wage` that takes an instance of `Model`

560-

and returns the associated reservation wage.

563+

Finally, here's a function `compute_reservation_wage` that uses all the logic above,

564+

taking an instance of `Model` and returning the associated reservation wage.

561565562566

```{code-cell} ipython3

563567

def compute_reservation_wage(model):

@@ -584,10 +588,11 @@ print(f"Reservation wage (full model): {w_bar_full:.4f}")

584588

print(f"Difference: {abs(w_bar_simplified - w_bar_full):.6f}")

585589

```

586590587-

As we can see, both methods produce essentially the same reservation wage, but the simplified method is much more efficient.

591+

As we can see, both methods produce essentially the same reservation wage.

588592589-

Next we will investigate how the reservation wage varies with parameters.

593+

However, the simplified method is far more efficient.

590594595+

Next we will investigate how the reservation wage varies with parameters.

591596592597593598

## Impact of Parameters

Read the original on github.com ↗