Code should execute sequentially if run in a Jupyter notebook

- See the set up page to install Jupyter, Python and all necessary libraries
- Please direct feedback to contact@quantecon.org or the discourse forum

# Default Risk and Income Fluctuations¶

Contents

## Overview¶

This lecture computes versions of Arellano’s [Are08] model of sovereign default

The model describes interactions among default risk, output, and an equilibrium interest rate that includes a premium for endogenous default risk

The decision maker is a government of a small open economy that borrows from risk-neutral foreign creditors

The foreign lenders must be compensated for default risk

The government borrows and lends abroad in order to smooth the consumption of its citizens

The government repays its debt only if it wants to, but declining to pay has adverse consequences

The interest rate on government debt adjusts in response to the state-dependent default probability chosen by government

The model yields outcomes that help interpret sovereign default experiences, including

- countercyclical interest rates on sovereign debt
- countercyclical trade balances
- high volatility of consumption relative to output

Notably, long recessions caused by bad draws in the income process increase the government’s incentive to default

This can lead to

- spikes in interest rates
- temporary losses of access to international credit markets
- large drops in output, consumption, and welfare
- large capital outflows during recessions

Such dynamics are consistent with experiences of many countries

## Structure¶

In this section we describe the main features of the model

### Output, Consumption and Debt¶

A small open economy is endowed with an exogenous stochastically fluctuating potential output stream \(\{y_t\}\)

Potential output is realized only in periods in which the government honors its sovereign debt

The output good can be traded or consumed

The sequence \(\{y_t\}\) is described by a Markov process with stochastic density kernel \(p(y, y')\)

Households within the country are identical and rank stochastic consumption streams according to

Here

- \(0 < \beta < 1\) is a time discount factor
- \(u\) is an increasing and strictly concave utility function

Consumption sequences enjoyed by households are affected by the government’s decision to borrow or lend internationally

The government is benevolent in the sense that its aim is to maximize (1)

The government is the only domestic actor with access to foreign credit

Because household are averse to consumption fluctuations, the government will try to smooth consumption by borrowing from (and lending to) foreign creditors

### Asset Markets¶

The only credit instrument available to the government is a one-period bond traded in international credit markets

The bond market has the following features

The bond matures in one period and is not state contingent

A purchase of a bond with face value \(B'\) is a claim to \(B'\) units of the consumption good next period

To purchase \(B'\) next period costs \(q B'\) now, or, what is equivalent

For selling \(-B'\) units of next period goods the seller earns \(- q B'\) of today’s goods

- if \(B' < 0\), then \(-q B'\) units of the good are received in the current period, for a promise to repay \(-B'\) units next period
- there is an equilibrium price function \(q(B', y)\) that makes \(q\) depend on both \(B'\) and \(y\)

Earnings on the government portfolio are distributed (or, if negative, taxed) lump sum to households

When the government is not excluded from financial markets, the one-period national budget constraint is

Here and below, a prime denotes a next period value or a claim maturing next period

To rule out Ponzi schemes, we also require that \(B \geq -Z\) in every period

- \(Z\) is chosen to be sufficiently large that the constraint never binds in equilibrium

### Financial Markets¶

Foreign creditors

- are risk neutral
- know the domestic output stochastic process \(\{y_t\}\) and observe \(y_t, y_{t-1}, \ldots,\) at time \(t\)
- can borrow or lend without limit in an international credit market at a constant international interest rate \(r\)
- receive full payment if the government chooses to pay
- receive zero if the government defaults on its one-period debt due

When a government is expected to default next period with probability \(\delta\), the expected value of a promise to pay one unit of consumption next period is \(1 - \delta\).

Therefore, the discounted expected value of a promise to pay \(B\) next period is

Next we turn to how the government in effect chooses the default probability \(\delta\)

### Government’s decisions¶

At each point in time \(t\), the government chooses between

- defaulting
- meeting its current obligations and purchasing or selling an optimal quantity of one-period sovereign debt

Defaulting means declining to repay all of its current obligations

If the government defaults in the current period, then consumption equals current output

But a sovereign default has two consequences:

Output immediately falls from \(y\) to \(h(y)\), where \(0 \leq h(y) \leq y\)

- it returns to \(y\) only after the country regains access to international credit markets

The country loses access to foreign credit markets

### Reentering international credit market¶

While in a state of default, the economy regains access to foreign credit in each subsequent period with probability \(\theta\)

## Equilibrium¶

Informally, an equilibrium is a sequence of interest rates on its sovereign debt, a stochastic sequence of government default decisions and an implied flow of household consumption such that

- Consumption and assets satisfy the national budget constraint
- The government maximizes household utility taking into account
- the resource constraint
- the effect of its choices on the price of bonds
- consequences of defaulting now for future net output and future borrowing and lending opportunities

- The interest rate on the government’s debt includes a risk-premium sufficient to make foreign creditors expect on average to earn the constant risk-free international interest rate

To express these ideas more precisely, consider first the choices of the government, which

enters a period with initial assets \(B\), or what is the same thing, initial debt to be repaid now of \(-B\)

observes current output \(y\), and

chooses either

- to default, or
- to pay \(-B\) and set next period’s debt due to \(-B'\)

In a recursive formulation,

- state variables for the government comprise the pair \((B, y)\)
- \(v(B, y)\) is the optimum value of the government’s problem when at the beginning of a period it faces the choice of whether to honor or default
- \(v_c(B, y)\) is the value of choosing to pay obligations falling due
- \(v_d(y)\) is the value of choosing to default

\(v_d(y)\) does not depend on \(B\) because, when access to credit is eventually regained, net foreign assets equal \(0\)

Expressed recursively, the value of defaulting is

The value of paying is

The three value functions are linked by

The government chooses to default when

and hence given \(B'\) the probability of default next period is

Given zero profits for foreign creditors in equilibrium, we can combine (3) and (4) to pin down the bond price function:

### Definition of equilibrium¶

An *equilibrium* is

- a pricing function \(q(B',y)\),
- a triple of value functions \((v_c(B, y), v_d(y), v(B,y))\),
- a decision rule telling the government when to default and when to pay as a function of the state \((B, y)\), and
- an asset accumulation rule that, conditional on choosing not to default, maps \((B,y)\) into \(B'\)

such that

- The three Bellman equations for \((v_c(B, y), v_d(y), v(B,y))\) are satisfied
- Given the price function \(q(B',y)\), the default decision rule and the asset accumulation decsion rule attain the optimal value function \(v(B,y)\), and
- The price function \(q(B',y)\) satisfies equation (5)

## Computation¶

Let’s now compute an equilibrium of Arellano’s model

The equilibrium objects are the value function \(v(B, y)\), the associated default decision rule, and the pricing function \(q(B', y)\)

We’ll use our code to replicate Arellano’s results

After that we’ll perform some additional simulations

The majority of the code below was written by Chase Coleman

It uses a slightly modified version of the algorithm recommended by Arellano

- The appendix to [Are08] recommends value function iteration until convergence, updating the price, and then repeating
- Instead, we update the bond price at every value function iteration step

The second approach is faster and the two different procedures deliver very similar results

Here is a more detailed description of our algorithm:

- Guess a value function \(v(B, y)\) and price function \(q(B', y)\)
- At each pair \((B, y)\),
- update the value of defaulting \(v_d(y)\)
- update the value of continuing \(v_c(B, y)\)

- Update the value function v(B, y), the default rule, the implied ex ante default probability, and the price function
- Check for convergence. If converged, stop. If not, go to step 2.

We use simple discretization on a grid of asset holdings and income levels

The output process is discretized using Tauchen’s quadrature method

Numba has been used in two places to speed up the code

The code can be found in the file arellano_vfi.py but we repeat it here for convenience

(Results and discussion follow the code)

```
"""
Filename: arellano_vfi.py
Authors: Chase Coleman, John Stachurski
Solve the Arellano default risk model
References
----------
http://quant-econ.net/py/arellano.html
.. Arellano, Cristina. "Default risk and income fluctuations in emerging
economies." The American Economic Review (2008): 690-712.
"""
from __future__ import division
import numpy as np
import random
import quantecon as qe
from numba import jit
class Arellano_Economy(object):
"""
Arellano 2008 deals with a small open economy whose government
invests in foreign assets in order to smooth the consumption of
domestic households. Domestic households receive a stochastic
path of income.
Parameters
----------
beta : float
Time discounting parameter
gamma : float
Risk-aversion parameter
r : float
int lending rate
rho : float
Persistence in the income process
eta : float
Standard deviation of the income process
theta : float
Probability of re-entering financial markets in each period
ny : int
Number of points in y grid
nB : int
Number of points in B grid
tol : float
Error tolerance in iteration
maxit : int
Maximum number of iterations
"""
def __init__(self,
beta=.953, # time discount rate
gamma=2., # risk aversion
r=0.017, # international interest rate
rho=.945, # persistence in output
eta=0.025, # st dev of output shock
theta=0.282, # prob of regaining access
ny=21, # number of points in y grid
nB=251, # number of points in B grid
tol=1e-8, # error tolerance in iteration
maxit=10000):
# Save parameters
self.beta, self.gamma, self.r = beta, gamma, r
self.rho, self.eta, self.theta = rho, eta, theta
self.ny, self.nB = ny, nB
# Create grids and discretize Markov process
self.Bgrid = np.linspace(-.45, .45, nB)
self.mc = qe.markov.tauchen(rho, eta, 3, ny)
self.ygrid = np.exp(self.mc.state_values)
self.Py = self.mc.P
# Output when in default
ymean = np.mean(self.ygrid)
self.def_y = np.minimum(0.969 * ymean, self.ygrid)
# Allocate memory
self.Vd = np.zeros(ny)
self.Vc = np.zeros((ny, nB))
self.V = np.zeros((ny, nB))
self.Q = np.ones((ny, nB)) * .95 # Initial guess for prices
self.default_prob = np.empty((ny, nB))
# Compute the value functions, prices, and default prob
self.solve(tol=tol, maxit=maxit)
# Compute the optimal savings policy conditional on no default
self.compute_savings_policy()
def solve(self, tol=1e-8, maxit=10000):
# Iteration Stuff
it = 0
dist = 10.
# Alloc memory to store next iterate of value function
V_upd = np.zeros((self.ny, self.nB))
# == Main loop == #
while dist > tol and maxit > it:
# Compute expectations for this iteration
Vs = self.V, self.Vd, self.Vc
EV, EVd, EVc = (np.dot(self.Py, v) for v in Vs)
# Run inner loop to update value functions Vc and Vd.
# Note that Vc and Vd are updated in place. Other objects
# are not modified.
_inner_loop(self.ygrid, self.def_y, self.Bgrid, self.Vd, self.Vc,
EVc, EVd, EV, self.Q,
self.beta, self.theta, self.gamma)
# Update prices
Vd_compat = np.repeat(self.Vd, self.nB).reshape(self.ny, self.nB)
default_states = Vd_compat > self.Vc
self.default_prob[:, :] = np.dot(self.Py, default_states)
self.Q[:, :] = (1 - self.default_prob)/(1 + self.r)
# Update main value function and distance
V_upd[:, :] = np.maximum(self.Vc, Vd_compat)
dist = np.max(np.abs(V_upd - self.V))
self.V[:, :] = V_upd[:, :]
it += 1
if it % 25 == 0:
print("Running iteration {} with dist of {}".format(it, dist))
return None
def compute_savings_policy(self):
"""
Compute optimal savings B' conditional on not defaulting.
The policy is recorded as an index value in Bgrid.
"""
# Allocate memory
self.next_B_index = np.empty((self.ny, self.nB))
EV = np.dot(self.Py, self.V)
_compute_savings_policy(self.ygrid, self.Bgrid, self.Q, EV,
self.gamma, self.beta, self.next_B_index)
def simulate(self, T, y_init=None, B_init=None):
"""
Simulate time series for output, consumption, B'.
"""
# Find index i such that Bgrid[i] is near 0
zero_B_index = np.searchsorted(self.Bgrid, 0)
if y_init is None:
# Set to index near the mean of the ygrid
y_init = np.searchsorted(self.ygrid, self.ygrid.mean())
if B_init is None:
B_init = zero_B_index
# Start off not in default
in_default = False
y_sim_indices = self.mc.simulate_indices(T, init=y_init)
B_sim_indices = np.empty(T, dtype=np.int64)
B_sim_indices[0] = B_init
q_sim = np.empty(T)
in_default_series = np.zeros(T, dtype=np.int64)
for t in range(T-1):
yi, Bi = y_sim_indices[t], B_sim_indices[t]
if not in_default:
if self.Vc[yi, Bi] < self.Vd[yi]:
in_default = True
Bi_next = zero_B_index
else:
new_index = self.next_B_index[yi, Bi]
Bi_next = new_index
else:
in_default_series[t] = 1
Bi_next = zero_B_index
if random.uniform(0, 1) < self.theta:
in_default = False
B_sim_indices[t+1] = Bi_next
q_sim[t] = self.Q[yi, Bi_next]
q_sim[-1] = q_sim[-2] # Extrapolate for the last price
return_vecs = (self.ygrid[y_sim_indices],
self.Bgrid[B_sim_indices],
q_sim,
in_default_series)
return return_vecs
@jit(nopython=True)
def u(c, gamma):
return c**(1-gamma)/(1-gamma)
@jit(nopython=True)
def _inner_loop(ygrid, def_y, Bgrid, Vd, Vc, EVc,
EVd, EV, qq, beta, theta, gamma):
"""
This is a numba version of the inner loop of the solve in the
Arellano class. It updates Vd and Vc in place.
"""
ny, nB = len(ygrid), len(Bgrid)
zero_ind = nB // 2 # Integer division
for iy in range(ny):
y = ygrid[iy] # Pull out current y
# Compute Vd
Vd[iy] = u(def_y[iy], gamma) + \
beta * (theta * EVc[iy, zero_ind] + (1 - theta) * EVd[iy])
# Compute Vc
for ib in range(nB):
B = Bgrid[ib] # Pull out current B
current_max = -1e14
for ib_next in range(nB):
c = max(y - qq[iy, ib_next] * Bgrid[ib_next] + B, 1e-14)
m = u(c, gamma) + beta * EV[iy, ib_next]
if m > current_max:
current_max = m
Vc[iy, ib] = current_max
return None
@jit(nopython=True)
def _compute_savings_policy(ygrid, Bgrid, Q, EV, gamma, beta, next_B_index):
# Compute best index in Bgrid given iy, ib
ny, nB = len(ygrid), len(Bgrid)
for iy in range(ny):
y = ygrid[iy]
for ib in range(nB):
B = Bgrid[ib]
current_max = -1e10
for ib_next in range(nB):
c = max(y - Q[iy, ib_next] * Bgrid[ib_next] + B, 1e-14)
m = u(c, gamma) + beta * EV[iy, ib_next]
if m > current_max:
current_max = m
current_max_index = ib_next
next_B_index[iy, ib] = current_max_index
return None
```

## Results¶

Let’s start by trying to replicate the results obtained in [Are08]

In what follows, all results are computed using Arellano’s parameter values

The values can be seen in the __init__ method of the Arellano_Economy shown above

- For example, r=0.017 matches the average quarterly rate on a 5 year US treasury over the period 1983–2001

Details on how to compute the figures are reported as solutions to the exercises

The first figure shows the bond price schedule and replicates Figure 3 of Arellano, where \(y_L\) and \(Y_H\) are particular below average and above average values of output \(y\)

- \(y_L\) is 5% below the mean of the \(y\) grid values
- \(y_H\) is 5% above the mean of the \(y\) grid values

The grid used to compute this figure was relatively coarse (ny, nB = 21, 251) in order to match Arrelano’s findings

Here’s the same relationships computed on a finer grid (ny, nB = 51, 551)

In either case, the figure shows that

- Higher levels of debt (larger \(-B'\)) induce larger discounts on the face value, which correspond to higher interest rates
- Lower income also causes more discounting, as foreign creditors anticipate greater likelihood of default

The next figure plots value functions and replicates the right hand panel of Figure 4 of [Are08]

We can use the results of the computation to study the default probability \(\delta(B', y)\) defined in (4)

The next plot shows these default probabilities over \((B', y)\) as a heat map

As anticipated, the probability that the government chooses to default in the following period increases with indebtedness and falls with income

Next let’s run a time series simulation of \(\{y_t\}\), \(\{B_t\}\) and \(q(B_{t+1}, y_t)\)

The grey vertical bars correspond to periods when the economy is excluded from financial markets because of a past default

One notable feature of the simulated data is the nonlinear response of interest rates

Periods of relative stability are followed by sharp spikes in the discount rate on government debt