Continuous Time 1
Continuous Time 1
• Many (most?) macroeconomic models of interest require the solution of dynamic optimization
problems, both in deterministic and stochastic environments.
1. Discrete time.
2. Continuous time.
• Three approaches:
2. Hamiltonians.
3. Dynamic Programming.
• Continuous time methods transform optimal control problems into partial differential equations
(PDEs):
2. Solving these PDEs turns out to be much simpler than solving the Bellman or the Chapman-Kolmogorov
equations in discrete time. Also, much knowledge of PDEs in natural sciences and applied math.
2
The development of “continuous-time methods”
• Differential calculus introduced in the 17th century by Isaac Newton and Gottfried Wilhelm Leibniz.
• In the late 19th century and early 20th century, it was extended to accommodate stochastic processes
(“stochastic calculus”).
• Thorvald N. Thiele (1880): Introduces the idea of Brownian motion.
• Louis Bachelier (1900): Formalizes the Brownian motion and applies to the stock market.
• Albert Einstein (1905): A model of the motion of small particles suspended in a liquid.
• Norbert Wiener (1923): Uses the ideas of measure theory to construct a measure on the path space of
continuous functions.
• Andrey Kolmogorov (1931): Diffusions depend on drift and volatility, Kolmogorov equations.
• Calculus of variations: Issac Newton (1687), Johann Bernoulli (1696), Leonhard Euler (1733),
Joseph-Louis Lagrange (1755).
• 1930s and 1940s: many problems in aerospace engineering are hard to tackle with calculus of
variations. Example: minimum time interception problems for fighter aircraft.
• Lev S. Pontryagin, Vladimir G. Boltyanskii, and Revaz V. Gamkrelidze (1956): Maximum principle.
2. Principle of optimality.
3. Dynamic programming.
5
Figure 2. Figure
The1: mathematicians at Steklov:
Lev S. Pontryagin, Vladimir G. Boltyanskii,Lev Semyonovich
and Revaz V. GamkrelidzePontryagin,
Vladimir Grigor’evich Boltyanskii, and Revaz Valerianovich Gamkrelidze
6
Figure 1. TheFigure
mathematicians at RAND:
2: Magnus R. Hestenes, Rufus P.Magnus
Isaacs, andR. Hestenes,
Richard Rufus P. Isaacs,
E. Bellman
and Richard E. Bellman
7
8
9
10
11
12
Optimal control
• An agent maximizes: Z ∞
max e −ρt u (αt , xt ) dt,
{αt }t≥0 0
subject to:
dxt
= µt (αt , xt ) , x0 = x.
dt
13
Hamilton-Jacobi-Bellman
15
HJB: proof
1. Apply the Bellman optimality principle (and limT →∞ e −ρT VT (x) = 0):
Z t h i
−ρ(s−t0 )
V (t0 , x) ≡ max e u (αs , xs ) ds + e −ρ(t−t0 ) V (t, xt )
{αs }t t0
0 ≤s≤t
2. Take the derivative with respect to t with the Leibniz integral rule and limt→t0 :
" #
d e −ρ(t−t0 ) V (t, xt )
−ρ(t−t0 )
0 = lim max e u (αt , x) +
t→t0 αt dt
16
Example: consumption-savings problem
• A household solves: Z ∞
max e −ρt log (ct ) dt,
{ct }t≥0 0
subject to:
dat
= rat + y − ct , a0 = ā,
dt
where r and y are constants.
• Intuitive interpretation.
17
Example: solution
• We guess V (a) = 1 1 r 1 y
ρ log ρ + ρ ρ −1 + ρ log a + r .
18
The Hamiltonian
• Then, the optimal policies are those that maximize the Hamiltonian H (α, x, λ):
H(α,x,λ)
z }| {
XN
max u (α, x) + µn (x, α) λnt
α
n=1
∂2V ∂ 2 V dxt
• Notice: dλnt
dt = ∂t∂xn + ∂xn2 dt .
19
Pontryagin maximum principle
dλnt ∂H
= ρλnt −
dt ∂xn
• But how do you take care of the filtration in the stochastic case?
21
Stochastic calculus
Brownian motion
1. W (0) = 0.
2. If r < s < t < u : W (u) − W (t) and W (s) − W (r ) are independent random variables.
22
Simulated paths
60
40
20
-20
-40
-60
0 100 200 300 400 500 600 700 800 900 1000 23
Why do we need a new concept of integral?
• But the value function is now a stochastic function because it depends on stochastic processes.
• More importantly, we need to deal with diffusions, which will include an integral.
• We cannot apply standard rules of calculus: Almost surely, a Brownian motion is nowhere
differentiable (even though it is everywhere continuous!).
• Brownian motion exhibits self-similarity (if you know what this means, the Hurst parameter of a
Brownian motion is H = 12 > 0).
24
Chebyshev polynomial of order 11 Chebyshev polynomial of order 11
1 0
-0.1
-0.2
0.5
-0.3
-0.4
0
-0.5
-0.6
-0.5
-0.7
-0.8
-1 -0.9
0 0.2 0.4 0.6 0.8 1 0 0.02 0.04 0.06 0.08 0.1
-0.02 -0.002
-0.04 -0.004
-0.06 -0.006
-0.08 -0.008
-0.1 -0.01
-0.12 -0.012
0 0.002 0.004 0.006 0.008 0.01 0 0.2 0.4 0.6 0.8 1
10 -3 25
Brownian motion Brownian motion
1.014 1.0005
1.012
1
1.01
1.008 0.9995
1.006
0.999
1.004
1.002 0.9985
1
0.998
0.998
0.996 0.9975
0 0.2 0.4 0.6 0.8 1 0 0.02 0.04 0.06 0.08 0.1
1.0004 1
1.0002 0.99995
1 0.9999
0.9998 0.99985
0.9996 0.9998
0.9994 0.99975
0.9992 0.9997
0 0.002 0.004 0.006 0.008 0.01 0 0.2 0.4 0.6 0.8 1
10 -3 26
The stochastic integral
• Recall that the Riemann-Stieltjes integral of a (deterministic) function g (t) with respect to the
(deterministic) function w (t) is:
Z t n−1
X
g (s)dw (s) = lim g (tk ) [w (tk+1 ) − w (tk )] ,
0 n→∞
k=0
where t0 = 0 and tn = t.
• Given a stochastic process g (t), the stochastic integral with respect to the Brownian motion W (t) is:
Z t n−1
X
g (s)dW (s) = lim g (tk ) [W (tk+1 ) − W (tk )] ,
0 n→∞
k=0
where t0 = 0 and tn = t and the limit converges in probability.
• Notice: both the integrand and the integrator are stochastic processes and that the integral is a
random variable.
27
Mean of the stochastic integral
" n−1
#
Z t X
E g (s)dW (s) = E lim g (tk ) [W (tk+1 ) − W (tk )]
0 n→∞
k=0
n−1
X
= lim g (tk )E [W (tk+1 ) − W (tk )]
n→∞
k=0
n−1
X
= lim g (tk ) · 0 = 0
n→∞
k=0
28
Variance of the stochastic integral
"Z
t 2 # " n−1
X
#
E g (s)dW (s) = Var lim g (tk ) [W (tk+1 ) − W (tk )]
0 n→∞
k=0
n−1
X
= lim g 2 (tk )Var [W (tk+1 ) − W (tk )]
n→∞
k=0
n−1
X Z t
= lim g 2 (tk ) (tk+1 − tk ) = g 2 (s)ds
n→∞ 0
k=0
29
Differentiation in stochastic calculus
• In an analogous way that we can define a stochastic integral, we can define a new idea derivative
with respect to Brownian motion.
• Malliavin derivative.
• Applications in finance.
30
31
Stochastic differential equations (SDEs)
as a short-cut to express:
Z t Z t
X (t) = x + µ (t, X (s)) ds + σ (s, X (t)) dW (s)
0 0
32
Example I: Brownian motion with drift
where:
Z t Z t
X (t) = x0 + µds + σdW (s)
0 0
= x0 + µt + σW (t)
33
Example II: Ornstein-Uhlenbeck process
• Named after Leonard Ornstein and George Eugene Uhlenbeck, although in economics and finance is
a.k.a. the Vašı́ček model of interest rates (Vašı́ček, 1977).
and
σ2
1 − e −2θt
Var [X (t)] =
2θ
• Except in a few cases (such as the ones before), we do not know how to get an analytic solution for a
SDE.
• Given a SDE:
dX (t) = µ (t, X (t)) dt + σ (t, X (t)) dW (t), X (0) = x,
it can be approximated by:
35
Euler–Maruyama method (Proof)
• The smaller the ∆t, the better the method will work.
36
Stochastic calculus
and:
2
Var W (t)2 = E W (t)4 − E W (t)2 = 2t 2 t
| {z }
3t 2
37
Functions of stochastic processes: Itô’s formula
df ∂f ∂f dx ∂f ∂f
= + =⇒ df = dt + dx
dt ∂t ∂x dt ∂t ∂x
we get:
1 ∂2f 2
∂f ∂f ∂f
df = + µ+ 2
σ dt+ σdW
∂t ∂x 2 ∂x ∂x
38
Itô’s formula: proof
• Then:
1 ∂2f 2
∂f ∂f ∂f
df = + µ+ σ dt + σdW
∂t ∂x 2 ∂x 2 ∂x
39
Multidimensional Itô’s formula
dXi (t) = µi (t, X1 (t), ..., Xn (t)) dt + σi (t, X1 (t), ..., Xn (t)) dWi (t),
i = 1, ..., n,
then
n n n
∂f X ∂f 1 X X ∂2f
df = dt + dXi + dXi dXj
∂t ∂xi 2 ∂xi ∂xj
i=1 i=1 j=1
40
Application: Geometric Brownian motion (GBM)
where Z t Z t
X (t) = x0 + µX (s)ds + σX (s)dW (s)
0 0
41
GBM solution using Itôs formula
• Therefore:
1 2
X (t) = x0 e (µ− 2 σ )t+σW (t)
42
Dynamic programming with
stochastic processes
The problem
• An agent maximizes: Z ∞
V0 (x) = max E0 e −ρt u (αt , Xt ) dt,
{αt }t≥0 0
subject to:
dXt = µt (Xt , αt ) dt + σt (Xt , αt ) dWt , X0 = x.
• σ (·) : A × X → RN .
• We consider feedback control laws αt = αt (Xt ) (no improvement possible if they depend on the
filtration Ft ).
43
HJB equation with SDEs
N N
∂2V
∂V X ∂V 1 X
σt2 (x, α) n1 ,n2
ρVt (x) = + max u (α, x) + µt,n (x, α) + ,
∂t α
n=1
∂xn 2 n ,n =1 ∂xn1 ∂xn2
1 2
where σt2 (x, α) = σt (x, α) σt> (x, α) ∈ RN×N is the variance-covariance matrix.
44
HJB with SDEs: proof
2. Take the derivative with respect to t, apply Itô’s formula and take limt→t0 :
" #
Et0 d e −ρ(t−t0 ) V (t, Xt )
−ρ(t−t0 )
0 = lim max e u (αt , x) +
t→t0 αt dt
Notice:
σ2 ∂ 2 V
h i ∂V ∂V
Et0 d e −ρ(t−t0 ) V (t, Xt ) = Et0 e −ρ(t−t0 ) −ρV + +µ + dt
∂t ∂x 2 ∂x 2
∂V
+e −ρ(t−t0 ) Et0 σ dWt
∂x
| {z }
0
45
The infinitesimal generator
E0 [f (Xt )] − f (x)
Af = lim
t↓0 t
N N
X ∂f 1 X ∂2f
σ 2 n1 ,n2
= µn +
n=1
∂xt,n 2 n ,n =1 ∂xn1 ∂xn2
1 2
• Intuitively: the infinitesimal generator describes the movement of the process in an infinitesimal time
interval.
46
Boundary conditions
• The boundary conditions of the HJB equation are not free to be chosen, they are imposed by the
dynamics of the state at the boundary ∂X.
dV
1. Reflection barrier: The process is reflected at the boundary: dx
= 0.
∂X
2. Absorbing barrier: The state jumps at a different point y when the barrier is reached: V (x) = V (y ).
∂X
3. State constraint: The policy αt guarantees that the process does not abandon the boundary.
47
Example: Merton portfolio model
by investing in ∆t shares of a stock (GBM) and saving the rest in a bond with return r :
dSt = µSt dt + σSt dWt
dBt = rBt dt
48
Merton model: The HJB equation
49
Solution to Merton portfolio model
50
The case with Poisson processes
• The HJB can also be solved for the case of Poisson shocks.
• Zt is a two-state continuous-time Markov chain Zt ∈ {z1 , z2 }. The process jumps from state 1 to
state 2 with intensity λ1 and vice-versa with intensity λ2 .
• We can have jump-diffusion processes (Lévy processes): HJB includes the two terms (volatility and
jumps).
51
Viscosity solutions
• Relevant notion of “solutions” to HJB introduced by Pierre-Louis Lions and Michael G. Crandall in
1983 in the context of PDEs.
• More concretely, we want to allow for points of non-differentiability of the value function.
52
What is a viscosity solution?
• There are different concepts of what a “solution” to a PDE F x, Dw (x), D 2 w (x) = 0, x ∈ X is:
2. Weak solutions. There is a function u ∈ H 1 (X ) (Sobolev space) such that for any function φ ∈ H 1 (X ),
then X F x, Du(x), D 2 u(x) φ(x)dx = 0, x ∈ X .
R
3. Viscosity solutions. There is a locally bounded u that is both a subsolution and a supersolution of
F x, Dw (x), D 2 w (x) = 0, x ∈ X .
• If it exists, it is unique.
53
Subsolutions and supersolutions
54
More on viscosity solutions
• Check, for more background, User’s Guide to Viscosity Solutions of Second Order Partial Differential
Equations by Michael G. Crandall, Hitoshi Ishii, and Pierre-louis Lions.
• Also, Controlled Markov Processes and Viscosity Solutions by Wendell H. Fleming and Halil Mete
Soner.
55
Finite difference method
Solving dynamic programming problems = solving PDEs
with a transversality condition limT →∞ e −ρT VT (x) = 0, and some boundary conditions defined by
the dynamics of Xt .
56
Overview of methods to solve PDEs
1. Perturbation: consider a Taylor expansion of order n to solve the PDEs around the deterministic
steady state (not covered here, similar to discrete time).
3. Projection (Galerkin): project the value function over a subspace of functions (non-linear version
covered later in the course).
4. Semi-Lagragian. Transform it into a discrete-time problem (not covered here, well known to
economists)
57
A (limited) comparison from Parra-Álvarez (2018)
58
Numerical advantages of continuous-time methods: Preview
1. “Static” first order conditions. Optimal policies only depend on the current value function:
N N
∂u X ∂µn ∂V 1 X ∂ ∂2V
σt2 (x, α) n1 ,n2
+ + =0
∂α n=1 ∂α ∂xn 2 n ,n =1 ∂α ∂xn1 ∂xn2
1 2
4. Convenient way to deal with optimal stopping and impulse control problems (more on this later
today).
59
Our benchmark: consumption-savings with incomplete markets
• An agent maximizes: Z ∞
−ρt
max E0 e u(ct )dt ,
{ct }t≥0 0
subject to:
dat = (zt + rat − ct ) dt, a0 = ā
where zt ∈ {z1 , z2 } is a Markov chain with intensities z1 → z2 : λ1 and z2 → z1 : λ2 .
60
The Hamilton-Jacobi-Bellman equation
ρvi (a) = max {u(c) + si (a) vi0 (a)} + λi (vj (a) − vi (a)) ,
c
61
How can we solve it?
• TIn particular, we employ an upwind finite difference scheme (Achdou et al., 2017).
62
Grid
• We approximate the value function v (a) on a finite grid with step ∆a : a ∈ {a1 , ..., aJ }, where
aj = aj−1 + ∆a = a1 + (j − 1) ∆a
63
Finite differences
64
Forward and backward approximations
65
Upwind scheme
−1
• The choice of ∂F vi,j or ∂B vi,j depends on the sign of the drift function si (a) = zi + ra − (u 0 ) (vi0 (a)):
−1 −1
1. If siF (aj ) ≡ zi + raj − (u 0 ) (∂F vi,j ) > 0 −→ ci,j = (u 0 ) (∂F vi,j ).
−1 −1
2. Else, if siB (aj ) ≡ zi + raj − (u 0 ) (∂B vi,j ) < 0 −→ ci,j = (u 0 ) (∂B vi,j ).
66
HJB approximation, I
67
HJB approximation, II
68
Boundary conditions
69
Matrix notation
• The HJB is a system of 2J linear equations which can be written in matrix notation as:
1
v n+1 − v n + ρv n+1 = u n + An v n+1
∆
v = u + βΠv ,
1
where Π = I + (1−ρ) A and β = (1 − ρ) .
70
Matrix A
n n
y1,1 z1,1 0 ··· λ1 0 0 ··· 0
n n n
x1,2 y1,2 z1,2 ··· 0 λ1 0 ··· 0
n n n
0 x1,3 y1,3 z1,3 ··· 0 λ1 ··· 0
.. .. .. .. .. .. .. .. ..
. . . . . . . . .
..
. n n
n
A =
0 x1,J y1,J 0 0 0 0 λ1
n n
λ2 0 0 ··· y2,1 z2,1 0 ··· 0
n n n
0 λ2 0 ··· x2,2 y2,2 z2,2 0 ···
n n n
λ2 ···
0 0 0 x2,3 y2,3 z2,3 0
.. .. ..
.. .. .. .. .. ..
. . . . . . . . .
n n
0 0 0 λ2 0 ··· 0 x2,J y2,J
71
How to solve it
n
n+1
u(c1,1 ) v1,1
.. ..
.
.
u(c n ) n+1
v1,J
• Given u n = 1,J
, v n+1 = n+1 ,
n
u(c2,1 ) v2,1
.. ..
. .
n n+1
u(c2,J ) v2,J
the system can in turn be written as:
1 1 n
B n v n+1 = b n , Bn = + ρ I − An , bn = u n + v
∆ ∆
72
The algorithm
0 u(zi +raj )
1. Begin with an initial guess vi,j = ρ .
2. Set n = 0.
3. Then:
n n n
3.1 Policy update: Compute ∂F vi.j , ∂B vi.j , and ci,j .
n+1
3.2 Value update: Compute vi,j solving the linear system of equations.
n+1 n
3.3 Check: If vi,j is close enough to vi,j , stop. If not, set n := n + 1 and go to 1.
73
Results
4 1.15
3
1.1
2
1.05
0.95
-1
0.9
-2
-3 0.85
-2 -1 0 1 2 3 4 -2 -1 0 1 2 3 4
74
The case with diffusions
75
The new grid
• We approximate the value function V (a, z) on a finite grid with steps ∆a and ∆z : a ∈ {a1 , ..., aI },
z ∈ {z1 , ..., zJ }.
76
HJB approximation
n+1 n
Vi,j − Vi,j n+1 n n+1 n+1 n+1 n+1 n+1
+ ρVi,j = u(ci,j ) + Vi−1,j %i,j + Vi,j βi,j + Vi+1,j χi,j + Vi,j−1 ξ + Vi,j+1 ςj ,
∆
n
si,j,B 1si,j,B
n <0
%i,j = − ,
∆a
n n
si,j,F 1si,j,F
n >0 si,j,B 1si,j,B
n <0 θ(ẑ − zj ) σ2
βi,j = − + − − 2,
∆a ∆a ∆z (∆z)
n
si,j,F 1si,j,F
n >0
χi,j = ,
∆a
2
σ
ξ = 2,
2 (∆z)
σ2 θ(ẑ − zj )
ςj = 2 +
2 (∆z) ∆z
77
Boundary conditions
78
The problem
80
Why does the finite difference method work?
• The finite difference method converges to the viscosity solution of the HJB as long as it satisfies
three properties:
1. Monotonicity.
2. Stability.
3. Consistency.
• The proposed method does satisfy them (proof too long, check Fleming and Soner, 2006).
81