Skip to content

Commit 1fad734

Browse files
jstacclaude
andcommitted
Standardize value function notation in McCall model with separation
This commit standardizes the value function notation in the Job Search II lecture to match the notation used in Job Search III (mccall_model_with_sep_markov.md). Key changes: - Renamed v(w) → v_e(w) for employed worker's value function - Renamed h(w) → v_u(w) for unemployed worker's value function - Updated continuation value h → v_u^* in explanations - Updated all Bellman equations and mathematical expressions - Updated code variables (v → v_e, h → v_u_star) - Updated plot labels to reflect new notation - Updated function documentation and comments This standardization improves consistency across the job search lecture series and makes the notation more intuitive (e for employed, u for unemployed). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 459ffcb commit 1fad734

File tree

1 file changed

+67
-78
lines changed

1 file changed

+67
-78
lines changed

lectures/mccall_model_with_separation.md

Lines changed: 67 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.17.1
7+
jupytext_version: 1.17.2
88
kernelspec:
9-
name: python3
109
display_name: Python 3 (ipykernel)
1110
language: python
11+
name: python3
1212
---
1313

1414
(mccall_with_sep)=
@@ -89,34 +89,25 @@ introducing a utility function $u$.
8989

9090
It satisfies $u'> 0$ and $u'' < 0$.
9191

92-
### The Wage Process
93-
94-
For now we will drop the separation of state process and wage process that we
95-
maintained for the {doc}`baseline model <mccall_model>`.
96-
97-
In particular, we simply suppose that wage offers $\{ w_t \}$ are IID with common distribution $q$.
92+
Wage offers $\{ w_t \}$ are IID with common distribution $q$.
9893

9994
The set of possible wage values is denoted by $\mathbb W$.
10095

101-
(Later we will go back to having a separate state process $\{s_t\}$
102-
driving random outcomes, since this formulation is usually convenient in more sophisticated
103-
models.)
104-
10596
### Timing and Decisions
10697

10798
At the start of each period, the agent can be either
10899

109100
* unemployed or
110-
* employed at some existing wage level $w_e$.
101+
* employed at some existing wage level $w$.
111102

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

114-
If currently *employed*, the worker
105+
If currently employed, the worker
115106

116-
1. receives utility $u(w_e)$ and
107+
1. receives utility $u(w)$ and
117108
1. is fired with some (small) probability $\alpha$.
118109

119-
If currently *unemployed*, the worker either accepts or rejects the current offer $w_t$.
110+
If currently unemployed, the worker either accepts or rejects the current offer $w_t$.
120111

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

@@ -134,8 +125,8 @@ We drop time subscripts in what follows and primes denote next period values.
134125

135126
Let
136127

137-
* $v(w_e)$ be total lifetime value accruing to a worker who enters the current period *employed* with existing wage $w_e$
138-
* $h(w)$ be total lifetime value accruing to a worker who who enters the current period *unemployed* and receives
128+
* $v_e(w)$ be total lifetime value accruing to a worker who enters the current period *employed* with existing wage $w$
129+
* $v_u(w)$ be total lifetime value accruing to a worker who who enters the current period *unemployed* and receives
139130
wage offer $w$.
140131

141132
Here *value* means the value of the objective function {eq}`objective` when the worker makes optimal decisions at all future points in time.
@@ -144,16 +135,16 @@ Our first aim is to obtain these functions.
144135

145136
### The Bellman Equations
146137

147-
Suppose for now that the worker can calculate the functions $v$ and $h$ and use them in his decision making.
138+
Suppose for now that the worker can calculate the functions $v_e$ and $v_u$ and use them in his decision making.
148139

149-
Then $v$ and $h$ should satisfy
140+
Then $v_e$ and $v_u$ should satisfy
150141

151142
```{math}
152143
:label: bell1_mccall
153144
154-
v(w_e) = u(w_e) + \beta
145+
v_e(w) = u(w) + \beta
155146
\left[
156-
(1-\alpha)v(w_e) + \alpha \sum_{w' \in \mathbb W} h(w') q(w')
147+
(1-\alpha)v_e(w) + \alpha \sum_{w' \in \mathbb W} v_u(w') q(w')
157148
\right]
158149
```
159150

@@ -162,25 +153,25 @@ and
162153
```{math}
163154
:label: bell2_mccall
164155
165-
h(w) = \max \left\{ v(w), \, u(c) + \beta \sum_{w' \in \mathbb W} h(w') q(w') \right\}
156+
v_u(w) = \max \left\{ v_e(w), \, u(c) + \beta \sum_{w' \in \mathbb W} v_u(w') q(w') \right\}
166157
```
167158

168-
Equation {eq}`bell1_mccall` expresses the value of being employed at wage $w_e$ in terms of
159+
Equation {eq}`bell1_mccall` expresses the value of being employed at wage $w$ in terms of
169160

170-
* current reward $u(w_e)$ plus
161+
* current reward $u(w)$ plus
171162
* discounted expected reward tomorrow, given the $\alpha$ probability of being fired
172163

173164
Equation {eq}`bell2_mccall` expresses the value of being unemployed with offer
174165
$w$ in hand as a maximum over the value of two options: accept or reject
175166
the current offer.
176167

177-
Accepting transitions the worker to employment and hence yields reward $v(w)$.
168+
Accepting transitions the worker to employment and hence yields reward $v_e(w)$.
178169

179170
Rejecting leads to unemployment compensation and unemployment tomorrow.
180171

181172
Equations {eq}`bell1_mccall` and {eq}`bell2_mccall` are the Bellman equations for this model.
182173

183-
They provide enough information to solve for both $v$ and $h$.
174+
They provide enough information to solve for both $v_e$ and $v_u$.
184175

185176
(ast_mcm)=
186177
### A Simplifying Transformation
@@ -196,68 +187,66 @@ First, let
196187
```{math}
197188
:label: defd_mm
198189
199-
d := \sum_{w' \in \mathbb W} h(w') q(w')
190+
d := \sum_{w' \in \mathbb W} v_u(w') q(w')
200191
```
201192

202193
be the expected value of unemployment tomorrow.
203194

204195
We can now write {eq}`bell2_mccall` as
205196

206197
$$
207-
h(w) = \max \left\{ v(w), \, u(c) + \beta d \right\}
198+
v_u(w) = \max \left\{ v_e(w), \, u(c) + \beta d \right\}
208199
$$
209200

210201
or, shifting time forward one period
211202

212203
$$
213-
\sum_{w' \in \mathbb W} h(w') q(w')
214-
= \sum_{w' \in \mathbb W} \max \left\{ v(w'), \, u(c) + \beta d \right\} q(w')
204+
\sum_{w' \in \mathbb W} v_u(w') q(w')
205+
= \sum_{w' \in \mathbb W} \max \left\{ v_e(w'), \, u(c) + \beta d \right\} q(w')
215206
$$
216207

217208
Using {eq}`defd_mm` again now gives
218209

219210
```{math}
220211
:label: bell02_mccall
221212
222-
d = \sum_{w' \in \mathbb W} \max \left\{ v(w'), \, u(c) + \beta d \right\} q(w')
213+
d = \sum_{w' \in \mathbb W} \max \left\{ v_e(w'), \, u(c) + \beta d \right\} q(w')
223214
```
224215

225216
Finally, {eq}`bell1_mccall` can now be rewritten as
226217

227218
```{math}
228219
:label: bell01_mccall
229220
230-
v(w) = u(w) + \beta
221+
v_e(w) = u(w) + \beta
231222
\left[
232-
(1-\alpha)v(w) + \alpha d
223+
(1-\alpha)v_e(w) + \alpha d
233224
\right]
234225
```
235226

236-
In the last expression, we wrote $w_e$ as $w$ to make the notation
237-
simpler.
238227

239228
### The Reservation Wage
240229

241230
Suppose we can use {eq}`bell02_mccall` and {eq}`bell01_mccall` to solve for
242-
$d$ and $v$.
231+
$d$ and $v_e$.
243232

244233
(We will do this soon.)
245234

246235
We can then determine optimal behavior for the worker.
247236

248237
From {eq}`bell2_mccall`, we see that an unemployed agent accepts current offer
249-
$w$ if $v(w) \geq u(c) + \beta d$.
238+
$w$ if $v_e(w) \geq u(c) + \beta d$.
250239

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

253-
It is clear that $v$ is (at least weakly) increasing in $w$, since the agent is never made worse off by a higher wage offer.
242+
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.
254243

255244
Hence, we can express the optimal choice as accepting wage offer $w$ if and only if
256245

257246
$$
258247
w \geq \bar w
259248
\quad \text{where} \quad
260-
\bar w \text{ solves } v(\bar w) = u(c) + \beta d
249+
\bar w \text{ solves } v_e(\bar w) = u(c) + \beta d
261250
$$
262251

263252
### Solving the Bellman Equations
@@ -267,7 +256,7 @@ adopted in the {doc}`first job search lecture <mccall_model>`.
267256

268257
Here this amounts to
269258

270-
1. make guesses for $d$ and $v$
259+
1. make guesses for $d$ and $v_e$
271260
1. plug these guesses into the right-hand sides of {eq}`bell02_mccall` and {eq}`bell01_mccall`
272261
1. update the left-hand sides from this rule and then repeat
273262

@@ -277,22 +266,22 @@ In other words, we are iterating using the rules
277266
:label: bell1001
278267
279268
d_{n+1} = \sum_{w' \in \mathbb W}
280-
\max \left\{ v_n(w'), \, u(c) + \beta d_n \right\} q(w')
269+
\max \left\{ v_{e,n}(w'), \, u(c) + \beta d_n \right\} q(w')
281270
```
282271

283272
```{math}
284273
:label: bell2001
285274
286-
v_{n+1}(w) = u(w) + \beta
275+
v_{e,n+1}(w) = u(w) + \beta
287276
\left[
288-
(1-\alpha)v_n(w) + \alpha d_n
277+
(1-\alpha)v_{e,n}(w) + \alpha d_n
289278
\right]
290279
```
291280

292-
starting from some initial conditions $d_0, v_0$.
281+
starting from some initial conditions $d_0, v_{e,0}$.
293282

294283
As before, the system always converges to the true solutions---in this case,
295-
the $v$ and $d$ that solve {eq}`bell02_mccall` and {eq}`bell01_mccall`.
284+
the $v_e$ and $d$ that solve {eq}`bell02_mccall` and {eq}`bell01_mccall`.
296285

297286
(A proof can be obtained via the Banach contraction mapping theorem.)
298287

@@ -341,69 +330,69 @@ We then return the current iterate as an approximate solution.
341330

342331
```{code-cell} ipython3
343332
@jax.jit
344-
def update(model, v, d):
333+
def update(model, v_e, d):
345334
" One update on the Bellman equations. "
346335
α, β, c, w, q = model.α, model.β, model.c, model.w, model.q
347-
v_new = u(w) + β * ((1 - α) * v + α * d)
348-
d_new = jnp.maximum(v, u(c) + β * d) @ q
349-
return v_new, d_new
336+
v_e_new = u(w) + β * ((1 - α) * v_e + α * d)
337+
d_new = jnp.maximum(v_e, u(c) + β * d) @ q
338+
return v_e_new, d_new
350339
351340
@jax.jit
352341
def solve_model(model, tol=1e-5, max_iter=2000):
353342
" Iterates to convergence on the Bellman equations. "
354-
343+
355344
def cond_fun(state):
356-
v, d, i, error = state
345+
v_e, d, i, error = state
357346
return jnp.logical_and(error > tol, i < max_iter)
358-
347+
359348
def body_fun(state):
360-
v, d, i, error = state
361-
v_new, d_new = update(model, v, d)
362-
error_1 = jnp.max(jnp.abs(v_new - v))
349+
v_e, d, i, error = state
350+
v_e_new, d_new = update(model, v_e, d)
351+
error_1 = jnp.max(jnp.abs(v_e_new - v_e))
363352
error_2 = jnp.abs(d_new - d)
364353
error_new = jnp.maximum(error_1, error_2)
365-
return v_new, d_new, i + 1, error_new
366-
367-
# Initial state: (v, d, i, error)
368-
v_init = jnp.ones_like(model.w)
354+
return v_e_new, d_new, i + 1, error_new
355+
356+
# Initial state: (v_e, d, i, error)
357+
v_e_init = jnp.ones_like(model.w)
369358
d_init = 1.0
370359
i_init = 0
371360
error_init = tol + 1
372-
373-
init_state = (v_init, d_init, i_init, error_init)
361+
362+
init_state = (v_e_init, d_init, i_init, error_init)
374363
final_state = jax.lax.while_loop(cond_fun, body_fun, init_state)
375-
v_final, d_final, _, _ = final_state
376-
377-
return v_final, d_final
364+
v_e_final, d_final, _, _ = final_state
365+
366+
return v_e_final, d_final
378367
```
379368

380369
### The Reservation Wage: First Pass
381370

382371
The optimal choice of the agent is summarized by the reservation wage.
383372

384373
As discussed above, the reservation wage is the $\bar w$ that solves
385-
$v(\bar w) = h$ where $h := u(c) + \beta d$ is the continuation
374+
$v_e(\bar w) = v_u^*$ where $v_u^* := u(c) + \beta d$ is the continuation
386375
value.
387376

388-
Let's compare $v$ and $h$ to see what they look like.
377+
Let's compare $v_e$ and $v_u^*$ to see what they look like.
389378

390379
We'll use the default parameterizations found in the code above.
391380

392381
```{code-cell} ipython3
393382
model = Model()
394-
v, d = solve_model(model)
395-
h = u(model.c) + model.β * d
383+
v_e, d = solve_model(model)
384+
v_u_star = u(model.c) + model.β * d
396385
397386
fig, ax = plt.subplots()
398-
ax.plot(model.w, v, 'b-', lw=2, alpha=0.7, label='$v$')
399-
ax.plot(model.w, [h] * len(model.w),
400-
'g-', lw=2, alpha=0.7, label='$h$')
387+
ax.plot(model.w, v_e, 'b-', lw=2, alpha=0.7, label='$v_e$')
388+
ax.plot(model.w, [v_u_star] * len(model.w),
389+
'g-', lw=2, alpha=0.7, label='$v_u^*$')
401390
ax.set_xlim(min(model.w), max(model.w))
402391
ax.legend()
403392
plt.show()
404393
```
405394

406-
The value $v$ is increasing because higher $w$ generates a higher wage flow conditional on staying employed.
395+
The value $v_e$ is increasing because higher $w$ generates a higher wage flow conditional on staying employed.
407396

408397
### The Reservation Wage: Computation
409398

@@ -415,13 +404,13 @@ and returns the associated reservation wage.
415404
def compute_reservation_wage(model):
416405
"""
417406
Computes the reservation wage of an instance of the McCall model
418-
by finding the smallest w such that v(w) >= h. If no such w exists, then
407+
by finding the smallest w such that v_e(w) >= v_u^*. If no such w exists, then
419408
w_bar is set to np.inf.
420409
"""
421-
422-
v, d = solve_model(model)
423-
h = u(model.c) + model.β * d
424-
i = jnp.searchsorted(v, h, side='left')
410+
411+
v_e, d = solve_model(model)
412+
v_u_star = u(model.c) + model.β * d
413+
i = jnp.searchsorted(v_e, v_u_star, side='left')
425414
w_bar = jnp.where(i >= len(model.w), jnp.inf, model.w[i])
426415
return w_bar
427416
```

0 commit comments

Comments
 (0)