Skip to content

Commit c6aaf8f

Browse files
committed
FIX: arellano is missing {code-cell} wrappers
1 parent 7719183 commit c6aaf8f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lectures/arellano.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jupyter:
2929

3030
In addition to what's in Anaconda, this lecture will need the following libraries:
3131

32-
```python
32+
```{code-cell} python
3333
:tags: ["hide-output"]
3434
!pip install --upgrade quantecon
3535
```
@@ -77,7 +77,7 @@ Such dynamics are consistent with experiences of many countries.
7777

7878
Let's start with some imports:
7979

80-
```python
80+
```{code-cell} python
8181
import matplotlib.pyplot as plt
8282
import numpy as np
8383
import quantecon as qe
@@ -349,7 +349,7 @@ As we have in other places, we accelerate our code using Numba.
349349
We define a class that will store parameters, grids and transition
350350
probabilities.
351351

352-
```python
352+
```{code-cell} python
353353
class Arellano_Economy:
354354
" Stores data and creates primitives for the Arellano economy. "
355355
@@ -399,7 +399,7 @@ Jitted functions prefer simple arguments, since type inference is easier.
399399
Here is the utility function.
400400

401401

402-
```python
402+
```{code-cell} python
403403
@njit
404404
def u(c, γ):
405405
return c**(1-γ)/(1-γ)
@@ -408,7 +408,7 @@ def u(c, γ):
408408
Here is a function to compute the bond price at each state, given $v_c$ and
409409
$v_d$.
410410

411-
```python
411+
```{code-cell} python
412412
@njit
413413
def compute_q(v_c, v_d, q, params, arrays):
414414
"""
@@ -431,7 +431,7 @@ def compute_q(v_c, v_d, q, params, arrays):
431431

432432
Next we introduce Bellman operators that updated $v_d$ and $v_c$.
433433

434-
```python
434+
```{code-cell} python
435435
@njit
436436
def T_d(y_idx, v_c, v_d, params, arrays):
437437
"""
@@ -478,7 +478,7 @@ def T_c(B_idx, y_idx, v_c, v_d, q, params, arrays):
478478

479479
Here is a fast function that calls these operators in the right sequence.
480480

481-
```python
481+
```{code-cell} python
482482
@njit(parallel=True)
483483
def update_values_and_prices(v_c, v_d, # Current guess of value functions
484484
B_star, q, # Arrays to be written to
@@ -518,7 +518,7 @@ In fact, one of the jobs of this function is to take an instance of
518518
`Arellano_Economy`, which is hard for the JIT compiler to handle, and strip it
519519
down to more basic objects, which are then passed out to jitted functions.
520520

521-
```python
521+
```{code-cell} python
522522
def solve(model, tol=1e-8, max_iter=10_000):
523523
"""
524524
Given an instance of Arellano_Economy, this function computes the optimal
@@ -558,7 +558,7 @@ def solve(model, tol=1e-8, max_iter=10_000):
558558
Finally, we write a function that will allow us to simulate the economy once
559559
we have the policy functions
560560

561-
```python
561+
```{code-cell} python
562562
def simulate(model, T, v_c, v_d, q, B_star, y_idx=None, B_idx=None):
563563
"""
564564
Simulates the Arellano 2008 model of sovereign debt
@@ -703,17 +703,17 @@ To the extent that you can, replicate the figures shown above
703703

704704
Compute the value function, policy and equilibrium prices
705705

706-
```python
706+
```{code-cell} python
707707
ae = Arellano_Economy()
708708
```
709709

710-
```python
710+
```{code-cell} python
711711
v_c, v_d, q, B_star = solve(ae)
712712
```
713713

714714
Compute the bond price schedule as seen in figure 3 of Arellano (2008)
715715

716-
```python
716+
```{code-cell} python
717717
# Unpack some useful names
718718
B_grid, y_grid, P = ae.B_grid, ae.y_grid, ae.P
719719
B_grid_size, y_grid_size = len(B_grid), len(y_grid)
@@ -744,7 +744,7 @@ plt.show()
744744

745745
Draw a plot of the value functions
746746

747-
```python
747+
```{code-cell} python
748748
v = np.maximum(v_c, np.reshape(v_d, (1, y_grid_size)))
749749
750750
fig, ax = plt.subplots(figsize=(10, 6.5))
@@ -759,7 +759,7 @@ plt.show()
759759

760760
Draw a heat map for default probability
761761

762-
```python
762+
```{code-cell} python
763763
xx, yy = B_grid, y_grid
764764
zz = np.empty_like(v_c)
765765
@@ -780,7 +780,7 @@ plt.show()
780780

781781
Plot a time series of major variables simulated from the model
782782

783-
```python
783+
```{code-cell} python
784784
T = 250
785785
np.random.seed(42)
786786
y_sim, y_a_sim, B_sim, q_sim, d_sim = simulate(ae, T, v_c, v_d, q, B_star)

0 commit comments

Comments
 (0)