50
Deterministic Systems Functional Analysis Stochastic Systems Numerical Methods Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017

Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Numerical MethodsLecture 2: Dynamic Programming

Zachary R. Stangebye

University of Notre Dame

Fall 2017

Page 2: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Deterministic Systems

• Multi-period models are workhorse of macroeconomics• Agents make decisions each period, rationally forecasting

behavior in future periods

• Example: Multi-Period Consumption-Saving Model

maxctTt=0≥0,bt+1T−1

t=0

T∑t=0

βtu(ct)

s.t. ct + bt+1 = yt + (1 + r)bt for t < T

cT = yT + (1 + r)bT

• Note b0 and ytTt=0 are given

• Cannot save or borrow in last period

Page 3: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Solution Method: Backward Induction

1. Find optimal behavior in last period• Note this will be a function of bT

2. Find behavior in penultimate period, using optimal behaviorin next period• Again, function of bT−1

3. Find behavior in period before that . . .

4. Continue until period 0

Page 4: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Value Functions

• Helpful tool is to define Value Functions along the way

• For any t < T , we can define it as follows:

Vt(bt) = maxcsTs=t ,bs+1T−1

s=t

T∑s=t

βs−tu(cs)

s.t. cs + bs+1 = ys + (1 + r)bs for s < T

cT = yT + (1 + r)bT

• Note that V0(b0) delivers utility from our original problem

• If c?s (bt)Ts=t , b?s+1(bt)T−1s=t is solution, then

Vt(bt) =T∑s=t

βs−tu(c?s (bt))

Page 5: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Recursive Representation

• With value functions, we can conveniently write the problemin each period as follows:

Vt(bt) = maxbt+1

u (yt + (1 + r)bt − bt+1) + βVt+1(bt+1)

• Once we know VT−1(bT−1), it’s easy to find VT−2(bT−2)and so forth

• At each step, we attain b?t+1(bt). Can find consumption with

c?t (bt) = yt + (1 + r)bt − b?t+1(bt)

• Solution can be found from V0(b0): Can compute policiesalong entire trajectory following this

• This general approach to solving dynamic problems is calledDynamic Programming

Page 6: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Solution Method 1: Grids

• Simplest approach

1. Make a grid over bt for each t: B = b0, b1, . . . , bN2. For each bt on the grid, search over the grid to find the bt+1

that maximizes the recursive value function i.e. ∀bt ∈ B

Vt(bt) = maxbt+1∈B

u (yt + (1 + r)bt − bt+1) + βVt+1(bt+1)

3. Yields solution vector b?t ∈ BN i.e. easy to store

4. Continue until b?0.

• Accuracy (and solution time) increase with N

Page 7: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Example 1: Three Periods

maxc0,c1,c2≥0,b1,b2

u(c0) + βu(c1) + β2u(c2)

• Subject to same constraints as before

• Try two methods

1. Simultaneous solution2. Backward induction/dynamic programming

• Notice when β(1 + r) = 1, it should be that c0 = c1 = c2

• Backward induction scales up more easily than simultaneoussolution as T grows

Page 8: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Solution Method 2: Interpolation

• Grid can sometimes be restrictive, lead to inaccuracies

• Want to be able to pick points off grid

• Linear Interpolation Method

1. Solve period T − 1 on a grid of bT−1, but choosing any bT2. For bT−1 off grid, define the value function as straight line

connecting nearest grid points3. Solve period T − 2 on a grid of bT−2, but choosing any bT−1

4. . . .

• Formula: If bt+1 ∈ (bn, bn+1)

Vt+1(bt+1) = Vt+1(bn)+

[Vt+1(bn+1)− Vt+1(bn)

bn+1 − bn

]×(bt+1−bn)

Page 9: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Linear Interpolation

Page 10: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Extrapolation

• How to deal with points above/below whole grid?

• Two approaches

1. Restrict them in the problem2. Continue first/last interior interpolation lines

• (1) is nice when possible!

• Often (2) is necessary; example later

Page 11: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Other Interpolations

• More sophisticated technique is a spline interpolation

• Splines are piecewise polynomials of order 2 or higher• Idea: Keep function smooth/differentiable at kinks

• Cubic spline most popular: If we have a set (xi , yi )ni=0,

approximate each [xi , xi+1] interval with a cubic

y = ai + bix + cix2 + dix

3

• 4n coefficients: Point conditions and 1st/2nd derivativeconditions =⇒ Linear system

1. yi = ai + bixi + cix2i + dix

3i (i = 1, . . . , n)

2. yi = ai+1 + bi+1xi + ci+1x2i + di+1x

3i (i = 0, . . . , n − 1)

3. bi + 2cixi + 3dix2i = bi+1 + 2ci+1xi + 3di+1x

2i (i = 1, . . . , n− 1)

4. 2ci + 6dixi = 2ci+1 + 6di+1xi (1, . . . , n − 1)

• Two conditions free: Often chosen setting s ′(x0) = s ′(xn) = 0

Page 12: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Life Lessons

• In solving models, always look for model-specific shortcuts

• Often more useful in speeding up computation than anysupercomputer

• In our case, exploit the Euler Equation when β(1 + r) = 1:

u′(ct) = β(1 + r)u′(ct+1) =⇒ ct = c ∀t

• Put this together with the lifetime-budget constraint to getthe solution:

c =1

1− (1 + r)−T−1

(r

1 + r

[(1 + r)b0 +

T∑t=0

(1

1 + r

)t

yt

]

• Faster and better objective than any other method so far!

Page 13: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Extending the Horizon

• Take limit as T →∞...

maxct∞t=0≥0,bt+1T−1

t=0

∞∑t=0

βtu(ct)

s.t. ct + bt+1 = yt + (1 + r)bt

• What happens to last period condition? Need something totie it down• Need to prevent Ponzi schemes: Rolling over borrowed money

ad infinitum• Can achieve infinite utility with Ponzi schemes if not ruled

out...

Page 14: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Ruling Out Ponzi Schemes

• Look at Lifetime BC of finite-horizon case:

NPV (ctTt=0) = (1+r)b0 +NPV (ytTt=0)+

(1

1 + r

)T

BT+1

• To get a ‘sensible’ Lifetime BC, need only that

limT→∞

(1

1 + r

)T

BT+1

i.e. BT+1 cannot grow exponentially at a rate faster than r

• Call this the No-Ponzi Condition• Can be satisfied even if limT→∞ BT+1 > 0

• Past problem plus No-Ponzi Condition is well-defined

Page 15: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Solving

• How do we solve the infinite-horizon problem?• Backward induction directly no good...no terminal period• Not entirely true...more on this later!

• Last finite-horizon method will still work for some utilities e.g.log-utility

EE : ct+1 = β(1 + r)ct

=⇒ NPV (ct∞t=0) = c0

∞∑t=0

βt =c0

1− β

=⇒ c0 = (1− β)× [(1 + r)b0 + NPV (yt∞t=0)]

• Does not require that β(1 + r) = 1

Page 16: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Solving: Shooting Algorithm

• If it doesn’t happen that we can solve as above, we needanother strategy

• Try to solve it forward : Bisection over c0

1. Conjecture a solution for the optimal c0

2. Iterate forward with the budget constraint/Euler Equation3. Check it at a large T : See if No-Ponzi Condition holds

(approximately)• If it holds, we’re done• If bT too large, increase c0 in next guess• If bT too large (negatively), reduce c0 in next guess

• Starting from bt , conjecture a ct and iterate forward with

bt+1 = yt + (1 + r)bt − ct

ct+1 = u′−1

(u′(ct)

β(1 + r)

)Equation (2) may need to be done numerically (not always)

Page 17: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Alternate Model: NCG Model

• Endogenize yt process; save in capital instead of bt

• Solve social planner’s problem (economy efficient)

• yt = f (kt)

1. f (0) = 02. f ′(kt) > 03. f ′′(kt) < 0

• Capital depreciates at rate δ. k0 given

maxct∞t=0,kt+1∞t=0

∞∑t=0

βtu(ct)

s.t. ct + kt+1 = f (kt) + (1− δ)kt

Page 18: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

NCG Model: Solution Characterization

1. Euler Equation

u′(ct) = β[1− δ + f ′(kt+1)]u′(ct+1)

2. Resource Constraint

ct + kt+1 = f (kt) + (1− δ)kt

• Can iterate like before on (c0, k0)

• Terminal condition? Transversality condition

limt→∞

kt+1βtu′(ct) = 0

• Like a FOC ‘at t =∞’• Prevents sub-optimal ‘hoarding’ of capital

Page 19: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

NCG Model: SS Lines and Trajectories

𝒄𝒄

𝒌𝒌 𝒌𝒌

• Steady state lines: Set EE = 0 and BC = 0

• Trajectories easy to derive on either side of SS line

Page 20: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

NCG Model: Shooting Algorithm

• Only SS solution will satisfy TVC in long-run

• Search for c0(k0) that sends system ratcheting to steady state

• This trajectory is unique (saddle-path stable)

• This problem is recursive! Delivers time-invariant solutionalong an endogenous grid:

c?(kt) = ct(kt) ∀kt

• Could interpolate in between endogenous grid points forapproximation to full-solution

Page 21: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

The NCG Model Revisited

• Backward induction? How do we do it without a terminalperiod?

• Recall finite-horizon approach. For any t < T , equivalentproblem:

Vt(kt) = maxkt+1≥0

u(f (kt) + (1− δ)kt − kt+1) + βVt+1(kt+1)

• In infinite-horizon model, t should be irrelevant• Should be the case that

V (k) = maxk′≥0

u(f (k) + (1− δ)k − k ′) + βV (k ′)

• Solution k ′(k) should exactly be k1(k0) in infinite-horizon

Page 22: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Thinking Recursively

• How to solve this model? Try something crazy...

1. Guess any value function, V i (k)2. Derive V i+1(k) by solving (for every k)

V i+1(k) = maxk′≥0

u(f (k) + (1− δ)k − k ′) + βV i (k ′)

3. Continue until supk ||V i+1(k)− V i (k)|| < ε for a small ε > 0

• For this model, it will work every time! Regardless of V 0

• This is called Value Function Iteration

• If it converges in I periods, you’ll have approximations of

1. The value function V (k) = V I (k)2. The policy function k ′(k) = k I (k)

Page 23: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Analysis

• Provable results: k ′(k)

1. k ′(0) > 02. limk→∞ k ′(k) < k

3. ∂k′(k)∂k < 1

• Implies the model converges to a steady state (from eitherside)

Page 24: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Why?

• Why would we expect VFI to work?

• Answer lies in Functional Analysis

• A Functional Space, J, is a set of functions on a givendomain, Ω ⊂ RN i.e. if f ∈ J, then

f : Ω→ R

• A Functional Equation maps functions into functions i.e.H : J1 → J2

• We can write most recursive economic problems as finding afunction, d ∈ J1 such that

H(d) = 0

where 0 is the zero function, not the number zero

Page 25: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Example

• In NCG example, J1 is all functions mapping R+ into R.

1. d = V2. H(d) = 0 ⇐⇒ for all k ≥ 0,

V (k)−[

maxk′≥0

u(f (k) + (1− δ)k − k ′) + βV (k ′)

]= 0

• Can write it equivalently by using Euler Equation

1. d = k ′

2. H(d) = 0 ⇐⇒ for all k ≥ 0,

u′(f (k) + (1− δ)k − k ′(k)

)−

β×[1−δ+f ′(k ′(k))]×u′(f (k ′(k))+(1−δ)k ′(k)−k ′(k ′(k))

)= 0

Page 26: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Fixed Points

• Equivalency to fixed points. If T : J → J, an eq’m can oftenbe described as a d ∈ J such that

Td = d

Notation: Often functional equations are just written as ‘Td ’instead of T (d)

• Completely equivalent to saying Hd = Td − d and sayingHd = 0

• Fixed point approach lends itself to iterative approaches

Page 27: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Metric Spaces

• To characterize things cleanly, zoom out a little bit

• Reference: Stokey, Lucas, and Prescott (1989) Chapter 3

DefinitionA Metric Space is a set S , together with a metric (distancefunction) ρ: S × S → R such that for all x , y , z ∈ S :

1. ρ(x , y) ≥ 0, with equality iff x = y

2. ρ(x , y) = ρ(y , x)

3. ρ(x , z) ≤ ρ(x , y) + ρ(y , z)

• S could be a functional set e.g. f , g ∈ J

• Common metric is the sup-norm:ρ(f , g) = supx∈Ω |f (x)− g(x)|

Page 28: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Completeness

• A few more definitions

DefinitionA sequence xn∞n=0 in S is a Cauchy sequence if for every ε > 0,∃Nε such that

ρ(xn, xm) < ε ∀n,m ≥ Nε

DefinitionA metric space (S , ρ) is complete if every Cauchy sequence in Sconverges to an element in S .

• Complete metric space ≈ A closed interval on the real line (asopposed to an open one)

Page 29: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

The Contraction Mapping Theorem

DefinitionLet (S , ρ) be a metric space and T : S → S . T is a contractionmapping with modulus β if for some β ∈ (0, 1),ρ(Tx ,Ty) ≤ βρ(x , y) for all x , y ∈ S .

• If I apply my mapping to any two items in the set, those twoelements always get closer together

Theorem (Contraction Mapping Theorem)

If (S , ρ) is a complete metric space and T : S → S is a contractionmapping with modulus β, then

1. T has exactly one fixed point, ν ∈ S

2. For any ν0 ∈ S , ρ(T nν0, ν) ≤ βnρ(ν0, ν) for n = 0, 1, 2, . . .

Page 30: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Application

• If we have a contraction mapping...great!

• We know that limn→∞ βnρ(ν0, ν) = 0 since β < 1

• Implies limn→∞ T nν0 = ν• i.e. repeated iteration will eventually get us to the fixed

point/equilibrium

• How do we know if it’s a contraction?...

Page 31: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Application

Theorem (Blackwell’s Sufficiency Theorem)

Let X ⊂ Rl and let B(X ) be a space of bounded functionsf : X → R with the sup-norm. Let T : B(X )→ B(X ) be anoperator satisfying

1. (Monotonicity) f , g ∈ B(X ) and f (x) ≤ g(x) for all x ∈ Ximplies (Tf )(x) ≤ (Tg)(x) for all x ∈ X

2. (Discounting) There exists some β ∈ (0, 1) such that

[T (f + a)](x) ≤ (Tf )(x) + βa, ∀f ∈ B(X ), a ≥ 0, x ∈ X

Then T is a contraction with modulus β

Page 32: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Back the NCG Model

• Define TV as follows: For any k ∈ R+

(TV )(k) = maxk ′≥0

u(f (k) + (1− δ)k − k ′) + βV (k ′)

• Check Blackwell’s conditions

1. Let VL(k) ≤ VH(k) for all k . Easy to see thatTVL(k) ≤ TVH(k) for all k

2. [T (V + a)](k) ≤ (TV )(k) + βa for any positive a

• Both conditions satisfied! Repeatedly applying T i.e. VFI isguaranteed to converge to unique solution

Page 33: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Example 2: Adding Shocks

• Real Business Cycle Model• NCG model with new production function

yt = At f (kt)

• At is total factor productivity: At = exp(zt) and

zt = ρzt−1 + εt

• Recursive representation:

V (A, k) = maxk′≥0

u(Af (k) + (1− δ)k − k ′) + βEA|A[V (A, k ′)]

• Two states now: Capital stock and productivity

• Still satisfies Blackwell’s sufficiency conditions

Page 34: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

RBC Model: Solution Approach 1

1. Tauchenize zt shock: z ∈ z1, z2, . . . , zN2. Cubic spline interpolation across k for each zi

• Delivers a collection of continuous, differentiable functions,Vi (k)Ni=1

• Vi (k) ≈ V (exp(zi ), k) for i = 1, 2, . . . ,N• Monotonicity: Vi (k) ≤ Vi+1(k) when zi < zi+1

Page 35: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

RBC Model: Solution Approach 2

1. Create a grid over k ; grid-search maximum

2. Gaussian quadrature expectations over zt (continuous)

• Must be careful...• Policy functions look sensible• Value function not monotone in zt !

• Limitation of grid-search• Grid-search cannot extrapolate• When zt is high, optimal solution almost always k ′ > k• If k is highest grid point...best you can do is k ′ = k

• Sub-optimal behavior =⇒ Low values• Translates to lower k levels since convergence fast and process

persistent

Page 36: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Speeding Things Up 1

• VFI linearly at a rate β

• A little slow for large scale problems

• Speeding up: Many tricks devised over the years

• Approach 1 (Judd [1998]): Policy Function Iteration Hybrid

• Start with guess V i (A, k)

1. Find corresponding policy, k i (A, k) via maximization2. Fix policy function: Apply Bellman (without maximization) M

times• Delivers new V i+1(A, k)

• Takes more iterations than VFI, BUT...• Tends to converge faster than linearly in β...helpful!• Can often speed things up by 10x or more• Still a contraction (convergence guaranteed)

Page 37: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Speeding Things Up 2

• Endogenous Grid Method (Barillas andFernandez-Villaverde [2007])

• Observe FOC:

u′(c?(A, k)) = βEA|A

[Vk(A, k?(A, k))

]• Notice that if k? was fixed,

c?(k?) = u′−1(βEA|A

[Vk(A, k?)

])No maximization/root-finding required!

• Exploit this to speed things up (a lot)• Fix grid over optimal capital choice• Derive grid over current capital endogenously

Page 38: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Endogenous Grid Method: Requirements

• Store two different value functions:1. V i (At , kt+1) = βEAt+1|At

[V istandard(At+1, kt+1)]

• Expected discounted value of having kt+1 tomorrow if shock iszt today

2. V i (At ,Yt) =

maxkt+1 u(Yt − kt+1) + βEAt+1|At[V i

standard(At+1, kt+1)]

• Value function as a function of available market resourcesYt = f (kt) + (1− δ)kt

• Store three different grids

1. Tauchenized grid over zt , Gz

2. Capital grid over investment decisions, Gk

3. Market resources grid, Gy : Yt ∈ Gy if ∃(k , z) ∈ Gk × Gz suchthat Yt = ezt f (kt) + (1− δ)kt

Page 39: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Endogenous Grid Method: Procedure

• Begin with a guess V i (At , kt+1)

1. Compute approximate derivative V ik(At , kt+1) by averageing

slopes of linear interpolation

2. Compute c?(At , kt+1) = u′−1(V ik(At , kt+1))

3. Compute necessary market resourcesY (At , kt+1) = c?(At , kt+1) + kt+1

4. ComputeV i (At ,Y (At , kt+1)) = u(c?(At , kt+1)) + V i (At , kt+1)

5. Compute V i+1(At ,Yt) by interpolating V i (At ,Y (At , kt+1))on GY

6. Compute V i+1(At , kt+1) = βEAt+1|At[V i+1(At ,Yt)]

7. Stop if supi ,j |V i+1(Ai , kj)− V i (Ai , kj)| < ε

Page 40: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Endogenous Grid Method

• Once done, use root-solver to find endogenous capital grid i.e.k ∈ Gk,state if Y (At , kt+1) = At f (k) + (1− δ)k for some At

and kt+1

• Value function is Vstandard(At , k(At ,Yt)) = V (At ,Yt) for allYt such that Yt = Y (At , kt+1)

• Policy function is the original grid! (with domain beingendogenous grid)

Page 41: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Non-contractions

• Without the CMT...

• Cannot always guarantee a process will converge• Sometimes it does anyway! (count your blessings)• Other times, exploit other features

• Example: Monotonicity• Instead of working with distances in a metric space...• Work with a notion of inequality in an ordered set• Different fixed point theorem, but still works!

Page 42: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Partially Ordered Sets

DefinitionA Partially Ordered Set, (X ,≤), is a set taken together with apartial order i.e.

1. For any a ∈ X , a ≤ a (Reflexivity)

2. For any a, b ∈ X , a ≤ b and b ≤ a implies a = b(Antisymmetry)

3. For any a, b, c ∈ X , a ≤ b and b ≤ c implies a ≤ c(Transitivity)

Page 43: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Complete Lattices

DefinitionA partially ordered set, (L,≤), is called a Complete Lattice ifevery subset has a least upper bound and a greatest lower boundin L i.e. for any M ⊂ L,

1. supM ∈ L

2. inf M ∈ L

• Akin to the notion of closedness/boundedness, but there is nodistance metric

Page 44: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Tarski’s Fixed Point Theorem

DefinitionLet (L,≤) be a complete lattice, and suppose T : L→ L is amonotone function i.e. for any x , y ∈ L, the following holds

x ≤ y =⇒ Tx ≤ Ty

Then the set of all fixed points in L for the function T is also acomplete lattice.

• Cool theorem! Some interesting implications

1. There exists a greatest (u) and a least (u) fixed point(possibly the same; fixed point set non-empty)

2. If x ≤ Tx , then x ≤ u

3. If x ≥ Tx , then x ≥ u

Page 45: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Applying Tarski’s: The Eaton-Gersovitz/ArellanoModel

• Based on NCG/RBC model, but a few simple differences

1. Gov’t controls all consumption decisions2. No investment (endowment economy)3. Foreigners buy debt4. Gov’t monopolist in debt market/foreign lenders competitive

• Internalizes price changes from debt issuance

5. Gov’t cannot commit to repay debt• Will default if ex-post optimal• If default, excluded from credit markets forever i.e. ct = yt

and pay default cost

Page 46: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

The Arellano Model: Sovereign

• Sovereign wants to solve similar Bellman equation

V (y , b) = maxb′

u(y − b + q(y , b′)b′) + βE [V (y , b′)]

whereV (y , b) = maxV (y , b),X (y)

and X (y) is the utility value of defaulting in state y

X (y) = u(y × [1− φ(y)]) + βE [X (y)]

Page 47: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

The Arellano Model: Lenders

• Foreign lenders are risk-neutral, deep-pocketed

• Competitively price debt =⇒• Can get a risk-free return, r• Can invest in risky sovereign debt (may get defaulted on)

q(y , b′) =Ey |y [1V (y , b′) ≥ X (y)]

1 + r

Page 48: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Solving the Arellano Model

• That’s it! Pretty simple, BUT...• VFI is no longer a contraction• Discounting in Blackwell sufficiency no longer holds, since V

enters into q

• Alternative approach via Tarski: Iterate on qi

1. Define Q to be a complete lattice of decreasing functions i.e.

q ∈ Q then q : Y × B →[

0,1

1 + r

]2. Take our order to be the absolute order i.e. if q1, q2 ∈ Q

q1 ≤ q2 ⇐⇒ q1(y , b) ≤ q2(y , b) ∀(y , b) ∈ Y × B

Page 49: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Solving the Arellano Model

• Iterative operator T defined as follows• Fixing q, the sovereign’s Bellman is a contraction: qi =⇒ V i

• Update step

(Tqi )(y , b) =Ey |y

[1V i (y , b′) ≥ X (y)

]1 + r

Proposition

The operator T is a monotone self-map on Q

• Easy to show Tq must be decreasing, self-map

• Monotonicity follows from fact that if q1 ≤ q2, then V1 ≤ V2

since prices are always higher in world 2

Page 50: Numerical Methods Lecture 2: Dynamic Programming · 2019. 3. 29. · Lecture 2: Dynamic Programming Zachary R. Stangebye University of Notre Dame Fall 2017. Deterministic SystemsFunctional

Deterministic Systems Functional Analysis Stochastic Systems

Applying Tarski’s

• T is a monotone operator on a complete lattice, so Tarski’stheorem applies• Get that an equilibrium exists (may be many)

• To find it is easy: Repeatedly apply T from either top orbottom• Set q0 = 0; know q0 ≤ qeq, which implies Tq0 ≤ Tqeq = qeq

limn→∞

T nq0 ≤ T nqeq = qeq

• Gets bigger with each iteration• Must converge to something: Will converge to lowest fixed

point (worst eq’m)• Same logic applies starting from best i.e. q0 = 1

1+r

• Will converge to best