11---
2- jupyter :
3- jupytext :
4- default_lexer : ipython
5- text_representation :
6- extension : .md
7- format_name : markdown
8- format_version : ' 1.3'
9- jupytext_version : 1.17.2
10- kernelspec :
11- display_name : Python 3
12- language : python
13- name : python3
2+ jupytext :
3+ text_representation :
4+ extension : .md
5+ format_name : myst
6+ format_version : 0.13
7+ jupytext_version : 1.17.2
8+ kernelspec :
9+ display_name : Python 3
10+ language : python
11+ name : python3
1412---
1513
1614``` {raw} jupyter
@@ -56,7 +54,7 @@ We will solve the model using fitted value function iteration with linear interp
5654
5755We will use the following imports:
5856
59- ``` python
57+ ``` {code-cell} ipython
6058import matplotlib.pyplot as plt
6159import jax
6260import jax.numpy as jnp
@@ -178,7 +176,7 @@ Here's a `NamedTuple` that stores the model parameters and data.
178176
179177Default parameter values are embedded in the model.
180178
181- ``` python
179+ ``` {code-cell} ipython
182180class Model(NamedTuple):
183181 μ: float # transient shock log mean
184182 s: float # transient shock log variance
@@ -210,7 +208,7 @@ def create_job_search_model(μ=0.0, s=1.0, d=0.0, ρ=0.9, σ=0.1, β=0.98, c=5.0
210208
211209Next, we implement the $Q$ operator.
212210
213- ``` python
211+ ``` {code-cell} ipython
214212def Q(model, f_in):
215213 """
216214 Apply the operator Q.
@@ -245,7 +243,7 @@ def Q(model, f_in):
245243
246244Here's a function to compute an approximation to the fixed point of $Q$.
247245
248- ``` python
246+ ``` {code-cell} ipython
249247@jax.jit
250248def compute_fixed_point(model, tol=1e-4, max_iter=1000):
251249 """
@@ -276,7 +274,7 @@ def compute_fixed_point(model, tol=1e-4, max_iter=1000):
276274
277275Let's try generating an instance and solving the model.
278276
279- ``` python
277+ ``` {code-cell} ipython
280278model = create_job_search_model()
281279
282280with qe.Timer():
@@ -285,7 +283,7 @@ with qe.Timer():
285283
286284Next, we will compute and plot the reservation wage function defined in {eq}` corr_mcm_barw ` .
287285
288- ``` python
286+ ``` {code-cell} ipython
289287res_wage_function = jnp.exp(f_star * (1 - model.β))
290288
291289fig, ax = plt.subplots()
@@ -305,7 +303,7 @@ increasing the option value of waiting.
305303Let's try changing unemployment compensation and looking at its impact on the
306304reservation wage:
307305
308- ``` python
306+ ``` {code-cell} ipython
309307c_vals = 1, 2, 3
310308
311309fig, ax = plt.subplots()
@@ -331,7 +329,7 @@ Next, we study how mean unemployment duration varies with unemployment compensat
331329
332330For simplicity, we'll fix the initial state at $z_t = 0$.
333331
334- ``` python
332+ ``` {code-cell} ipython
335333@jax.jit
336334def draw_duration(key, μ, s, d, ρ, σ, β, z_grid, f_star, t_max=10_000):
337335 """
@@ -400,7 +398,7 @@ def compute_unemployment_duration(
400398
401399Let's test this out with some possible values for unemployment compensation.
402400
403- ``` python
401+ ``` {code-cell} ipython
404402c_vals = jnp.linspace(1.0, 10.0, 8)
405403durations = []
406404for i, c in enumerate(c_vals):
@@ -412,7 +410,7 @@ durations = jnp.array(durations)
412410
413411Here is a plot of the results.
414412
415- ``` python
413+ ``` {code-cell} ipython
416414fig, ax = plt.subplots()
417415ax.plot(c_vals, durations)
418416ax.set_xlabel("unemployment compensation")
@@ -441,7 +439,7 @@ Investigate how mean unemployment duration varies with the discount factor $\bet
441439
442440Here is one solution:
443441
444- ``` python
442+ ``` {code-cell} ipython
445443beta_vals = jnp.linspace(0.94, 0.99, 8)
446444durations = []
447445for i, β in enumerate(beta_vals):
@@ -451,7 +449,7 @@ for i, β in enumerate(beta_vals):
451449durations = jnp.array(durations)
452450```
453451
454- ``` python
452+ ``` {code-cell} ipython
455453fig, ax = plt.subplots()
456454ax.plot(beta_vals, durations)
457455ax.set_xlabel(r"$\beta$")
0 commit comments