Skip to content

Commit 526e5dd

Browse files
jstacclaude
andcommitted
Convert mccall_persist_trans.md to MyST format
Used jupytext to convert the file from markdown to MyST format: - Changed format_name from "markdown" to "myst" in YAML frontmatter - Converted all ```python code blocks to ```{code-cell} ipython directives - Removed extra "jupyter:" wrapper level in frontmatter - Updated format_version to match other lecture files (0.13) This ensures the file is properly processed as a MyST markdown file consistent with all other lectures in the repository. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 7b03c71 commit 526e5dd

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

lectures/mccall_persist_trans.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
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

5755
We will use the following imports:
5856

59-
```python
57+
```{code-cell} ipython
6058
import matplotlib.pyplot as plt
6159
import jax
6260
import jax.numpy as jnp
@@ -178,7 +176,7 @@ Here's a `NamedTuple` that stores the model parameters and data.
178176

179177
Default parameter values are embedded in the model.
180178

181-
```python
179+
```{code-cell} ipython
182180
class 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

211209
Next, we implement the $Q$ operator.
212210

213-
```python
211+
```{code-cell} ipython
214212
def Q(model, f_in):
215213
"""
216214
Apply the operator Q.
@@ -245,7 +243,7 @@ def Q(model, f_in):
245243

246244
Here's a function to compute an approximation to the fixed point of $Q$.
247245

248-
```python
246+
```{code-cell} ipython
249247
@jax.jit
250248
def 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

277275
Let's try generating an instance and solving the model.
278276

279-
```python
277+
```{code-cell} ipython
280278
model = create_job_search_model()
281279
282280
with qe.Timer():
@@ -285,7 +283,7 @@ with qe.Timer():
285283

286284
Next, we will compute and plot the reservation wage function defined in {eq}`corr_mcm_barw`.
287285

288-
```python
286+
```{code-cell} ipython
289287
res_wage_function = jnp.exp(f_star * (1 - model.β))
290288
291289
fig, ax = plt.subplots()
@@ -305,7 +303,7 @@ increasing the option value of waiting.
305303
Let's try changing unemployment compensation and looking at its impact on the
306304
reservation wage:
307305

308-
```python
306+
```{code-cell} ipython
309307
c_vals = 1, 2, 3
310308
311309
fig, ax = plt.subplots()
@@ -331,7 +329,7 @@ Next, we study how mean unemployment duration varies with unemployment compensat
331329

332330
For simplicity, we'll fix the initial state at $z_t = 0$.
333331

334-
```python
332+
```{code-cell} ipython
335333
@jax.jit
336334
def draw_duration(key, μ, s, d, ρ, σ, β, z_grid, f_star, t_max=10_000):
337335
"""
@@ -400,7 +398,7 @@ def compute_unemployment_duration(
400398

401399
Let's test this out with some possible values for unemployment compensation.
402400

403-
```python
401+
```{code-cell} ipython
404402
c_vals = jnp.linspace(1.0, 10.0, 8)
405403
durations = []
406404
for i, c in enumerate(c_vals):
@@ -412,7 +410,7 @@ durations = jnp.array(durations)
412410

413411
Here is a plot of the results.
414412

415-
```python
413+
```{code-cell} ipython
416414
fig, ax = plt.subplots()
417415
ax.plot(c_vals, durations)
418416
ax.set_xlabel("unemployment compensation")
@@ -441,7 +439,7 @@ Investigate how mean unemployment duration varies with the discount factor $\bet
441439

442440
Here is one solution:
443441

444-
```python
442+
```{code-cell} ipython
445443
beta_vals = jnp.linspace(0.94, 0.99, 8)
446444
durations = []
447445
for i, β in enumerate(beta_vals):
@@ -451,7 +449,7 @@ for i, β in enumerate(beta_vals):
451449
durations = jnp.array(durations)
452450
```
453451

454-
```python
452+
```{code-cell} ipython
455453
fig, ax = plt.subplots()
456454
ax.plot(beta_vals, durations)
457455
ax.set_xlabel(r"$\beta$")

0 commit comments

Comments
 (0)