an introduction to dynamic programming - …jin.cao.userweb.mwn.de/dynamic_programming_10.pdf · an...

21
An Introduction to Dynamic Programming Jin Cao Macroeconomics (Research, WS10/11) November, 2010

Upload: hakhuong

Post on 22-Aug-2018

245 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

An Introduction to Dynamic Programming

Jin Cao

Macroeconomics (Research, WS10/11)

November, 2010

Page 2: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Outline

MotivationWhy Dynamic ProgrammingBasic Idea

Optimality ConditionsThe First Order ConditionThe Envelope ConditionAn Example: Brock-Mirman Model

Value Function and Policy FunctionGuess and VerifyValue Function IterationNumerical Simulation

2 of 21

Page 3: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Why dynamic programming?

� Lagrangian and optimal control are able to deal with most of thedynamic optimization problems, even for the cases where dynamicprogramming fails.

� However, dynamic programming has become widely used becauseof its appealing characteristics:� Recursive feature: flexible, and significantly reducing the complexity of

the problems;� Convergence in the value function: quantitative analysis, especially

numerical simulation;� Although based on profound theories, numerical computation is rather

simple as well as full-fledged. — At least one can get numericalresults.

� In this presentation: How to USE dynamic programming methods.

3 of 21

Page 4: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

The prototype problem

� Consider a general discrete-time optimization problem

max{ct ,kt+1}+∞t=0

+∞∑t=0

βtu(ct)

s.t. kt+1 = f (ct , kt).

� Now define a function (mostly, bounded in value)

V (kt) = maxct ,kt+1

+∞∑i=0

βiu(ct+i ) = maxct ,kt+1

{u(ct) + β

+∞∑i=0

βiu(ct+i+1)

}= max

ct ,kt+1

{u(ct) + βV (kt+1)}

s.t. kt+1 = f (ct , kt).

4 of 21

Page 5: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Basic idea: recursive structure

� Recursive nature of the problem — same problem for all t!Bellman equation

V (kt) = maxct ,kt+1

{u(ct) + βV (kt+1)}

� More jargons, similar as before: State variable kt , control variablect , transition equation (law of motion), value function V (kt),policy function ct = h(kt).

� Now the problem turns out to be a one-shot optimization problem,given the transition equation!

5 of 21

Page 6: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

The first order condition

� The next step: finding the optimality conditions!

� Trivial to see: FOC of the maximization problem.

V (kt) = maxct ,kt+1

{u(ct) + βV (kt+1)} −→ ∂u(ct)

∂kt+1+ β

∂V (kt+1)

∂kt+1= 0.

� Reason: Decision problem at period t is to allocate resourcesbetween ct and kt+1. V (kt) is an optimized value for each periodt — FOC with respect to kt+1 should hold.

� To get Euler equation, still need a second equation to eliminateV (·) term.

6 of 21

Page 7: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

The envelope condition

� The Envelope Theorem

TheoremSuppose that value function m(a) is defined as following:

m(a) = maxx

f (x(a), a).

Then the total derivative of m(a) with respect to a equals the partialderivative of f (x(a), a) with respect to a, if f (x(a), a) is evaluated atx = x(a) that maximizes f (x(a), a), i.e.

dm(a)

da=∂f (x(a), a)

∂a

∣∣∣∣x=x(a)

.

7 of 21

Page 8: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

The envelope condition

� Then the envelope condition of the maximization problem.

V (kt) = maxct ,kt+1

{u(ct) + βV (kt+1)} −→ ∂V (kt)

∂kt=∂u(ct)

∂kt.

� Combine with the FOC: update and eliminate V (·)

∂u(ct)

∂kt+1+ β

∂V (kt+1)

∂kt+1= 0.

� To see how it works? An example.

8 of 21

Page 9: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Example: deterministic Brock-Mirman model

� Consider the following social planner’s problem:

max{ct ,kt}+∞t=0

+∞∑t=0

βt ln ct

s.t. kt+1 = kαt − ct .

� Bellman equation:

V (k) = maxk ′

{ln c + βV (k ′)

}s.t. c + k ′ = kα.

9 of 21

Page 10: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Example: optimality conditions

� Use the transition equation to replace c

V (k) = maxk ′

{ln(kα − k ′) + βV (k ′)

}.

� The first order condition and the envelope condition

− 1c + βV ′(k ′) = 0

V ′(k) = 1cαkα−1 → V ′(k ′) = 1

c ′αk ′α−1

� Euler equation, same as one can get from Hamiltonian:c ′

c = αβk ′α−1.

10 of 21

Page 11: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

What’s new: making more senses

� If dynamic programming simply arrives at the same outcome asHamiltonian, then one doesn’t have to bother with it.

� However, the marginal return from dynamic programming becomeshigher if one explores deeper. Take a closer look:� Value function? Tells you how different paths may affect your value

on the entire time horizon. Policy evaluation!� Policy function? Tells you explicitly how you make optimal choice in

each period, given the state!

� Strategy: Determine V (k), and optimize to get ct = h(kt). Noteasy...� Analytical — not always tractable, or� Numerical — in principle, always works.

11 of 21

Page 12: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Mickey Mouse models: guess and verify

� Brock-Mirman model:

V (k) = maxk ′

{ln c + βV (k ′)

}s.t. c + k ′ = kα.

� Guess: V (k) = A + B ln k . Verify with the first order condition

−1

c+ βV ′(k ′) = − 1

kα − k ′+βB

k ′= 0.

� Solve to get k ′ = βB1+βB kα, as well as c = 1

1+βB kα. Then applythese equations back to Bellman.

12 of 21

Page 13: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Mickey Mouse models: guess and verify

� Compare with our conjecture V (k) = A + B ln k

V (k) = lnβB + βA− (1 + βB) ln(1 + βB) + α(1 + βB) ln k .

� Solve to get the value of the parameters and the policy function

B =α

1− αβ,

A =1

1− β

[ln(1− αβ) +

αβ

1− αβlnαβ

],

ct =1

1 + βBkαt = (1− αβ)kαt .

13 of 21

Page 14: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Value function at the end of the world

� More general approach: To find the value function in the limit.Suppose that the world ends after some finite peroid T . Thensurely V (kT+1) = 0 as well as cT = kαT , and kT+1 = 0.

� Apply these in the Bellman equation

V (kT ) = ln kαT + βV (kT+1) = ln kαT .

� Then take one period backward, the agent has to solve

V (kT−1) = maxcT−1,kT

{ln(cT−1) + βV (kT )} .

14 of 21

Page 15: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Value function before the end of the world

� Insert V (kT ) and solve for V (kT−1) in terms of kT−1

V (kT−1) = αβ ln(αβ)− (1 + αβ) ln(1 + αβ) + (1 + αβ) ln kαT−1.

� In the limit T → +∞ one can show that the value functionconverges to

V (kt) = maxct ,kt+1

{ln ct + β

[1

1− β

(ln(1− αβ) +

αβ

1− αβlnαβ

)+

α

1− αβln kt+1

]}.

� Then solve this static maximization problem to get the policyfunction

ct = (1− αβ)kαt .

15 of 21

Page 16: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Numerical simulation

� How if the problem gets more complicated? Consider

V (k) = maxc,k ′

{u(c) + βV (k ′)

}s.t. c + k ′ = Akα − δk .

� No open form solution! But... let the computer do the valuefunction iteration.� Discretize the state space, and determine its range;� Start from the end of the world, and do the backward induction� Until the change in value function meets the convergence criterion.

16 of 21

Page 17: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Numerical simulation: value function

� Take β = 0.6, A = 20, α = 0.3, δ = 0.5 and run MATLAB

0 2 4 6 8 10 126

6.5

7

7.5

8

8.5

9

Capital

Util

ityValue Function

17 of 21

Page 18: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Numerical simulation: convergence

� ... and see how it converges ...

0 2 4 6 8 10 121

2

3

4

5

6

7

8

9

Capital

Util

ity

Value Function

18 of 21

Page 19: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Numerical simulation: steady state

� ... and find the steady state.

0 2 4 6 8 10 120

2

4

6

8

10

12

Capital Today

Cap

ital T

omor

row

Policy Function

19 of 21

Page 20: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

Summary

� If one only needs the Euler equation and qualitative reasoning,dynamic programming is no better than Hamiltonian.

� To use dynamic programming, more issues to worry: Recursive?Existence of equilibrium (Blackwell sufficient conditions forcontraction mapping, and fixed point theorem)? Stochastic? ...

� But rewarding if one wants to know more� Flexibility in modelling;� Well developed numerical methods.

� Especially, some interesting new research� Dynamic contract theory, e.g. Marcet & Marimon (1998), Werning

(2008), Doepke (2008);� Computating dynamic equilibrium, e.g. Heer & Maussner (2005), and

dynamic equilibrium econometrics, e.g. Canova (2007);� Stochastic models, e.g. Stachurski (2009), Dixit & Pindyck (1994).

20 of 21

Page 21: An Introduction to Dynamic Programming - …jin.cao.userweb.mwn.de/Dynamic_Programming_10.pdf · An Introduction to Dynamic Programming Jin Cao ... How to USE dynamic programming

For further reading...

Klaus Walde.Applied Intertemporal Optimization.Mimeo, University of Mainz, 2010.

Nancy L. Stokey, Robert E. Lucas with Edward C. PrescottRecursive Methods in Economic Dynamics.Cambridge: Harvard University Press, 1989.

21 of 21