munich graduate program burkhard heer · pdf filemunich graduate program burkhard heer ... the...

393
Computational Economics Munich Graduate Program Burkhard Heer University of Bolzano-Bozen, Italy 4. September 2006 Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 1 / 393

Upload: trankhuong

Post on 06-Feb-2018

221 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Computational EconomicsMunich Graduate Program

Burkhard Heer

University of Bolzano-Bozen, Italy

4. September 2006

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 1 / 393

Page 2: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Objectives of the Course

1 Formulate your own business cycle model2 Compute your own business cycle model with Matlab

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 2 / 393

Page 3: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

References

References in order of importance for the course:

1 Heer, B., and A. Maussner, 2005, Dynamic General Equilibrium Modelling:Computational Methods and Applications, Springer.

2 Miranda, M.J., and P.L. Fackler, 2002, Applied Computational Economics andFinance, MIT Press.

3 Judd, K.L., 1998, Numerical Methods in Economics, MIT Press.4 Burden, R.L., and J.D. Faires, 1993, Numerical Analysis, 5th edition, PWS

Publishing Company.5 Marimon, R., and A. Scott, eds., 1999, Computational Methods for the Study of

Dynamic Economics, Oxford University Press.6 Burnside, C., 1999, Real Business Cycle Models: Linearization and GMM

estimation, 7th revision, notes, World Bank.7 Cooley, T.F., ed., 1995, Frontiers of Business Cycle Research, Princeton University

Press.8 Ljungqvist, L., and T.J. Sargent, 2005, Recursive Macroeconomic Theory, 2nd

edition, MIT Press.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 3 / 393

Page 4: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 4 / 393

Page 5: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 5 / 393

Page 6: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 6 / 393

Page 7: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Ramsey Problem

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 7 / 393

Page 8: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Ramsey Problem

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 8 / 393

Page 9: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Ramsey Problem

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 9 / 393

Page 10: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Ramsey Problem

Ramsey Problem: Ramsey (1928)

The Deterministic Finite-Horizon Ramsey Model

representative agent

lives T + 1 periods

maximizes utility U(C0,C1, . . . ,CT )

produces output with capital Kt in period t :

Yt = F (Kt) (1)

Production Yt in period t can be used for either consumption Ct or next periodcapital stock Kt :

Yt = F (Kt) ≥ Kt+1 + Ct (2)

Initial capital stock K0 is given.

no uncertainty

no labor supply decision

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 10 / 393

Page 11: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Ramsey Problem

Properties of the Production Function

No production without capital:

F (0) = 0

F is twice continuously differentiable

F is strictly increasing, F ′ > 0

F is strictly concave, F ′′ < 0

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 11 / 393

Page 12: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Ramsey Problem

The Kuhn-Tucker ProblemThe Ramsey Problem

max(C0,...,CT )

U(C0, . . . ,CT )

s.t.

Kt+1 + Ct ≤ f (Kt),0 ≤ Ct ,0 ≤ Kt+1,

9=; t = 0, . . . ,T ,

K0 given.

(3)

optimization subject to constraints2 kinds of constraints:

1 equalities2 inequalities

⇒The Kuhn-Tucker theorem provides a set of necessary and sufficient conditions for asolution to exist.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 12 / 393

Page 13: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Kuhn-Tucker Problem

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 13 / 393

Page 14: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Kuhn-Tucker Problem

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 14 / 393

Page 15: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Kuhn-Tucker Problem

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 15 / 393

Page 16: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Kuhn-Tucker Problem

The Kuhn-Tucker ProblemKuhn-Tucker Theorem

Theorem (Kuhn-Tucker)

Let f be a concave C1 function mapping U into R, where U ⊂ Rn is open and convex.For i = 1, . . . , l , let hi : U → R be concave C1 functions. Suppose there is some x ∈ Usuch that

hi(x) > 0, i = 1, . . . , l.

Then x∗ maximizes f over D = {x¯∈ U|hi(x) ≥ 0, i = 1, . . . l} if and only if there is

λ∗ ∈ Rl such that the Kuhn-Tucker first order conditions hold:

∂f (x∗)∂xj

+lX

i=1

λ∗i∂hi(x∗)∂xj

= 0, j = 1, . . . n,

λ∗i ≥ 0 i = 1, . . . , l,

λ∗i hi(x∗) = 0 i = 1, . . . , l.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 16 / 393

Page 17: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Kuhn-Tucker Problem

The Kuhn-Tucker ProblemFirst-Order Conditions of the Ramsey Problem

The Ramsey problem fits the conditions of the Kuhn-Tucker theorem:

0 =∂U(C0, . . . ,CT )

∂Ct− λt + µt , t = 0, . . . ,T , (4a)

0 = −λt + λt+1f ′(Kt+1) + ωt+1, t = 0, . . .T − 1, (4b)

0 = −λT + ωT+1, (4c)

0 = λt (f (Kt)− Ct − Kt+1) , t = 0, . . .T , (4d)

0 = µtCt , t = 0, . . .T , (4e)

0 = ωt+1Kt+1, t = 0, . . .T , (4f)

λt — Lagrange multiplier associated with the resource constraint:

f (Kt)− Ct − Kt+1 ≥ 0

µt — multiplier for Ct ≥ 0ωt+1 — multiplier for Kt+1 ≥ 0.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 17 / 393

Page 18: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Kuhn-Tucker Problem

The Kuhn-Tucker ProblemFirst-Order Conditions of the Ramsey Problem

Assumption: Marginal utility U(C0,C1, . . . ,CT ) goes to ∞ if consumption Ct → 0:

⇒ µt = 0 for all t = 0, . . . ,T (why?), the resource constraint always binds⇒

∂U(C0, . . . ,CT )

∂Ct= λt

⇒ Ct > 0 and f (0) = 0 imply Kt > 0 for t = 0, . . . ,T and KT+1 = 0.⇒ ωt = 0 for t = 1, . . . ,T .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 18 / 393

Page 19: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model The Kuhn-Tucker Problem

The Kuhn-Tucker ProblemFirst-Order Conditions of the Ramsey Problem

Optimal solution:

Kt+1 = f (Kt)− Ct , (5a)

∂U(C0, . . .CT )/∂Ct

∂U(C0, . . .CT )/∂Ct+1= f ′(Kt+1). (5b)

Interpretation:

Resource constraint

Marginal rate of substitution between consumption in two adjacent periods =return on savings

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 19 / 393

Page 20: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model Numerical solution

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 20 / 393

Page 21: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model Numerical solution

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 21 / 393

Page 22: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model Numerical solution

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 22 / 393

Page 23: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model Numerical solution

Numerical Solution of the Finite-Horizon Ramsey Problem

Numerical solution:Calibration: matching empirical observations

1 choice of the functional types2 choice of the parameter values

Computation: solving the numerical problem

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 23 / 393

Page 24: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model Numerical solution

Numerical Solution of the Finite-Horizon Ramsey Problem

Example

Let U be given by a constant elasticity of substitution function

U(C0, . . . ,CT ) :=

(TX

t=0

C%t

)1/%

, % ∈ (−∞, 1],

and define f (Kt) := K αt , α ∈ (0, 1). Given this specification, equations (5) become

Kt+1 = K αt − Ct , t = 0, 1, . . . ,T ,»

Ct

Ct+1

–1−%

αK α−1t+1 = 1, t = 0, 1, . . . ,T − 1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 24 / 393

Page 25: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model Numerical solution

Numerical Solution of the Finite-Horizon Ramsey Problem

If we eliminate consumption in the second set of equations using the first T + 1equations we arrive at a set of T non-linear equations in the T unknowns(K1,K2, . . . ,KT ):

0 =

„K α

1 − K2

K α0 − K1

«1−%

− αK α−11 ,

0 =

„K α

2 − K3

K α1 − K2

«1−%

− αK α−12 ,

...

0 =

„K α

T

K αT−1 − KT

«1−%

− αK α−1T .

(6)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 25 / 393

Page 26: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Deterministic Finite-Horizon Ramsey Model Numerical solution

Reading Assignments and Problems

Reading Assignment

Heer, Maussner, Chapter 1.1.

Problems1 Review the concept of the CES utility function. How can we interpret ρ?2 Formulate the finite-horizon Ramsey with endogenous labor supply. Let utility be a

function of both consumption Ct and labor Nt ≥ 0. Utility in period t is given by:

C1−ηt (1− Nt)

θ(1−η)

1− η

Production is a function of both capital and labor, F (K ,N) = K αN1−α. Capitaldepreciates at rate δ. Compute the first-order conditions.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 26 / 393

Page 27: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations The problem

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 27 / 393

Page 28: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations The problem

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 28 / 393

Page 29: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations The problem

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 29 / 393

Page 30: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations The problem

Nonlinear equations

Problem:How do we find a numerical solution of a non-linear equation?

f (x) = 0

1 Bisection Method2 Newton’s Method

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 30 / 393

Page 31: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Bisection

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 31 / 393

Page 32: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Bisection

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 32 / 393

Page 33: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Bisection

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 33 / 393

Page 34: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Bisection

Bisection MethodThe idea

f (.) is continuous

f (a) · f (b) < 0

⇒ at least one root x in [a, b]

Idea of bisection: Half the interval that brackets the zero

Application: Find the root of f (x) = x3 − 2 on [1, 2]

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 34 / 393

Page 35: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Bisection

Bisection MethodThe Matlab program

The matlab program bisect1.m:

a=1;b=2;tol=1e-10;

s=sign(f(a));x=(a+b)/2;d=(b-a)/2;

while d>tol;d=d/2;if s==sign(f(x))

x=x+d;else

x=x-d;end

end

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 35 / 393

Page 36: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Bisection

Bisection MethodThe Matlab program, cont.

The Matlab program f.m:

function f1 = f(x)f1 = x^3-2;

Problem with Bisection:1 Find two values that bracket the root2 Slowness

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 36 / 393

Page 37: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 37 / 393

Page 38: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 38 / 393

Page 39: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 39 / 393

Page 40: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodThe idea

Idea: Successive linearization

Linear approximation of of f : [a, b] → R at x0:

g0(x) := f (x0) + f ′(x0)(x − x0)

Root of g0(x):

0 = f (x0) + f ′(x0)(x1 − x0) ⇒ x1 = x0 −f (x0)

f ′(x0).

Iteration on the sequence:

xk+1 = xk −f (xk )

f ′(xk ).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 40 / 393

Page 41: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson Method

Rates of Convergence

Suppose limk→∞ xk = x∗ with f (x∗) = 0.We say that xk converges at rate q to x∗ if

limk→∞

‖xk+1 − x∗‖‖xk − x∗‖q <∞. (7)

q = 2: xk converges quadratically

limk→∞

‖xk+1 − x∗‖‖xk − x∗‖ ≤ β ≤ 1,

→ xk converges linearly at rate β.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 41 / 393

Page 42: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodRate of convergence

Theorem

Suppose that f (x) is C2 and that f (x∗) = 0. If x0 is sufficiently close to x∗, f ′(x∗) 6= 0,and |f ′′(x∗)/f ′(x∗)| <∞, the Newton sequence xk converges to x∗, and it isquadratically convergent:

limk→∞

|xk+1 − x∗||xk − x∗|2 <∞.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 42 / 393

Page 43: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodRate of convergence

Proof:

Taylor’s theorem:

f (xk ) = f (x∗) + f ′(x∗)(xk − x∗) +12

f ′′(η(x))(xk − x∗)2

for some function η(x) ∈ [xk , x∗] ∪ [x∗, xk ].⇒

˛xk −

f (xk )

f ′(xk )− x∗

˛= |xk+1 − x∗| = 1

2

˛f ′′(η(x))(xk − x∗)2

f ′(x∗)

˛For any β ∈ (0, 1), if |xk − x∗| is sufficiently small:

|xk+1 − x∗| < β |xk − x∗|

⇒ xk → x∗

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 43 / 393

Page 44: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson Method

Stopping criteria

When shall we stop the algorithm?

Two Problems:

1 "Have we solved the problem?": f (xk ) close to zero2 "Have we ground to a halt?": xk+1 and xk are close together

1 Stop if |f (xk )| < ε.I |f (x)| < 10−5 for all x ∈ [x0, x∗]: ε = 10−3 too largeI f (x) differ greatly over x : ε = 10−3 may be overly restrictive

2 Stop if

|xsi − xs+1

i |1 + |xs

i |≤ ε ∀ i = 1, 2, . . . , n, ε ∈ R++. (8)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 44 / 393

Page 45: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodAlgorithm

Algorithm: Newton’s Method

Purpose: Solve f (x) = 0, where x ∈ R.

Step 1: Initialize: choose x0 ∈ [x , x ].

Step 2: Compute f (x0), f ′(x0) and iterate on the sequence:

xk+1 = xk −f (xk )

f ′(xk ).

Step 3: Check for convergence: if ‖f (xk )‖∞ < ε and/or |xk+1 − xk |/(1 + |xk |) ≤ ε for agiven tolerance ε ∈ R++ stop, else return to step 2.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 45 / 393

Page 46: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson Method

Problems:

1 xk+1 may not be defined2 it may be impossible to derive f ′

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 46 / 393

Page 47: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Numerical Methods: Non-Linear EquationsQuasi Newton

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 47 / 393

Page 48: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Numerical Methods: Non-Linear Equations

Solutions to the problems:

1 Backtrack xs+1 along the direction of f ′(xs) to a point x ′s+1 at which f can beevaluated: See problem 1.

2 Use the slope of the secant in order to compute the derivative:

xs+2 = xs+1 −xs+1 − xs

f (xs+1)− f (xs)

→ Modified or Quasi-Newton method

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 48 / 393

Page 49: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Numerical Methods: Non-Linear EquationsSecant Method

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 49 / 393

Page 50: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Numerical Methods: Non-Linear EquationsNumerical Differentiation

First Difference Formulas

Taylor’s Theorem:

f (x + h) = f (x) + f (1)(x)h + f (2)(ξ)h2

2. (9)

Approximation of the first derivative: forward difference formula

DFD f (x , h) :=f (x + h)− f (x)

h. (10)

The approximation error is proportional to h:˛DFD f (x , h)− f (1)(x)

˛=

˛f (2)(ξ)/2

˛h.

Backward difference formula: −h in place of h.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 50 / 393

Page 51: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Numerical Methods: Non-Linear EquationsNumerical Differentiation

Taylor’s theorem for n = 2, h, and −h:

f (x + h) = f (x) + f (1)(x)h + f (2)(x)h2

2+ f (3)(ξ1)

h3

6, (11a)

f (x − h) = f (x)− f (1)(x)h + f (2)(x)h2

2− f (3)(ξ2)

h3

6, (11b)

Subtract the second line from the first:

f (x + h)− f (x − h) = 2f (1)(x)h +“

f (3)(ξ1) + f (3)(ξ2)” h3

6

⇒ Central difference formula

DCD f (x , h) :=f (x + h)− f (x − h)

2h(12)

C denoteS the maximum of (f (3)(ξ1) + f (3)(ξ2))/6 in [x , x + h]Approximation error is proportional to Ch2 and, thus, of second order.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 51 / 393

Page 52: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Numerical Methods: Non-Linear EquationsNumerical Differentiation

Central difference formula for the second derivative:

D2CD f (x , h) :=

f (x + h) + f (x − h)− 2f (x)

h2 , (13)

Approximation error is bound by Ch and, thus, of first order.

Choice of h

As small as possible? Finite precision of computer arithmetic. Only accurate forthe first 10 digits to the right of the floating point (depending on PC, program).

depending on f (3) (see Heer/Maussner)

rule-of-thumb for two-sided rules: h = max (|x |, 1)ε1/3, (ε is the machine precision)

rule-of-thumb for one-sided rules: h = max (|x |, 1)√ε

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 52 / 393

Page 53: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodExtension to Rn

Assume we want to solve the system of n equations

0=f 1(x1, x2, . . . , xn),

0=f 2(x1, x2, . . . , xn),...=

...,0=f n(x1, x2, . . . , xn),

9>>>=>>>; ⇐⇒ 0 = f(x) (14)

The equivalent to f ′(x) in the multi-variable case is the Jacobian matrix J(x) of partialderivatives of f = [f1, f2, . . . , fn]′ with respect to xi , i = 1, 2, . . . n. We use the notation

f ij :=

∂f i(x)

∂xj

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 53 / 393

Page 54: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodExtension to Rn, Definitions

Jacobian:

J(x) :=

26664f 11 f 1

2 . . . f 1n

f 21 f 2

2 . . . f 2n

......

. . ....

f n1 f n

2 . . . f nn

37775 . (15)

Open ball with center x0 and radius r :

N (x0, r) := {x ∈ Rn : ‖x− x0‖ < r}.

J is said to be Lipschitz on N (x0) of x0 with constant γ if for x1, x2 ∈ N (x0) thefollowing condition holds

‖J(x1)− J(x2)‖ ≤ γ‖x1 − x2‖.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 54 / 393

Page 55: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodExtension to Rn

TheoremLet f : Rn → Rn be continuously differentiable in an open convex set D ⊂ Rn. Assumethat there exists x∗ ∈ Rn and r , β > 0, such that N (x∗, r) ⊂ D, f(x∗) = 0, J(x∗)−1

exists with ‖J(x∗)−1‖ ≤ β, and J Lipschitz with constant γ on N (x∗, r). Then thereexists ε > 0 such that for all x0 ∈ N (x∗, r) the sequence x1, x2, . . . generated by

xk+1 = xk − J(xk)−1f(xk), k = 0, 1, . . . ,

is well defined, converges to x∗, and obeys

‖xk+1 − x∗‖ ≤ βγ‖xk − x∗‖2, k = 0, 1, . . . .

Proof: Dennis and Schnabel (1983)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 55 / 393

Page 56: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodExtension to Rn

Algorithm: Modified Newton-Raphson

Purpose: Solve 0 = f(x), where f = [f1, f2, .., fn]′ and x ∈ Rn.

Step 1: Initialize: choose x0 ∈ [x, x].

Step 2: Compute J(x0) the Jacobian of f at x0 and solve J(x0)dx = −f(x0). Ifx1 = x0 + dx /∈ [x, x] choose λ ∈ (0, 1) such that x2 = x0 + λdx ∈ [x, x] andset x1 = x2.

Step 3: Check for convergence: if ‖f(x1)‖∞ < ε and/or |x1i − x0

i |/(1 + |x0i |) ≤ ε ∀i for a

given tolerance ε ∈ R++ stop, else set x0 = x1 and return to step 2.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 56 / 393

Page 57: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodExtension to Rn

Two Problems:

1 Solution of the system of linear equations:

(x1 − x0)J(x0) ≡ dxJ(x0) = f(x0)

The issue will be taken up in chapter 5 of this course.2 Computation of the Jacobian J(x0). Two solutions:

1 Central differences2 Broyden’s algorithm

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 57 / 393

Page 58: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodExtension to Rn

Central differences:

Approximate the element f ij of the Jacobian matrix at the point x by

f ij :=

∂f i(x)

∂xj' f i(x + ejh)− fi(x− ejh)

2h, (16)

where ej is the unit (row) vector with one in the j–th position and zeros elsewhere.

⇒ n2 computations.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 58 / 393

Page 59: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodExtension to Rn

Broyden’s Algorithm:

Initialize the Jacobian with a guess J(x0) = A0.

Given the points xk and xk−1,

f(xk)− f(xk−1) = Ak (xk − xk−1)

→ does not provide enough conditions for unique matrix Ak .→ no information on vectors orthogonal to (xk − xk−1)

We require

Ak z = J(x0)z, whenever (xk − xk−1)z.

→ details of the computation of Ak : see Miranda/Fackler, p.38→ less accurate, but fewer (n) computations.→ implemented in broyden.m

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 59 / 393

Page 60: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Computation of the Example 1TURNPIKE Property

0 10 20 30 40 50 600.16

0.165

0.17

0.175

0.18

0.185

0.19

0.195

0.2

0.205

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 60 / 393

Page 61: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Computation of the Example 1

Program problem1.m

function y = problem1(x)rho=0.5;:alpha=0.35;T=59;K0=0.10;y=zeros(T,1);x1=zeros(T+2,1);x1(1)=K0;x1(2:T+1)=x;x1(T+2)=0;for i=2:T+1

y(i-1)=(x1(i)^alpha-x1(i+1))/(x1(i-1)^alpha-x1(i));y(i-1)=y(i-1)^(1-rho)-alpha*x1(i)^(alpha-1);

endend

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 61 / 393

Page 62: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Computation of the Example 1

Script example1.m:

clear;T=59;alpha=0.35;K=ones(T,1)*alpha^(1/(1-alpha));K1=zeros(T,1);K1=broyden(’problem1’,K);t1=1:1:T;plot(t1,K1);

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 62 / 393

Page 63: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Computation of the Example 1

Assignment: Program Example 1

1 Create Directory ’/compecon/matlab/nonlinear/’.2 Write the two programs example1.m and problem1.m and store them in the new

directory.3 Change the current directory to ’/compecon/matlab/nonlinear/’.4 Download the toolbox from Fackler’s homepage and store it in the directory

’/compecon/matlab/nonlinear/’.5 Load the program broyden.m in the editor and add the path (’File ⇒ Set Path ⇒

Add Folder’).6 Type ’Example1’ in order to start the program.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 63 / 393

Page 64: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Netwon-Rhapson MethodProblems

Problems with Newton’s Method

1 Starting points needs to be close to the true solution.

Possible remedies:1 Grid Search. The algorithm may have to evaluate the function at a point that results in a

breakdown (e.g. 1/0 or (−2.5)1/2)2 Educative guess3 Genetic Search4 Backstepping

→ diligent discussion in Heer/Maussner

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 64 / 393

Page 65: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Numerical Methods: Non-Linear Equations Newton’s Method

Reading Assignments and ProblemsReading Assignment

Heer, Maussner, Chapter 8.3. and 8.5.Miranda, Fackler, Chapter 3.1.-3.6.

Problems1 Newton-Rhapson

1 Solve the equation

f (x) = x3 − 2 = 0.

Write a MATLAB program that solves the non-linear equation with the help of theNewton-Rhapson algorithm. For this reason, specify the two functions f (x) = x3 − 2.0and f ′(x) = 3x2. Use x0 = 1.0 as a starting value.

2 Solve the equation

f (x) = ln x = 0.

What happens if you use the Newton-Rhapson algorithm with x0 = 5? Write a MATLABprogram that solves the equation with the modified Newton-Rhapson algorithm. Specifyboundaries [a, b] for xk . In order to compute the step size reduce the step size by 1/2whenever xk is outside [a, b].

3 Assume that we are unable to compute the derivative f ′() analytically. Write a programthat computes the derivative f ′() numerically and compute the root of

f (x) = x3 − 2 = 0.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 65 / 393

Page 66: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model The model

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 66 / 393

Page 67: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model The model

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 67 / 393

Page 68: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model The model

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 68 / 393

Page 69: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model The model

Infinite-Horizon Ramsey Model

The Ramsey Model

maxC0,C1,...

U0 =∞Xt=0

βtu(Ct)

s.t.

Kt+1 + Ct ≤ f (Kt),0 ≤ Ct ,0 ≤ Kt+1,

9=; t = 0, 1, . . . ,

K0 given.

(17)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 69 / 393

Page 70: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model The model

Infinite-Horizon Ramsey Model

maximizing of the Lagrange function with respect to C0,C1, . . . ,K1,K2, . . . :

L = βt∞Xt=0

hu(Ct) + λt (f (Kt)− Ct − Kt+1)

+ µtCt + ωt+1Kt+1

i.

First order conditions for maximizing L are given by:

u′(Ct) = λt − µt , (18a)

λt = βλt+1f ′(Kt+1) + ωt+1, (18b)

0 = λt(f (Kt)− Ct − Kt+1), (18c)

0 = µtCt , (18d)

0 = ωt+1Kt+1. (18e)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 70 / 393

Page 71: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model The model

Infinite-Horizon Ramsey Model

Transversality condition:

limt→∞

βtλtKt+1 = 0, (19)

limC→0 u′(C) = ∞

⇒ Euler Equation:

u′(f (Kt)− Kt+1)

u′(f (Kt+1)− Kt+2)− βf ′(Kt+1) = 0. (20)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 71 / 393

Page 72: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 72 / 393

Page 73: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 73 / 393

Page 74: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 74 / 393

Page 75: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey Model

Dynamic Programming

Bellman equation:

v(K ) = max0≤K ′≤f (K )

u(f (K )− K ′) + βv(K ′). (21)

v(.) — value function, time-invariant

The first order condition for this problem is

u′(f (K )− K ∗) = βv ′(K ∗). (22)

v(K ) implies the policy function:

K ∗ = g(K ).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 75 / 393

Page 76: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey ModelDynamic Programming

If u() and f () are strictly increasing, strictly concave and twice continuouslydifferentiable functions, the following results hold:

1 The function v exists, is differentiable, strictly increasing, and strictly concave.2 The policy function g is increasing and differentiable.3 The function v is the limit of the following sequence of steps s = 0, 1, . . . :

v s+1(K ) = max0≤K ′≤f (K )

u(f (K )− K ′) + βv s(K ′),

with v0 = 0.

Proof: Harris (1987)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 76 / 393

Page 77: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey ModelDynamic Programming

Example

Let the one-period utility function u and the production function f be given by

u(C) := ln C

f (K ) := K α, α ∈ (0, 1),

respectively.The policy function K ∗ = g(K ) that solves the Ramsey problem (17) is given by

K ∗ = αβK α.

Furthermore, the value function is linear in ln K and given by

v(K ) = a + b ln K ,

a :=1

1− β

»ln(1− αβ) +

αβ

1− αβlnαβ

–, b :=

α

1− αβ.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 77 / 393

Page 78: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey ModelDynamic Programming

Analytical Solution of the Example

Let v0 = 0, we solve

v1 = max ln(K α − K ′)

yielding K ′ = 0 and v1 = α ln K . In the next step we seek K ′ that solves

v2 = max ln(K α − K ′) + βα ln K ′.

From the first order condition

1K α − K ′ =

αβ

K ′

we get

K ′ =αβ

1 + αβK α,

v2 = α(1 + αβ) ln K + A1,

A1 := ln(1/(1 + αβ)) + αβ ln(αβ/(1 + αβ)).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 78 / 393

Page 79: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey ModelDynamic Programming

The value function in step s = 3 is given by

v3 = max ln(K α − K ′) + βα(1 + αβ) ln K ′ + βA1

yielding

K ′ =αβ + (αβ)2

1 + αβ + (αβ)2 K α,

v3 = α(1 + αβ + (αβ)2) ln K + A2,

A2 = ln»

11 + αβ + (αβ)2

–+

“αβ + (αβ)2

”ln

»αβ + (αβ)2

1 + αβ + (αβ)2

–+ βA1.

Continuing in this fashion we find the policy function in step s given by

K ′ =

Ps−1i=1 (αβ)sPs−1i=0 (αβ)s

K α

with limit s →∞ equal to

K ′ = αβK α.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 79 / 393

Page 80: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey ModelDynamic Programming

⇒ the value function is a linear function of ln K : v = a + b ln K .

Solution for a, b: Method of undetermined coefficients:

maxK ′

ln(K α − K ′) + β(a + b ln K ′)

K ′ =βb

1 + βbK α.

Therefore

v = α(1 + βb)| {z }b

ln K + βa + ln»

11 + βb

–+ βb ln

»βb

1 + βb

–| {z }

a

.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 80 / 393

Page 81: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey ModelDynamic Programming

Equating the constant on the right hand side of this equation to a and the slopeparameter to b, we get:

b = α(1 + βb) ⇒ b =α

1− αβ,

a = βa + ln»

11 + βb

–+ βb ln

»βb

1 + βb

–,

⇒ a =1

1− β

»ln(1− αβ) +

αβ

1− αβlnαβ

–.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 81 / 393

Page 82: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey ModelDynamic Programming

Dynamic Programming versus Euler Equation

Let

K ∗ = g(K ) := argmax0≤K ′≤f (K )

u(f (K )− K ′) + βv(K ′),

and consider the identity

v(K ) = u(f (K )− g(K )) + βv(g(K )).

Differentiation with respect to K yields

v ′(K ) = u′(C)`f ′(K )− g′(K )

´+ βv ′(K ∗)g′(K ) = 0.

Using the first order condition (22), we find

v ′(K ) = u′(C)f ′(K ). (23)

Finally, letting C′ = F (N,K ′)− K ′′ denote next period’s consumption, (22) and (23)may be combined to yield

1 = βu′(f (K ′)− K ′′)

u′(f (K )− K ′)f ′(K ′),

which is identical to the Euler equation (20).Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 82 / 393

Page 83: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey ModelDynamic Programming

Numerical Solution of the Example

1 Value function iteration2 Backward iteration

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 83 / 393

Page 84: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey Model IDynamic Programming

Algorithm: Value Function Iteration 1

Purpose: Find an Approximate Solution of the Policy Function for the Ramsey model(17)

Step 1: Choose a grid of n equally spaced points

G = [K1,K2, . . . ,Kn], Ki < Kj∀i < j = 1, 2, . . . n.

Step 2: Initialize the value function: ∀i = 1, . . . , n set

v0i =

u(f (K ∗)− K ∗)

1− β,

where K ∗ denotes the stationary solution to the continuous valued Ramseyproblem.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 84 / 393

Page 85: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey Model IIDynamic Programming

Step 3: Compute a new value function and associated policy function, v1 and g1,respectively: Put j∗0 ≡ 1. For i = 1, 2, . . . , n, and j∗i−1 find the index j∗i thatmaximizes

u(f (Ki)− Kj) + βv0j

in the set of indices j∗i−1, j∗i−1 + 1, . . . n. Set g1

i = j∗i andv1

i = u(f (Ki)− Kj∗i) + βv0

j∗i.

Step 4: Check for convergence: If ‖v0 − v1‖∞ < ε(1− β), ε ∈ R++ (or if the policyfunction has remained unchanged for a number of consecutive iterations) stop,else set v0 = v1 and g0 = g1 and return to step 3.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 85 / 393

Page 86: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Value Function Iteration

Algorithm: See value1.m, value2.m

Computation of the infinite-horizon Ramsey model with depreciation

Parameter choice: quarterly periods

β = 0.99

σ = 2.0

δ = 0.02

grid: K ∗ ± 0.1 ∗ K ∗

1000 grid points over K

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 86 / 393

Page 87: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Value Function IterationConsumption

5 10 15 20 25 30 35 40 45 501

1.2

1.4

1.6

1.8

2

2.2

2.4

2.6

2.8

capital stock

cons

umpt

ion

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 87 / 393

Page 88: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Value Function IterationSavings

5 10 15 20 25 30 35 40 45 50−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

capital stock

savi

ngs

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 88 / 393

Page 89: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Value Function IterationValue function

5 10 15 20 25 30 35 40 45 5044

46

48

50

52

54

56

58

capital stock

v an

d tv

tvv

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 89 / 393

Page 90: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Value Function Iteration IAccuracy

Accuracy check

We stop the algorithm if the maximum of the absolute difference between the oldand the new value function is less than ε = 0.001.

For this accuracy, the policy function k ′(k) does not change any more.

Question: Is ε small enough?

Accuracy measure: Violation of the Euler equation

For δ = 0, we know the exact solution of k ′(k) and c(k) and can compute thepercentage error.

Given the solution k ′(k), c(k), and c′(k ′) we can compute the residual of the Eulerequation for all k ∈ K:

r = 1− βu′(c′(k ′))u′(c(k))

h1− δ + αk ′α−1

iNotice that we transformed the equation to get a measure-unit free variable.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 90 / 393

Page 91: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Value Function Iteration IIAccuracy

In addition, we may compute the change in the policy function c(k), ∆, that isnecessary in order to fulfill the Euler equation:

f (∆) = 1− βu′(c′(k ′))

u′(c(k) · (1 + ∆))

h1− δ + αk ′α−1

i= 0

→ good measure for accuracy of the policy functions!

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 91 / 393

Page 92: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey Model IDynamic Programming

Algorithm: Value Function Iteration 1

Remarks:

1 A good initial guess speeds up the computation significantly. Try v = 0 instead.2 Make use of the characteristics of the value and policy functions:

1 policy function monotone: for Ki > Ki−1, K ′(Ki ) ≥ K ′(Ki−1)2 value function strictly concave: stop iteration over K ′ if for K ′ = Ki the right-hand side

of the Bellman equation is smaller than for K ′ = Ki−1

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 92 / 393

Page 93: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey Model IDynamic Programming

Binary Search

Purpose: Find the maximum of a strictly concave function f (x) defined over a grid of npoints G = [x1, ..., xn]

Step 1: Initialize: Put imin = 1 and imax = n.

Step 2: Select two points: il = floor(imin + imax)/2 and iu = il + 1, where floor(i)denotes the largest integer smaller or equal to i ∈ R.

Step 3: If f (xiu ) > f (xil ) set imin = il . Otherwise put imax = iu .

Step 4: If imax − imin = 2, stop and choose the largest element among f (ximin ), f (ximin+1),and f (ximax ). Otherwise return to Step 2.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 93 / 393

Page 94: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey Model IDynamic Programming

Algorithm: Value Function Iteration 2

Purpose: Find an Approximate Solution of the Policy Function for the Ramsey model(17)

Step 1: Choose a grid of n equally spaced points

G = [K1,K2, . . . ,Kn], Ki < Kj∀i < j = 1, 2, . . . n.

Step 2: Initialize the value function: ∀i = 1, . . . , n set

v0i =

u(f (K ∗)− K ∗)

1− β,

where K ∗ denotes the stationary solution to the continuous valued Ramseyproblem.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 94 / 393

Page 95: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Dynamic Programming

Infinite-Horizon Ramsey Model IIDynamic Programming

Step 3: Compute a new value function and associated policy function, v1 and g1,respectively: Put j∗0 ≡ 1. For i = 1, 2, . . . , n, and j∗i−1 use Algorithm BinarySearch to find the index j∗i that maximizes

u(f (Ki)− Kj) + βv0j

in the set of indices j∗i−1, j∗i−1 + 1, . . . n. Set g1

i = j∗i andv1

i = u(f (Ki)− Kj∗i) + βv0

j∗i.

Step 4: Check for convergence: If ‖v0 − v1‖∞ < ε(1− β), ε ∈ R++ (or if the policyfunction has remained unchanged for a number of consecutive iterations) stop,else set v0 = v1 and g0 = g1 and return to step 3.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 95 / 393

Page 96: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Transition Dynamics

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 96 / 393

Page 97: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Transition Dynamics

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 97 / 393

Page 98: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Transition Dynamics

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 98 / 393

Page 99: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Transition Dynamics

Infinite-Horizon Ramsey ModelSaddle Path

Dynamics of the Ramsey Model

Kt+1 = f (Kt)− Ct , (24a)

1 = βu′(Ct+1)

u′(Ct)f ′(Kt+1). (24b)

and the transversality condition.

Steady State:

= f ′(K ∗).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 99 / 393

Page 100: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Transition Dynamics

Infinite-Horizon Ramsey ModelSaddle Path

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 100 / 393

Page 101: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 101 / 393

Page 102: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 102 / 393

Page 103: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 103 / 393

Page 104: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Difference Equations

Linear Difference Equations

Most economic data are compiled at a yearly, quarterly, or monthly frequency:

discrete variables x only at equally spaced points in time: x(t), x(t + 1), x(t + 2), . . . .

The first difference of xt , ∆xt , is defined as

∆xt := xt − xt−1,

and further differences are computed according to

∆2xt := ∆xt −∆xt−1 = xt − 2xt−1 + xt−2,

∆3xt := ∆2xt −∆2xt−1 = xt − 3xt−1 + 3xt−2 − xt−3,

...,

∆nxt := ∆n−1xt −∆n−1xt−1.

A difference equation of order n relates the function x to its n differences.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 104 / 393

Page 105: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Difference EquationsLinear Difference Equations

First-Order Linear Difference Equation with Constant Coefficient:

∆xt = xt − xt−1 = axt−1, a ∈ R. (25)

Assume we know the time t = 0 value x0. We can then determine all future (or past)values of xt by iterating forward (or backward) on (25):

x1 = λx0, λ := 1 + a,

x2 = λx1 = λ2x0,

x3 = λx2 = λ3x0,

...,

xt = λxt−1 = λtx0.

Asymptotic stability if |λ| < 1:

limt→∞

xt = 0

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 105 / 393

Page 106: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Difference EquationsLinear Difference Equations

Generalization to n variables x := [x1, x2, . . . , xn]′ ∈ Rn:

xt = Axt−1. (26)

Suppose the matrix possesses n distinct real eigenvalues and associated eigenvectorsv1, v2, . . . , vn.

Let

P = [v1, v2, . . . , vn]

then

Λ =

26664λ1 0 . . . 00 λ2 . . . 0...

.... . .

...0 0 . . . λn

37775 = P−1AP

where Λ is the diagonal matrix with the eigenvalues λ1, λ2, . . . , λn on its main diagonal.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 106 / 393

Page 107: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Difference EquationsLinear Difference Equations

Transformation of the original system xt = Axt−1 to new coordinates y = P−1x:

yt = P−1xt = P−1Axt−1 = P−1APyt−1 = Λyt−1,

with solution

yt = Λty0.

Since

Λt =

26664λt

1 0 . . . 00 λt

2 . . . 0...

.... . .

...0 0 . . . λt

n

37775 ,a necessary and sufficient condition for asymptotic stability of yt and xt = Pyt is that alleigenvalues λi have absolute value of less than unity.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 107 / 393

Page 108: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Difference EquationsLinear Difference Equations

Now assume (without loss of generality) that the first n1 eigenvalues are less than onein absolute value while the remaining n2 = n − n1 eigenvalues exceed one in absolutevalue.

If we are free to choose the initial point y0, we can pick

y0 := [y1, y2, . . . , yn1 , 0, 0, . . . , 0| {z }n2 elements

]′,

for arbitrary yi ∈ R, i = 1, 2, . . . , n1.

⇒ y0 converges to zero.

→ this is also true for all x0 = Py0 of the original system.

The set of all such starting points constitutes the stable eigenspace of the differenceequation (26). In the two-dimensional case, we refer to this space sometimes as thesaddle path.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 108 / 393

Page 109: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Difference EquationsLinear Difference Equations

Complex eigenvalues

λ := α+ βi

In this case one of the columns of P is a complex vector and the respective newcoordinate, say y = y1 + iy2, is a complex number, too.

For a given initial coordinate y0 the solution is given by

(y1t + iy2t) = (α+ iβ)t(y10 + iy20). (27)

which may equivalently be stated as:»y1t

y2t

–= At

»y10

y20

–= r t

»cos(tθ) − sin(tθ)sin(tθ) cos(tθ)

– »y10

y20

–. (28)

with r =pα2 + β2.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 109 / 393

Page 110: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Difference EquationsLinear Difference Equations

Extension to the case of mixed real and complex eigenvalues of multiplicity k ≥ 2:

TheoremLet A be a real square matrix. Then

limt→∞

At = 0n×n

if and only if every eigenvalue of A is less than unity in modulus.

Proof: See Murata (1977), p. 85.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 110 / 393

Page 111: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Difference EquationsNon–Linear Difference Equations

Non–Linear Difference Equations

Let f i : Rn → R, i = 1, 2, . . . , n denote arbitrary differentiable functions.

A system of n non–linear first–order difference equations is defined by the following setof equations:26664

x1t

x2t...

xnt

37775 =

26664f 1(x1 t−1, x2 t−1, . . . , xn t−1)

f 2(x1 t−1, x2 t−1, . . . , xn t−1)...

f n(x1 t−1, x2 t−1, . . . , xn t−1)

37775 , (29)

or

xt = f(xt−1).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 111 / 393

Page 112: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Difference EquationsNon–Linear Difference Equations

Assume there is a rest point x that satisfies

x = f(x).

The behavior of the dynamical system (29) near its rest point can be inferred from theproperties of the linear system

xt = J(x)xt−1.

J denotes the Jacobian matrix of f at x:

J(x) :=

0BBB@f 11 (x) f 1

2 (x) . . . f 1n (x)

f 21 (x) f 2

2 (x) . . . f 2n (x)

......

. . ....

f n1 (x) f n

2 (x) . . . f nn (x)

1CCCA , (30)

where

f ij (x) :=

∂f i(x1, x2, . . . , xn)

∂xj.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 112 / 393

Page 113: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Reading Assignments and Problems I

Reading Assignment

Heer, Maussner, Chapter 1.2. and Chapter 9.1

Problems1 Compute the accuracy of the program value1.m with the help of the percentage

error in the Euler equation. For δ = 0, compare the solution with the analyticalsolution and report the percentage deviation. How does the choice of the periodlength (quarter, year) influence the accuracy of the policy function?

2 Use the Matlab functions tic and toc to compute the time needed to compute theinfinite-horizon Ramsey model with inelastic labor with the help of value functionwhere the value function is initialized i) by zeros, ii) by the steady state value, andiii) by a flat consumption profile.

3 Introduce binary search in the program value2.m in order to speed up thecomputation. Compare with value1.m.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 113 / 393

Page 114: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Infinite-Horizon Ramsey Model Difference Equations

Reading Assignments and Problems II

4 Compute the infinite-horizon Ramsey model with elastic labor supply using valuefunction iteration. Use the following utility function:

u(c, n) =1

1− η

hc1−η(1− n)θ(1−η) − 1

iUse the production function y = kαn1−α. Consider quarters and use theparameter values α = 0.4, β = 0.99, η = 1.5.

1 Calibrate θ so that the steady-state supply of labor n is equal to 0.3.2 Compute the policy functions k ′(k), n(k), and c(k) with the help of value function

iteration. Plot the policy functions.3 Report the maximum absolute Euler equation residual and plot ∆ as a function of k .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 114 / 393

Page 115: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 115 / 393

Page 116: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 116 / 393

Page 117: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 117 / 393

Page 118: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear Algebra

VectorsA real (complex) vector of dimension n is a n-tuple of numbers xi ∈ R (xi ∈ C)i = 1, 2, . . . n, denoted by

x =

26664x1

x2...

xn

37775 .The space of all n-tuples is Rn (Cn).

Vector addition and scalar multiplication are defined by

y = a + bx¯

=

26664a + bx1

a + bx2...

a + bxn

37775 .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 118 / 393

Page 119: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear Algebra

Norms

Norm: measure of distance

Def.: Norm on Rn is a real valued function ‖x‖ that obeys:

‖x‖ ≥ 0 for every x ∈ Rn, and ‖x‖ = 0 if and only if x = 0 ∈ Rn,

‖ax‖ = |a| · ‖x‖ for every x ∈ Rn and a ∈ R,‖x + y‖ ≤ ‖x‖+ ‖y‖ for every x, y ∈ Rn.

(31)

the `∞ or sup norm: ‖x‖∞ := max1≤i≤n

|xi|, where |xi | denotes the absolute value of xi .

the `2 or Euclidean norm: ‖x‖2 :=`Pn

i=1 x2i´1/2

.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 119 / 393

Page 120: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear AlgebraMatrices

A = (aij) :=

26664a11 a12 . . . a1m

a21 a22 . . . a2m...

.... . .

...an1 an2 . . . anm

37775 .If n = m, A is called a square matrix. Other special matrices:2664

a11 0 . . . 00 a22 . . . 0...

.... . .

...0 0 . . . ann

3775diagonal matrix

,

2664a11 a12 . . . a1n0 a22 . . . a2n...

.... . .

...0 0 . . . ann

3775upper triangular matrix

,

26641 0 . . . 00 1 . . . 0...

.... . .

...0 0 . . . 1

3775identity matrix

.

the `2 norm of A is

‖A‖ =

0@ nXj=1

nXi=1

a2ij

1A1/2

.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 120 / 393

Page 121: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear AlgebraMatrices

Matrix addition and scalar multiplication:

C = A + dB =

26664a11 + db11 a12 + db12 . . . a1m + db1m

a21 + db21 a22 + db22 . . . a2m + db2m...

.... . .

...an1 + dbn1 an2 + dbn2 . . . anm + dbnm

37775 (32)

The product of two matrices A ∈ Rn×m and B ∈ Rm×n, is the n × n matrix C = (cij),defined by

cij =mX

k=1

aik bkj . (33)

For suitable matrices A, B, C, and D matrix multiplication satisfies the following rules

AB 6= BA, (34a)

A(B + C) = AB + AC, (34b)

A(BC) = (AB)C, (34c)

A(B + C)D = ABD + ACD. (34d)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 121 / 393

Page 122: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear Algebra

Kronecker product ⊗ of two matrices A, B:

A⊗ B :=

26664a11B a12B . . . a1mBa21B a22B . . . a2mB

......

. . ....

an1B an2B . . . anmB

37775 .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 122 / 393

Page 123: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear Algebra

Trace of a square matrix A: sum of the elements of its main diagonal

trA =nX

i=1

aii . (35)

Determinant of a 2× 2 matrix A: |A| or det(A)

|A| = a11a22 − a12a21. (36)

Recursive formula for computation:

|A| =nX

j=1

aij(−1)i+j |Aij | =nX

i=1

aij(−1)i+j |Aij |, (37)

where Aij is the matrix obtained from A by deleting the i-th row and j-th column.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 123 / 393

Page 124: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear AlgebraThe transpose of A, denoted by A′ or AT :

A′ = (a′ij) = (aji) =

26664a11 a21 . . . an1

a12 a22 . . . an2...

.... . .

...a1m a2m . . . anm

37775 .

Inverse of a square matrix A, denoted A−1 = (aij) solves the problem AA−1 = I. If itexists, the inverse is unique and given by

aij =aij(−1)i+j |Aji |

|A| . (38)

Rules for transpose:

(A′)′ = A, (39a)

(A + B)′ = A′ + B′, (39b)

(AB)′ = B′A′, (39c)

(A−1)′ = (A′)−1. (39d)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 124 / 393

Page 125: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear AlgebraA right eigenvector of A is a vector v that solves

Av = λv ⇔ (A− λI)v = 0. (40)

Similarly, the solution of

v¯′A = λv

¯′

is named a left eigenvector of A.

The condition |A− λI| = 0 results in a polynomial of degree n in λ.These n roots are the eigenvalues of the matrix A.

Eigenvectors are unique up to a scalar multiple and, thus, may be normalized to haveunit length.

Properties of the eigenvalues λi :nX

i=1

λi =nX

i=1

aii , (41a)

nYi=1

λi = |A|. (41b)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 125 / 393

Page 126: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear Algebra

eigenspace

(A− λI)mvm = 0

If there are non-trivial solutions vm for m ≥ 2 but not for m − 1, the vector vm is called ageneralized right eigenvector of rank m for the square matrix A.

The space spanned by the (generalized) eigenvectors of A is called the eigenspace ofA.

The eigenspace can be partitioned in three subspaces formed by generalizedeigenvectors that belong to the eigenvalues with

modulus less than one (stable eigenspace, Es),

modulus equal to one (center eigenspace, Ec),

modulus greater than one (unstable eigenspace, Eu).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 126 / 393

Page 127: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear AlgebraMATLAB application

In MATLAB, enter the matrix A, the vector b, and a vector b = 0 as follows:

A=[-3 2 3; -3 2 1; 3 0 0]b=[10; 8; -3]x=zeros(3,1)

Eigenvalues of A:

>> eig(A)ans =-4.00001.5000 + 0.8660i1.5000 - 0.8660i

Determinant of A:

>> det(A)

ans =-12

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 127 / 393

Page 128: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Review: Basics from Linear Algebra

Review: Linear AlgebraMATLAB application

Inverse of a matrix:

>> inv(A)

ans =

0 0 0.3333-0.2500 0.7500 0.50000.5000 -0.5000 0

Trace: sum of the diagonal:

sum(diag(A))

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 128 / 393

Page 129: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 129 / 393

Page 130: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 130 / 393

Page 131: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 131 / 393

Page 132: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Linear Equations

Problem: How shall we solve Ax = b?

LU and Cholesky Factorization

Consider a system of linear equations

a11x1 + a12x2 + · · ·+ a1nxn = b1,

a21x1 + a22x2 + · · ·+ a2nxn = b2,

... =...,

an1x1 + an2x2 + · · ·+ annxn = bn

9>>>>>=>>>>>;⇔ Ax = b. (42)

Assumption: Square matrix A has full rank

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 132 / 393

Page 133: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Linear Equations

In this case it is possible to factorize A as follows

LU = A,

L =

26666641 0 0 . . . 0

l21 1 0 0 . . . 0l31 l32 1 0 . . . 0...

......

.... . .

...ln1 ln2 ln3 ln4 . . . 1

3777775 , U =

2666664u11 u12 u13 . . . u1n0 u22 u23 . . . u2n0 0 u33 . . . u3n...

.... . .

......

0 0 0 . . . unn

3777775(43)

If A is symmetric and positive definite, its Cholesky factor is the lower triangular matrixL that solves

LL′ = A (44)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 133 / 393

Page 134: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Linear EquationsBoth the LU and the Cholesky factorization can be used to solve the linear system.

Let x := Ux. Then it is easy to solve the system

Lx = x

by forward substitution:

x1 = b1,

x2 = b2 − l21x1,

x3 = b3 − l31x1 − l32x2,

... =...

Given the solution for x, one gets the desired solution for x via backward substitutionfrom Ux = ~x:

xn =xn

unn,

xn−1 =1

un−1 n−1(xn−1 − un−1 nxn) ,

xn−2 =1

un−2 n−2(xn−2 − un−2 n−1xn−1 − un−2 nxn) ,

... =...

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 134 / 393

Page 135: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

LU Decomposition

Computation of the LU decomposition: Idea of Gaussian elimination

Solution of Ax = b:

We pre-multiply the equation Ax = b by a series of matrices M(k−1), k = 1, . . . , n thattransforms the matrix A into an upper-triangular one.

For k = 1: A(1) = A, M(0) = I, b(1) = b.

For k = 2: A(2)x = M(1)A(1)x = M(1)b(1) = b(2), with

M(1) =

2666641 0 . . . 0

− a21a11

1 . . . 0...

.... . .

...− an1

a110 . . . 1

377775 .

Question: How does M(k) look like?

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 135 / 393

Page 136: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

LU Decomposition

If akk = 0, we need to pre-multiply the system by a permutation matrix that changes theorder of the rows. In this case, Mk is replaced by a permutation matrix P.

Let A have the dimension 3× 3. Then PA changes the third and second row of A:

P =

241 0 00 0 10 1 0

35 .The Gaussian elimination results in:

M(n−1) ·M(n−2) . . .M(2) ·M(1)Ax = Ux = M(n−1) ·M(n−2) . . .M(2) ·M(1)b = b(n).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 136 / 393

Page 137: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

LU Decomposition

In order to transform b(n) back into b and reverse these transformations, we need tomultiply the equations by the inverse of the matrix M(k) starting with k = n − 1.

Questions: How do these simple matrices L(k) =“

M(k)”−1

look like?

The final result of this Gaussian elimination: LU-Decompostion

LU = L(1)L(2)L(3) . . . L(n−1) ·M(n−1)M(n−2) . . .M(2)M(1)A = A.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 137 / 393

Page 138: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Linear EquationsMATLAB application

LU-Factorization of A:

>> [L,U]=lu(A)

L =

1 0 01 0 1-1 1 0

U =

-3 2 30 2 30 0 -2

Type LU in MATLAB help index to find out more

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 138 / 393

Page 139: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Linear EquationsMATLAB application

Solution of Ax = b in Matlab: based on LU-decomposition

>> x=A\b

x =

-121

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 139 / 393

Page 140: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

LU DecompositionPivoting Strategies

0.003000x1 + 59.14x2 = 59.17 (45)

5.291x1 − 6.130x2 = 46.78 (46)

has the solution x = (10.0, 1.0)′:

>> A=[0.0030 59.14; 5.291 -6.130]; b=[59.17; 46.78]; x=[10.0; 1.0];>> A*x

ans =

59.170046.7800

>> x=A\b

x =

101

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 140 / 393

Page 141: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

LU DecompositionPivoting Strategies

Assume: Accuracy is only 4 digits

First pivot element: a11 = 0.003000,

Associated multiplier, a21a11

= 5.2910.003000 = 1763.66, rounds to 1764.

After Gaussian elimination, the system is transformed to:

0.003000x1 + 59.14x2 ≈ 59.17

−104300x2 ≈ −104400,

instead of

0.003000x1 + 59.14x2 = 59.17

−104309.376x2 ≈ −104309.376,

The solutions are:

x2 ≈ 1.001

x1 ≈ 59.17− (59.14)(1.001)

0.003000= −10.00

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 141 / 393

Page 142: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Problem: Small error in x2 (0.001) is multiplied by a large number

59.140.003000

⇒ pivot element aii is too small

Good pivot strategy: change rows such that the diagonal elements are not small,reduces round-off error!

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 142 / 393

Page 143: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

LU DecompositionProblems

Ill conditioning

Assumption:b is perturbated by rounding errors rno errors in A

Let x be the solution of Ax = b.

Define e ≡ x− x = A−1r

Condition number:‖e‖‖x‖/

‖r‖‖b‖ (47)

Ae = r ⇒

‖A‖ ‖e‖ ≥ ‖r‖

e = A−1r⇒

‖A−1‖ ‖r‖ ≥ ‖e‖

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 143 / 393

Page 144: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

LU DecompositionProblems

Together with Ax = b:

‖r‖‖A‖ ‖A−1‖ ‖b‖ ≤

‖e‖‖x‖ ≤

‖A−1‖ ‖A‖ ‖r‖‖b‖

Condition number of A:

cond(A) = ‖A‖ ‖A−1‖ (48)

Upper and lower bounds:

1cond(A)

‖r‖‖b‖ ≤

‖e‖‖x‖ ≤

‖r‖‖b‖ cond(A)

Rough rule of thumb: As the condition number increase by a factor of 10, you lose onesignificant digit

Any condition over 10ε−5 is considered large if ε is the number of the machine accuracyBurkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 144 / 393

Page 145: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Schur Decomposition

Schur Factorization

The Schur factorization of a square matrix A is given by

A = TST−1. (49)

The complex matrix S is upper triangular with the eigenvalues of A on the maindiagonal. It is possible to choose T such that the eigenvalues appear in any desiredorder along the diagonal of S.

The transformation matrix T has the following properties:

its complex conjugate transpose T ′ equals the inverse of T ,

therefore: TT ′ = TT−1 = I, i.e., T is an unitary matrix,

all eigenvalues of T have absolute value equal to 1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 145 / 393

Page 146: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Reading Assignments and Problems I

Reading Assignment

Heer, Maussner, Chapter 8.1.

Miranda, Fackler, Chapter 2

Burden, Faires, Chapter 6

Problems1 Solve the problem Ax = b with

A =

»M−1 1

1 1

–, P =

»12

–1 Type help lu and help norm in Matlab.2 Write a short program by increasing M from 100 to 500. Report the solution vector and

the [P, L, U] decomposition.3 Verify the solution.

2 Use the Matlab function randn to generate a 100-by-100 matrix A and a random100-vector b. Then use the Matlab functions tic and toc to compute the timeneeded to solve the linear equation Ax = b for the algorithms i) LU decompositionand ii) x = A−1b.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 146 / 393

Page 147: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Linear Algebra Linear Equations

Reading Assignments and Problems II3 Consider the Hilbert matrix

Hn =

266641 1

213 . . . 1

n12

13

14 . . . 1

n+1...

......

......

1n

1n+1

1n+2 . . . 1

2n

377751 Type help cond in Matlab.2 Increase N from 3 to 10 and report the condition number.

4 Consider the Vandermonde matrix

V =

266641 x1 . . . xN−1

11 x2 . . . xN−1

2...

......

...1 xN . . . xN−1

N

377751 Type help randn, help plot and help print in Matlab.2 Write a Matlob code that generates N random numbers xi from the normal distribution

N(10, σ2) with σ = 5.3 Increase N from 2 to 5 and report the condition number.4 Compare your results to the Hilbert matrix.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 147 / 393

Page 148: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Application: Reverse Shooting

Infinite-Horizon Ramsey ModelSaddle Path

Backward Iteration: Reverse Shooting

Computation of the transition dynamics in the infinite-horizon Ramsey model with fulldepreciation of the capital stock:

Kt+1 = K αt − Ct , (50a)

Ct+1 = αβCt(K αt − Ct)

α−1. (50b)

Its stationary solution is

K ∗ = (αβ)1/(1−α) and C∗ =

„1− αβ

αβ

«(αβ)1/(1−α),

and the Jacobian matrix at this solution is

J =

»1/β −1

1−αβαβ

α−1β

1− 1−αβαβ

(α− 1)

–.

It can be shown analytically that J has one eigenvalue smaller than one and oneeigenvalue exceeding one. See Heer/Maussner, Section 2.3.1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 148 / 393

Page 149: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Application: Reverse Shooting

Infinite-Horizon Ramsey ModelComputation of the Saddle Path

Computation with Matlab: shooting.m

1 Compute the steady state (K ∗,C∗).2 Compute the eigenvalue and the eigenvector of the Jacobian.3 Start from a point close to the steady state where (1, v)′ denotes the eigenvector

associated with the stable eigenvalue: (K ∗ + dK ,C∗ + vdK ), dK small.4 Iterate backwards, i.e., compute (Kt ,Ct) given (Kt+1,Ct+1) from (50). Therefore,

you have to solve a system of non-linear equations with the Broyden algorithm.

Reason, why we start in K ∗ + dk rather than K0:

The terminal state is excessively sensitive to the initial guess.

The initial state corresponding to the any terminal state is relatively insensitive tothe terminal state.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 149 / 393

Page 150: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Application: Reverse Shooting

Infinite-Horizon Ramsey ModelComputation of the Saddle Path

0 2 4 6 8 10 12 140.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4ca

pita

l sto

ck a

nd c

onsu

mpt

ion

period

kc

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 150 / 393

Page 151: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Application: Reverse Shooting

Infinite-Horizon Ramsey ModelComputation of the Saddle Path

0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.20.22

0.24

0.26

0.28

0.3

0.32

0.34

0.36

0.38co

nsum

ptio

n

capital stock

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 151 / 393

Page 152: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Application: Reverse Shooting

Reading Assignments and Problems

Reading Assignment

Heer, Maussner, Chapter 1.2.5

Optional: Judd, Chapter 10.7 (requires advanced knowledge of numericalmathematics)

Problems1 Compute the transition dynamics in the above Example for given K0 = 0.1. Apply

the method of reverse shooting.1 For this reason, choose a time horizon T = 20 for the number of transition periods.

Choose an initial value of dK 0 = 10−6 as a starting value. Compute the sequence{K 0

t }Tt=0 backwards. Solve the non-linear equation f (K0) = K 0

0 − K0 by adjusting dK .Store the solution K0, C0.

2 Control your solution. Iterate forward your solution (K0, C0). Graph the transition.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 152 / 393

Page 153: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 153 / 393

Page 154: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 154 / 393

Page 155: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 155 / 393

Page 156: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey model

The stochastic Ramsey model

maxC0

E0

"∞Xt=0

βtu(Ct)

#s.t.

Kt+1 + Ct ≤ Zt f (Kt) + (1− δ)Kt ,0 ≤ Ct ,0 ≤ Kt+1.

9=; t = 0, 1, . . .

K0, Z0 given.

(51)

Zt — stochastic productivity, source of uncertainty

Zt follows Markov process ⇒ recursive structure: policy function Kt+1 = g(Zt ,Kt).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 156 / 393

Page 157: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey model

Markov processes

Markov process: probability distribution of Zt+1 only depends on the realization of Zt

AR(1) Process:

Zt = (1− ρ)Z + ρZt−1 + εt , εt ∼ N(0, σ2).

Markov chains are discrete valued Markov processes. They are characterized bythree objects:

1 The vector z = [z1, z2, . . . , zm]′ summarizes the m different realizations of Zt .

2 The probability distribution of the initial date t = 0 is represented by the vectorπ0 = [π01, π02, . . . , π0n]

′, where π0i denotes the probability of the event Z0 = zi .

3 The dynamics of the process are represented by a transition matrix P = (pij), wherepij denotes the probability of the event Zt+1 = zj |Zt = zi , i.e., the probability that nextperiod’s state is zj given that this period’s state is zi . Therefore, pij ≥ 0 andPm

j=1 pij = 1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 157 / 393

Page 158: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey model

Thus, given Zt = zi the conditional expectation of Zt+1 is given by:

E(Zt+1|Zt = zi) = Piz,

where Pi denotes the i–th row of P

Conditional variance: var(Zt+1|Zt = zi) =P

j Pij(zj − Piz)2.

The probability distribution of Zt evolves according to

π′t+1 = π′t P

Ergodic distribution:

π′ = limt→∞

π′t ,

defined by

π′ = π′P ⇔ (P′ − I)π = 0.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 158 / 393

Page 159: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey model

Does the ergodic distribution π exist?

If for some integer k , all elements of Pk = P × P × . . .× P are strictly positive,pk

ij > 0.

P =

„0.0 1.00.9 0.1

«, P2 =

„0.9 0.1

0.09 0.91

«.

computation of the ergodic distribution

π′

26664p11 − 1 p12 . . . p1,n−1 1

p21 p22 − 1 . . . p2,n−1 1...

......

......

pn1 pn2 . . . pn,n−1 1

37775 = (0, . . . , 0, 1)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 159 / 393

Page 160: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey modelMatlab application

>> x=[0,1];>> y=[-1.0 1; 0.9 1];>> x*inv(y)

ans =

0.4737 0.5263

>> p=x*inv(y)

p =

0.4737 0.5263

>> p*[0 1; 0.9 0.1]

ans =

0.4737 0.5263

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 160 / 393

Page 161: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey modelMarkov Chain Approximations of AR(1) Processes

Consider the process

Zt+1 = %Zt + εt , εt ∼ N(0, σ2ε).

The unconditional mean and variance of this process are 0 and σ2Z = σ2

ε/(1− %2).

Tauchen (1986):

choose a grid Z = [z1, z2, . . . , zm] of equidistant points z1 < z2, . . . , < zm, whoseupper end point is a multiple, say λ, of the unconditional standard of theautoregressive process, zm = λσZ and whose lower end point is z1 = −zm.For a given realization zi ∈ Z the variable z := %zi + ε is normally distributed withmean %zi and variance σ2

ε .Let dz denote half of the distance between two consecutive grid points. Theprobability that z is in the interval [zj − dz, zj + dz] is given by

prob(zj − dz ≤ z ≤ zj + dz) = π(zj + dz)− π(zj − dz)

where π(·) denotes the cumulative distribution function of the normal distributionwith mean %zi and variance σ2.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 161 / 393

Page 162: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey model

Algorithm: Markov chain approximation

Purpose: Finite state Markov chain approximation of first order autoregressive process

Step 1: Compute the discrete approximation of the realizations: Let % and σε denotethe autoregressive parameter and the standard deviation of innovations,respectively. Select the size of the grid by choosing λ ∈ R++ so thatz1 = −λσε/

p1− %2. Choose the number of grid points m. Put

step = −2z1/(m − 1) and for i = 1, 2, ...,m compute zi = z1 + (i − 1)step.

Step 2: Compute the transition matrix P = (pij): Let π(·) denote the cumulativedistribution function of the standard normal distribution. For i = 1, 2, . . . ,m put

pi1 = π“

z1−%ziσε

+ step2

”,

pij = π“

zj−%ziσε

+ step2

”− π

“zj−%zi

σε− step

2

”,

j = 2, 3, . . . ,m − 1,pim = 1−

Pm−1j=1 pij .

Tauchen: m = 9, λ = 3

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 162 / 393

Page 163: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey model

The stochastic Euler equations

L = E0

∞Xt=0

βthu(Ct) + µtCt + ωt+1Kt+1

+ λt (Zt f (Kt) + (1− δ)Kt − Ct − Kt+1)iff.

Differentiation with respect to C0 and K1:

∂L∂C0

= E0{u′(C0)− λ0 + µ0} = 0,

∂L∂K1

= βE0{−λ0 + ω1 + βλ1(1− δ + Z1f ′(K1))} = 0,

0 = λ0(Z0f (K0) + (1− δ)K0 − C0 − K1),

0 = µ0C0,

0 = ω1K1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 163 / 393

Page 164: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey modelThe stochastic Euler equations

Since C0, K1, and hence the multipliers λ0, µ0, and ω1 are non-stochastic, we canreplace the first condition with

u′(C0) = λ0 − µ0

and the second with

λ0 = βE0λ1{1− δ + Z1f ′(K1)}+ ω1.

Now, consider the problem from t = 1 onwards, when Z1 is known and K1 given. TheLagrangean for this problem is

L = E1

∞Xt=1

βt−1hu(Ct) + µtCt + ωt+1Kt+1

+ λt (Zt f (Kt) + (1− δ)Kt − Ct − Kt+1)iff.

Proceeding as before, we find

u′(C1) = λ1 − µ1,

λ1 = βE1λ2{1− δ + Z2f ′(K2)}+ ω2.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 164 / 393

Page 165: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey modelThe stochastic Euler equations

Continuing in this way, we find, since Kt must be optimal at t , that the plan for choosingC0,C1, . . . and K1,K2, . . . must solve the system:

u′(Ct) = λt − µt , (52a)

λt = βEtλt+1ˆ1− δ + Zt+1f ′(Kt+1)

˜+ ωt+1, (52b)

0 = λt(Zt f (Kt) + (1− δ)Kt − Ct − Kt+1), (52c)

0 = µtCt , (52d)

0 = ωt+1Kt+1. (52e)

Thus, an interior solution with strictly positive consumption and capital at all dates t(i.e., ∀t : µt = ωt+1 = 0) must satisfy:

1 =βEtu′(Zt+1f (Kt+1) + (1− δ)Kt+1 − Kt+2)

u′(Zt f (Kt) + (1− δ)Kt − Kt+1)

× (1− δ + Zt+1f ′(Kt+1)).

(53)

In addition to the stochastic Euler equation (53) there is also the stochastic analog ofthe transversality condition:

limt→∞

βtEtλtKt+1 = 0 (54)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 165 / 393

Page 166: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model The model

The stochastic Ramsey modelThe stochastic Euler equations

Example

Let the one-period utility function u and the production function f be given by

u(C) := ln C,

f (K ) := K α, α ∈ (0, 1),

K ′ is directly proportional to K α in the deterministic counterpart of the model. So let ustry

Kt+1 = g(Kt ,Zt) := AZtK αt

with the unknown parameter A as policy function. If this function solves the problem, itmust satisfy the stochastic Euler equation (53). To prove this assertion, we replace Kt+1

in equation (53) by the right hand side of the previous equation:

1 = βEt

»(1− A)ZtK α

t

(1− A)Zt+1[AZtK αt ]α

αZt+1[AZtK αt ]α−1

–=αβ

A.

If we put A = αβ the function g(Zt ,Kt) = αβZtK αt satisfies the Euler equation, and,

thus is the policy function we look for.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 166 / 393

Page 167: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 167 / 393

Page 168: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 168 / 393

Page 169: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 169 / 393

Page 170: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

The stochastic Ramsey modelStochastic Dynamic Programming

Value function:

v(K ,Z ) = max0≤K ′≤Zf (K )+(1−δ)K

u(Zf (K ) + (1− δ)K − K ′)

+ βEˆv(K ′,Z ′)|Z

˜,

In the case of a Markov chain with realizations [z1, z2, . . . , zn] and transition matrixP = (pij):

Eˆv(K ′,Z ′)|zi

˜=

nXj=1

pijv(K ′, zj)

In the case of the continuous valued Markov process with conditional probabilitydensity function π(z,Z ′) over the interval [a, b]:

Eˆv(K ′,Z ′)|z

˜=

Z b

av(K ′,Z ′)π(z,Z ′)dZ ′.

Existence and properties of the value function: Stokey, Lucas (1989)Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 170 / 393

Page 171: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

The stochastic Ramsey modelStochastic Dynamic Programming

The procedure is built on the result that the sequence of value functions obtained under

v s+1(K , zi) =maxK ′

u(zi f (K ) + (1− δ)K − K ′)

+ β

mXj=1

pijv s(K ′, zj),

converges linearly at rate β.

Problems:1 Choice of a grid for K : minimum and maximum values2 Choice of the number of grid points3 Initialization of the value function

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 171 / 393

Page 172: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

The stochastic Ramsey model IStochastic Dynamic Programming

Algorithm: Value Function Iteration 3

Purpose: Compute an Approximation to the Policy Function of the Stochastic RamseyModel with m–state Markov Chain for the productivity shock.

Step 1: Choose a grid of n equally spaced points over [K1 = K ,Kn = K ]:

G = [K1,K2, . . . ,Kn], Ki < Ki+1 ∀i = 1, 2, . . . n − 1.

Step 2: Initialize the value function as follows: Let U = (uij). For all j = 1, 2, . . . , ncompute

uij := u(zj f (K ∗j ) + (1− δ)K ∗

j − K ∗j ),

where K ∗j solves 1 = β(1− δ + zj f ′(K ∗

j )) and i = 1, 2, . . . , n. Put

v0 = U(I − βP′)−1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 172 / 393

Page 173: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

The stochastic Ramsey model IIStochastic Dynamic Programming

Step 3: Compute a new value function v1 and associated policy function g1: For eachj = 1, 2, . . . ,m repeat these steps: Put k∗0 = 1 and for i = 1, 2, . . . , n find theindex k∗i that maximizes

wk = u(zj f (Ki) + (1− δ)Ki − Kk ) + β

mXl=1

pjlv0kl

in the set of indices k = k∗i−1, k∗i−1 + 1, . . . , n. Set v1

ij = wk∗iand g1

ij = k∗i .

Step 4: Check for convergence: if

maxi=1,...nj=1,...m

|v1ij − v0

ij | ≤ ε(1− β), ε ∈ R++

(or if the policy function has remained unchanged for a number of consecutiveiterations) stop, else set v0 = v1 and g0 = g1 and return to Step 3.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 173 / 393

Page 174: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

The stochastic Ramsey modelStochastic Dynamic Programming

Matlab program: svalue1.m and svalue2.m

Sensitivity to the grid [kmin, kmax ]1 upper and lower value: try kmin ∈ {0.3k∗, 0.5k∗, 0.8k∗} and

kmax ∈ {1.7k∗, 1.5k∗, 1.2k∗}.2 Number of grid points: Try n ∈ {500, 1000, 5000}.

Sensitivity: Initialization of v : try v ≡ 0Simulate time series:

1 stability? solution ok?2 does the simulated time series stay within the grid for k?

Reasonable choice of the asset grid? Check if the policy function k ′(z, k) hit thelower/upper grid point.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 174 / 393

Page 175: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

Infinite-Horizon Stochastic Ramsey ModelMatlab output, N=500 grid points over K

18 20 22 24 26 28 3018

20

22

24

26

28

30solution of example 1.3.4 in heer/maussner

capital stock

next

per

iod

capi

tal s

tock

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 175 / 393

Page 176: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

Infinite-Horizon Stochastic Ramsey ModelMatlab output, N=500 grid points over K

18 20 22 24 26 28 301.9

1.95

2

2.05

2.1

2.15

2.2

2.25

2.3

2.35solution of example 1.3.4 in heer/maussner

capital stock

cons

umpt

ion

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 176 / 393

Page 177: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

Infinite-Horizon Stochastic Ramsey ModelMatlab output, N=500 grid points over K

18 20 22 24 26 28 3029

30

31

32

33

34

35

36solution of example 1.3.4 in heer/maussner

capital stock

valu

e fu

nctio

n

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 177 / 393

Page 178: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

Infinite-Horizon Stochastic Ramsey ModelMatlab output, N=5000 grid points over K

18 20 22 24 26 28 301.9

1.95

2

2.05

2.1

2.15

2.2

2.25

2.3

2.35solution of example 1.3.4 in heer/maussner

capital stock

cons

umpt

ion

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 178 / 393

Page 179: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

Infinite-Horizon Stochastic Ramsey ModelMatlab output, svalue2.m, N=2000 grid points over K

100 150 200 250 300 350 400 450 50021.8

22

22.2

22.4

22.6

22.8

23

time

capi

tal s

tock

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 179 / 393

Page 180: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

The Stochastic Ramsey Model Stochastic Dynamic Programming

Reading Assignments and Problems

Reading Assignment

Heer, Maussner, Chapter 1.3, 9.2

Problems1 Compute the ergodic distribution of

P =

»0.5 0.50.1 0.9

–.

2 Discretize the AR-(1) process Zt = ρZt−1 + εt with ρ = 0.95 and σ = 0.0072. UseTauchen’s algorithm with m = 9 and λ = 3. Report your results. Draw a sequenceof 10000 random numbers from the normal distribution with σ = 0.0072 andsimulate a time series for Zt given Z0 = 0. Drop the first 100 observations andcompute the mean and the variance of the series. Compare it to the mean and thevariance of the AR(1) process. Repeat the exercise for m ∈ {7, 15} andλ ∈ {2, 4}. Report your results in a table.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 180 / 393

Page 181: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 181 / 393

Page 182: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 182 / 393

Page 183: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 183 / 393

Page 184: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle Model

The Real Business Cycle Model

⇒ The stochastic growth model with labor/leisure choice, U(C, 1− N)

Effect of positive productivity shock:1 Income effect: higher consumption, more leisure2 Substitution effect: more labor3 Intertemporal substitution: more labor today, less labor tomorrow, higher savings

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 184 / 393

Page 185: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle Model

Growth and Restrictions on Technology and Preferences

Balanced growth path = equivalent to steady state

1 Output per working hour grows at constant rate2 Share of net savings in output is constant

⇒ only in accordance with labor-augmenting technical progress:

Yt = ZtF (AtNt ,Kt)

Zt — disembodied technological changeAt — embodied technological change, quality of labor

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 185 / 393

Page 186: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle Model

Restrictions on preferences

max{Ct ,Nt}∞t=0

∞Xt=0

βtu(Ct , 1− Nt)

s.t.

Kt+1 + Ct ≤ F (AtNt ,Kt) + (1− δ)Kt ,0 ≤ Ct ,1 ≥ Nt ≥ 0,0 ≤ Kt+1.

9>>=>>; t = 0, 1, . . . ,

K0 given.

(55)

→ restriction on utility (see Heer/Maussner, Appendix 2, Ch.1 ):

u(C, 1− N) =

C1−ηv(1− N) if η 6= 1,

ln C + v(1− N) if η = 1.(56)

Of course, u(.) must be concave.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 186 / 393

Page 187: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle ModelLagrangean of Example (55):

L =∞Xt=0

βthu(Ct , 1− Nt) + Λt

`F (AtNt ,Kt)

+ (1− δ)Kt − Ct − Kt+1´i.

Differentiating this expression with respect to Ct , Nt , and Kt+1 provides the following setof first order conditions:

0 = u1(Ct , 1− Nt)− Λt , (57a)

0 = −u2(Ct , 1− Nt) + ΛtF1(AtNt ,Kt)At , (57b)

0 = −Λt + βΛt+1(1− δ + F2(At+1Nt+1,Kt+1)). (57c)

Conditions (57a) and (57b) imply that the marginal rate of substitution betweenconsumption and leisure, u2/u1, equals the marginal product of labor:

u2(Ct , 1− Nt)

u1(Ct , 1− Nt)= AtF1(AtNt ,Kt). (58)

Conditions (57a) and (57c) yield

u1(Ct , 1− Nt)

u1(Ct+1, 1− Nt+1)= β(1− δ + F2(At+1Nt+1,Kt+1)). (59)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 187 / 393

Page 188: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle Model

Transformation to Stationary Variables

Assume η 6= 1 in Example (55) and deterministic growth of the efficiency level of labor:

At+1 = aAt

The static labor supply condition can be written as

v ′(1− Nt)

(1− η)v(1− Nt)

Ct

At= F1(Nt ,Kt/At) (60)

and the intertemporal condition:

C−ηt v(1− Nt)

C−ηt+1v(1− Nt+1)

=(aAt)

ηC−ηt v(1− Nt)

Aηt+1C−η

t+1v(1− Nt+1)

=aη(Ct/At)

−ηv(1− Nt)

(Ct+1/At+1)−ηv(1− Nt+1)

= β(1− δ + F2(Nt+1,Kt+1/At+1))

(61)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 188 / 393

Page 189: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle Model

Since F is homogenous of degree one, we can transform the resource constraint to

Kt+1

At+1/a= F (Nt ,Kt/At) + (1− δ)(Kt/At)− (Ct/At). (62)

Equations (60) through (62) constitute a dynamical system in the new variables Nt ,ct := Ct/At , and kt = Kt/At . Their stationary values N, c and k are found as solution tothe system of three equations

c =(1− η)v(1− N)

v ′(1− N)F1(N, k),

1 = βa−η(1− δ + F2(N, k)),

0 = F (N, k)− (1− δ − a)k − c.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 189 / 393

Page 190: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle Model

Note, that we can get the efficiency conditions (60) through (62) from solving theproblem

max{ct ,Nt}∞t=0

∞Xt=0

βtc1−ηt v(1− Nt)

s.t.

ct ≤ F (Nt , kt) + (1− δ)kt − akt+1,k0 given

with discount factor β := βa1−η in the stationary decision variables ct := Ct/At andkt+1 := Kt+1/At+1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 190 / 393

Page 191: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle ModelThe decentralized economy

Firms

Assumption: n equal firms

Maximization of the firm’s present value is equivalent with maximizing one-periodprofits

Πi := ZF (ANi ,Ki)− wNi − rKi .

The first order conditions imply

w = ZAF1(ANi ,Ki) = ZAF1(A,Ki/Ni),

r = ZF2(ANi ,Ki) = ZF2(A,Ki/Ni),

due to the homogeneity of degree zero of Fi .

All firms choose the same capital-labor ratio k := Ki/Ni , output per labor is the same,yi = y = ZF (A, k):⇒ Aggregate production:

Y =X

i

Yi =X

i

Niy = Ny = NZF (A, k) = ZF (AN,K ),

Profits are zero (Euler theorem).Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 191 / 393

Page 192: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle Model

Households

Mass 1

or equivalently: representative household

maximizes intertemporal utility

supplies labor Nt with efficiency At

supplies capital services Kt

saves in terms of capital Kt

Budget constraint:

Kt+1 − Kt ≤ wtNt + (r − δ)Kt − Ct . (63)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 192 / 393

Page 193: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle Model

maximize its life-time utility

∞Xt=0

βtu(Ct , 1− Nt), β ∈ (0, 1) (64)

subject to (63) and the given initial stock of capital K0. From the Lagrangean of thisproblem,

L =∞Xt=0

βthu(Ct , 1− Nt) + Λt(wtNt + (1− δ + rt)Kt

− Ct − Kt+1)i

we derive the following first order conditions:

u1(Ct , 1− Nt) = Λt , (65a)

u2(Ct , 1− Nt) = Λtwt , (65b)

Λt = βΛt+1(1− δ + rt+1). (65c)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 193 / 393

Page 194: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Growth, Leisure and Business Cycles

Real Business Cycle Model

Using the factor market equilibrium conditions to substitute for wt and rt+1 and applyingthe Euler theorem to F ,

Yt = ZF (AtNt ,Kt) = ZAtF1(AtNt ,Kt)Nt + ZF2(AtNt ,Kt)Kt

equations (65) reduce to

u2(Ct , 1− Nt)

u1(Ct , 1− Nt)= ZAtF1(AtNt ,Kt), (66a)

u1(Ct , 1− Nt)

u1(Ct+1, 1− Nt+1)= β(1− δ + ZF2(At+1Nt+1,Kt+1)), (66b)

Kt+1 = ZF (AtNt ,Kt) + (1− δ)Kt − Ct . (66c)

This system is identical to the first order conditions that we derived for the Ramseymodel of the central planner.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 194 / 393

Page 195: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model The benchmark real business cycle model

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 195 / 393

Page 196: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model The benchmark real business cycle model

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 196 / 393

Page 197: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model The benchmark real business cycle model

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 197 / 393

Page 198: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model The benchmark real business cycle model

Real Business Cycle ModelThe benchmark model

Our benchmark model

Example

Our benchmark real-business cycle model:

maxC0,N0

E0

"∞Xt=0

βt C1−ηt (1− Nt)

θ(1−η)

1− η

#,

β ∈ (0, 1), η ≥ 0, θ ≥ 0, η > θ/(1 + θ),

s.t.

Kt+1 + Ct ≤ Zt(AtNt)αK 1−α

t + (1− δ)Kt , α ∈ (0, 1),At+1 = aAt , a ≥ 1,Zt+1 = Z %

t eεt , % ∈ (0, 1), εt ∼ N(0, σ2),0 ≤ Ct ,0 ≤ Kt+1,

9>>>>=>>>>;∀t ,

K0, Z0 given.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 198 / 393

Page 199: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model The benchmark real business cycle model

Real Business Cycle ModelThe benchmark model

From the Lagrangean

L := E0

n ∞Xt=0

βth C1−η

t (1− Nt)θ(1−η)

1− η

+ Λt

“Zt(AtNt)

αK 1−αt + (1− δ)Kt − Ct − Kt+1

” iowe derive the following first order conditions:

θCt

1− Nt= αZtAt(AtNt)

α−1K 1−αt ,

Ct = Zt(AtNt)αK 1−α

t + (1− δ)Kt − Kt+1,

1 = βEt

„Ct

Ct+1

«η „1− Nt+1

1− Nt

«θ(1−η)

×`1− δ + (1− α)Zt+1(At+1Nt+1)

αK−αt+1

´

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 199 / 393

Page 200: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model The benchmark real business cycle model

Real Business Cycle ModelThe benchmark model

In terms of stationary variables ct := Ct/At and kt := Kt/At this system is:

θct

1− Nt= αZtNα−1

t k1−αt , (68a)

ct = ZtNαt k1−α

t + (1− δ)kt − akt+1, (68b)

1 = βa−ηEt

„ct

ct+1

«η „1− Nt+1

1− Nt

«θ(1−η)

× (68c)`1− δ + (1− α)Zt+1Nα

t+1k−αt+1

´.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 200 / 393

Page 201: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Calibration of the benchmark model

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 201 / 393

Page 202: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Calibration of the benchmark model

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 202 / 393

Page 203: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Calibration of the benchmark model

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 203 / 393

Page 204: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Calibration of the benchmark model

Real Business Cycle ModelCalibration

Basic idea of calibration: Real economic data is generated by the model.

We choose the German economy 1975.i-1989.iv

Assumption: Germany is on a balanced growth path during this period. ⇒ In order

to select values like k/y we use long-run averages

Evidence from time-series: {α, δ, ρ, σ, β}Microeconomic studies: {η}

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 204 / 393

Page 205: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Calibration of the benchmark model

Real Business Cycle ModelCalibration

Calibration of the parameters: svalue2.mWe choose a Cobb-Douglas production function in accordance with empiricalevidence.Labor augmenting technical progress a− 1 = 0.005: linear time trend of GDPα = 0.73, average wage share in total income (includes hypothetical income ofself-employed)Depreciation rate δ = 0.011Markov process for Zt

ln Zt = % ln Zt−1 + εt ,

where ln Zt ≈ (Zt − Z )/Z and

Zt =Yt

((1.005)tHt)0.72K 0.28t

.

We fit an AR(1) process to the percentage deviation of Zt from its mean Z ≡ 1.This delivers our estimate of % = 0.90 and of σ = 0.0072.η = 2 from micro-studiesβ = 0.994 with the help of the FOC and an average yearly return on capital equalto 6.5%.θ = 5.659: steady state labor supply N = 0.13.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 205 / 393

Page 206: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Calibration of the benchmark model

Real Business Cycle ModelCalibration

Computation of the steady state values and the grid

Given a, β, α, δ and η, we can solve the steady state for y/k :

1 = βa−η(1− δ + (1− α)Nαk−α) = βa−η(1− δ + (1− α)(y/k))

In the next step, we compute c/k :

yk

=Nαk1−α

k=

ck

+ (a + δ − 1).

And, hence, y/c = y/k · k/c. With N = 0.13, we can compute θ:

N1− N

θ

Nαk1−α

c=α

θ

yc

Finally, we can solve for k :

yk

= Nαk−α

⇒ we compute a grid around the steady state of k .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 206 / 393

Page 207: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Computation of the benchmark model 1: Value function iteration

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 207 / 393

Page 208: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Computation of the benchmark model 1: Value function iteration

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 208 / 393

Page 209: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Computation of the benchmark model 1: Value function iteration

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 209 / 393

Page 210: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Computation of the benchmark model 1: Value function iteration

Real Business Cycle Model IComputation

Computation: Value function iteration with binary search

Code: svalue2.m

1 First, we calibrate the model and choose a grid over k .2 In a second step we approximate the continuous valued Markov process by a

Markov chain using Tauchen’s Algorithm.3 Given the realizations z = [z1, z2, ..., zm] and the associated transition matrix

P = (pij) we must iterate over

v s+1(k , zj)

= maxN,k′

(zjNαk1−α + (1− δ)k − ak ′)1−η(1− N)θ(1−η)

1− η

+ β

mXl=1

pjlv s(k ′, zl), β := βa1−η.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 210 / 393

Page 211: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Computation of the benchmark model 1: Value function iteration

Real Business Cycle Model IIComputation

4 The maximization problem is split into two steps. Given a pair (z, k , k ′), we firstsolve for the optimal N using the first order condition

θziNαk1−α + (1− δ)k − ak ′

1− N= αziNα−1k1−α. (69)

We solve this non-linear equation with Broyden’s algorithm. In a second step, wesearch for the optimal k ′ using binary search.

5 We stop when the value function does not change by more than ε or the policyfunction is unchanged for a number n of iterations.

6 We simulate the economy with the help of the solution.

Run time on Pentium(R), 319 MHz: approximately 12 hours

Remarks:The grid can be re-specified by trial and error. In the simulation, k should not hitthe boundaries.We may need to re-specify the non-linear equation for the optimal labor supply,e.g. by multiplying through with N1−α(1− N) in order to improve convergence ofBroyden’s algorithm.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 211 / 393

Page 212: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Computation of the benchmark model 1: Value function iteration

Real Business Cycle ModelComputation

1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.2−520

−510

−500

−490

−480

−470

−460

−450

−440

capital stock

v

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 212 / 393

Page 213: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Computation of the benchmark model 1: Value function iteration

Real Business Cycle ModelComputation

1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.20.12

0.125

0.13

0.135

0.14

0.145

0.15

capital stock

labo

r su

pply

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 213 / 393

Page 214: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Computation of the benchmark model 1: Value function iteration

Real Business Cycle ModelComputation

1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.20.21

0.22

0.23

0.24

0.25

0.26

0.27

0.28

0.29

capital stock

cons

umpt

ion

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 214 / 393

Page 215: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Computation of the benchmark model 1: Value function iteration

Real Business Cycle ModelComputation

0 500 1000 1500 2000 2500 30002.6

2.65

2.7

2.75

2.8

2.85

2.9

2.95

3

3.05

3.1

time

capi

tal s

tock

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 215 / 393

Page 216: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 216 / 393

Page 217: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 217 / 393

Page 218: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 218 / 393

Page 219: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Real Business Cycle ModelModel Performance

Evaluation of the model with respect to business cycle features

Second moments of time series⇒ Trend has to be removed from time series data.

The HP-filterLet (yt)

Tt=1 denote the log of a time series that may be considered as realization of a

non-stationary stochastic process. The growth component (gt)Tt=1 of this series as

defined by the HP-Filter is the solution to the following minimization problem:

min(gt )

Tt=1

TXt=1

(yt − gt) + λ

T−1Xt=2

[(gt+1 − gt)− (gt − gt−1)]2. (70)

λ = 0: yt = gt .

λ→∞: constant growth rate g

For quarterly data: λ = 1600 based on the observation that with this choice thefilter removes all cycles longer than 32 quarters leaving shorter cycles unchanged.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 219 / 393

Page 220: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Real Business Cycle ModelHP filter

The first order conditions of the minimization problem imply the following system oflinear equations:

Ag = y, (71)

where g = [g1, g2, . . . , gT ]′, y¯

= [y1, y2, . . . , yT ]′, and A is the tridiagonal matrix266666666664

1 + λ −2λ λ 0 0 . . . 0 0 0−2λ 1 + 5λ −4λ λ 0 . . . 0 0 0

λ −4λ 1 + 6λ −4λ λ . . . 0 0 00 λ −4λ 1 + 6λ −4λ . . . 0 0 00 0 λ −4λ 1 + 6λ . . . 0 0 0...

......

......

. . ....

......

0 0 0 0 0 . . . 1 + 6λ −4λ λ0 0 0 0 0 . . . −4λ 1 + 5λ −2λ0 0 0 0 0 . . . λ −2λ 1 + λ

377777777775

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 220 / 393

Page 221: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Real Business Cycle ModelHP filter

Note, that A can be factored in1

A = I + λK ′K ,

K =

26666641 −2 1 0 0 . . . 0 0 00 1 −2 0 0 . . . 0 0 00 0 1 −2 1 . . . 0 0 0...

......

......

. . ....

......

0 0 0 0 0 . . . 1 −2 1

3777775

MATLAB program: hpfilter.m, returns the growth component. Do not use time seriesthat have many more than 1000 observations with this routine (speed).

1See BRANDNER and NEUSSER (1990), p. 5.Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 221 / 393

Page 222: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Real Business Cycle ModelHP filter

The cyclical component of y,

c = y− g = [I − A−1]y,

remains unchanged if a linear time trend

a :=

26664a1 + a2

a1 + 2a2...

a1 + Ta2

37775is added to the time series (yt)

Tt=1. To see this, note that

c = [I − A−1][y + a] = [I − A−1]y + [I − A−1]a| {z }=0

.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 222 / 393

Page 223: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Real Business Cycle ModelHP filter

This statement can be proven by noting that

[I − A−1]a = 0 ⇔ A−1[A− I]a = 0 ⇔ [A− I]a = 0,

and considering the product on the rightmost side of this statement.

We can use the cyclical components of the log of the time series data for per capitaoutput etc and compare it to the cyclical component of the logs of the stationary valuesk = K/A from our model since

ln Kt = lnkt + ln At = ln kt + ln A0 + at .

⇒ cyclical components of ln Kt and ln kt are equal.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 223 / 393

Page 224: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Real Business Cycle ModelModel evaluation

Standard deviations in %

Variable σx

Output y 1.78Investment i 7.95

Labor n 0.94Consumption c 0.72

Correlation with output

Close to one for i (0.99), n (0.99), and c (0.98)

Autocorrelation of output: 0.68

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 224 / 393

Page 225: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Reading Assignments and Problems I

Reading Assignment

Heer, Maussner, Chapter 1.4, 9.4

Cooley, Hansen, Chapter 1

Problems1 Use the calibration of Cooley and Prescott to parameterize the real business cycle

benchmark model for the US economy: a = 1.0055, β = 0.99, α = 0.64, δ = 0.25,ρ = 0.95, σ = 0.0072, N = 1/3, η = 2.0. Compute the model with the help ofvalue function iteration for the following three utility functions:

u(ct , nt) =

8>><>>:1

1−η

hc1−η

t (1− nt)θ(1−η) − 1

iI

11−η

h`ct − θ

1+νAtn1+ν

t

´1−η − 1i

II

ln ct + θ(1−nt )1−γ

1−γIII

(72)

Calibrate θ in each case so that N = 1/3 in steady state. For the utility functions IIand III, set ν = 3.33 and γ = 7.0, respectively.

1 Show that the values of ν and γ imply a Frisch labor supply elasticity ηn,w = 0.3.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 225 / 393

Page 226: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Real Business Cycle Model Evaluation of the Model

Reading Assignments and Problems II

2 Compute the models with value function iteration using binary search and 1000 gridpoints for k . Discretize the AR(1) process for technology using Tauchen’s method and 9gridpoints for the grid over technology.

3 Report your results for the standard deviations and correlations with output of thevariables output, labor, consumption, investment, and wages. Also, report first-orderautocorrelation coefficients. Compare the different specifications. For this reasonsimulate the economy 100 times for 100 periods and report averages. Also reportstandard errors.

4 Accuracy 1: Compute the maximum Euler equation residual e = (c)/c − 1 over thegrid for {k , z}, where c is consumption in period t and c is the consumption that isnecessary to equate λt = uc(c, 1− nt ) withβa−ηEtλt+1(1− δ + (1− α)Zt+1Nα

t+1k−αt+1 ). Compute the expectation Et () with the

help of the transition matrix and the policy functions. Report the average and themaximum values of the residuals for each utility function.

5 Accuracy 2: For the simulated time series compute the risk-free rate of return:

λt

βa−ηEtλt+1− 1.

Again, compute the expectation Et () with the help of the transition matrix and the policyfunctions. Compute the percentage differences between the averages of a time seriesof 10,000 points and the stationary rate aη/β − 1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 226 / 393

Page 227: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 227 / 393

Page 228: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 228 / 393

Page 229: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 229 / 393

Page 230: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

maxC0

E0

∞Xt=0

βt ln(Ct), β ∈ (0, 1),

s.t. Kt+1 = ZtK αt − Ct , α ∈ (0, 1), t = 0, 1, . . . ,

K0,Z0 given.

Ct denotes consumption at time t , Kt is the stock of capital and Zt the productivityshock.

FOCs:

1Ct

= λt , (73a)

λt = βEtλt+1αZt+1K α−1t+1 , (73b)

Kt+1 = ZtK αt − Ct . (73c)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 230 / 393

Page 231: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

Loglinearization at the steady state

K = (αβ)1/(1−α) , (74a)

C = K α − K . (74b)

Numerical example with Matlab: α = 0.3, β = 0.99, ρ = 0.95

ks=(alpha*beta)^(1/(1-alpha))

ks =

0.1765

>> cs=ks^alpha-ks

cs =

0.4178

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 231 / 393

Page 232: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

Total differential of (73a):

− 1C2

dCt = dλt ,

where the partial derivatives are evaluated at the stationary solution.

Note that for any variable x , the expression

x := (x − x)/x ≡ dxx' ln(x/x) (75)

is the percentage deviation of x from the point x (loglinear approximation).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 232 / 393

Page 233: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

− ct = λt . (76a)

Similarly (see Heer/Maussner, p. 101),

λt = βEt λt+1 − (1− α)Et Kt+1 + Et Zt+1, (77a)

Kt+1 =1β

Kt −1− αβ

αβCt +

1αβ

Zt . (77b)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 233 / 393

Page 234: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximation IAn Illustrative Example

More convenient matrix notation

x: stacked (n × 1) vector of endogenous variables with initial conditions (statevariables). In our case: k and n = 1

z: stacked (l × 1) vector of purely exogenous shocks. In our case: z and l = 1

u: stacked (m × 1) vector of control variables. In our case: c and m = 1.

We can write the dynamics of linearized system in the following form:

Cuut = Cxλ

»xt

λt

–+ Czzt , (78a)

DxλEt

»xt+1

λt+1

–+ Fxλ

»xt

λt

–= DuEtut+1 + Fuut (78b)

+ DzEtzt+1 + Fzzt .

with

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 234 / 393

Page 235: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximation IIAn Illustrative Example

Cu=−1, Cxλ=[0 1], Cz=0,

Dxλ=

»1− α −1

1 0

–, Fxλ=

»0 1− 1

β0

–, Du=

»00

–,

Fu=

»0

− 1−αβαβ

–, Dz=

»10

–, Fz=

»01

αβ

–.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 235 / 393

Page 236: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

Solving the system

Zt = %Zt−1 + εt , % ∈ (0, 1), εt ∼ N(0, σ2). (79)

implies

Et Zt+1 = %Zt .

Furthermore, we replace Ct in equation (77b) by −λt , and, thirdly, we use this newequation to eliminate Kt+1 from (77a).

Et

»Kt+1

λt+1

–=

"1β

1−αβαβ

1−αβ

1−α(1−αβ)αβ

# »Kt

λt

–+

"1

αβ1−ααβ

− %

#Zt ,

⇔ Et

»Kt+1

λt+1

–= W

»Kt

λt

–+ RZt .

(80)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 236 / 393

Page 237: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

LoglinearapproximationAn Illustrative Example

W =

1.0101 2.36700.7071 2.6569

>> R=[1/(alpha*beta); (1-alpha)/(alpha*beta)-rho]

R =

3.36701.4069

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 237 / 393

Page 238: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

Method of King-Watson to solve (80)

Schur factorization of W :

W = TST−1,

where S is a (possibly complex) upper triangular matrix, whose diagonal elements arethe eigenvalues of W .

W from equation (80) has two real eigenvalues so that S ∈ R2×2 is real, as is thetransformation matrix T satisfying T ′ = T−1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 238 / 393

Page 239: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

W has two real roots 0 < µ1 < 1 and µ2 > 1:the determinant of W equals the product of the roots, i.e.,

µ1µ2 = |W | = 1− α(1− αβ)

αβ2 − (1− α)(1− αβ)

αβ2 = (1/β).

the trace of W equals the sum of the roots, i.e.,

µ1 + µ2 = (1/β) +1− α(1− αβ)

αβ=

1 + α2β

αβ.

Therefore, the roots of W solve

φ(µ) := µ+1/βµ

=1 + α2β

αβ.

⇒ the first root µ1 is located to the left of 1 and the second root must lie to the right of 1.

T−1WT = S =

»µ1 s12

0 µ2

–(81)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 239 / 393

Page 240: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

LoglinearapproximationAn Illustrative Example

>> [T,S]=schur(W)

T =

-0.9578 -0.28730.2873 -0.9578

S =

0.3000 1.65990 3.3670

>> inv(T)*W*T

ans =

0.3000 1.65990.0000 3.3670

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 240 / 393

Page 241: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

We compute W , T , T−1, µ1, µ2 numerically.

Transformation of variables:»Kt

λt

–:= T−1

»Kt

λt

–, ⇔ T

»Kt

λt

–:=

»Kt

λt

–(82)

Et

»Kt+1

λt+1

–=

»µ1 s12

0 µ2

–| {z }

S

»Kt

λt

–+

»q1

q2

–| {z }

:=Q=T−1R

Zt . (83)

→ we solve the second equation forward, the first backward.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 241 / 393

Page 242: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

LoglinearapproximationAn Illustrative Example

>> Q=inv(T)*R

Q =

-2.8207-2.3151

>>>> [eigv,mu]=eig(W)

eigv =

-0.9578 -0.70860.2873 -0.7056

mu =

0.3000 00 3.3670

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 242 / 393

Page 243: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximation IAn Illustrative Example

Computation of λt and Ct

Et λt+1 = µ2λt + q2Zt . (84)

We can solve this equation for λt via repeated substitution:

λt =1µ2

Et λt+1 −q2

µ2Zt . (85)

Shifting the time index one period into the future and taking expectations conditional oninformation as of period t yields:

Et λt+1 =1µ2

Et λt+2 −q2

µ 2Et Zt+1 =

1µ2

Et λt+2 −q2

µ 2%Zt , (86)

due to (79). Substitution into (85) gives:

λt =1µ2

2Et λt+2 −

»q2

µ2+

q2

µ2

%

µ2

–Zt .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 243 / 393

Page 244: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximation IIAn Illustrative Example

We can use (86) to get an expression for λt+3 and so on up to period t + τ :

λt =

»1µ2

–τ

Et λt+τ −q2

µ2

τ−1Xi=0

»%

µ2

–i

Zt . (87)

Suppose that the sequence1µτ

2Et λt+τ

ff∞

τ=0

converges towards zero for τ →∞.

In this case we can compute the limit of (87) for τ →∞:

λt = − q2/µ2

1− (%/µ2)Zt . (88)

We substitute this solution into the second equation of (82),2

λt = t21Kt + t22λt ,

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 244 / 393

Page 245: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximation IIIAn Illustrative Example

to get the solution for λt in terms of Kt and Zt :

λt = − t21

t22|{z}=:Lux

Kt −q2/µ2

t22(1− (%/µ2))| {z }=:Luz

Zt . (89)

Thus, the policy function that gives Ct in terms of the (deviations) of the state variablesis

Ct = Lux Kt + Luz Zt .

2We denote the elements of T−1 by (t ij ).Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 245 / 393

Page 246: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximation IAn Illustrative Example

Computation of kt+1

From the first equation of (80),

Kt+1 =1β

Kt +1− αβ

αβλt +

1αβ

Zt ,

we can derive the solution for Kt :

Kt+1 =

„1β− 1− αβ

αβ

t21

t22

«| {z }

=:Lxx

Kt

+

„1αβ

− 1− αβ

αβ

q2/µ2

t22(1− (%/µ2))

«| {z }

=:Lxz

Zt .

Thus, given a sequence of shocks {Zt}Tt=0 and an initial K0 we may compute the entire

time path of consumption and the stock of capital by iteration over

Ct = Lux Kt + Luz Zt ,

Kt+1 = Lxx Kt + Lxz Zt .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 246 / 393

Page 247: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

>> Lux=-T(2,1)/T(2,2)Lux =

0.3000

>> Llx=-Q(2)/mu(2,2)*1/(T(2,2)*(1-rho/mu(2,2)))Llx =

-1

>> Lxx=1/beta-(1-alpha*beta)/(alpha*beta)*T(2,1)/T(2,2)Lxx =

0.3000

>> Lxz=1/(alpha*beta)-(1-alpha*beta)/(alpha*beta)*Q(2)/mu(2,2)*1/(T(2,2)*(1-rho/mu(2,2)))

Lxz =1

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 247 / 393

Page 248: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationAn Illustrative Example

Comparison of loglinear and exact solution

>> Lxx=0.30;>> ks=(alpha*beta)^(1/(1-alpha))

ks =

0.1765

>> kgrid=0.8*ks:0.01:1.2*ks;>> kp=alpha*beta*kgrid.^alpha;>> kplog=ks+Lxx*(kgrid-ks);>> plot(kgrid,kp, kgrid, kplog)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 248 / 393

Page 249: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Illustrative Example

Loglinear approximationComparison: exact and log-linear solution

0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.230.165

0.17

0.175

0.18

0.185

0.19

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 249 / 393

Page 250: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation The General Method

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 250 / 393

Page 251: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation The General Method

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 251 / 393

Page 252: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation The General Method

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 252 / 393

Page 253: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation The General Method

Loglinear approximation

The General Method

Cuut = Cxλ

»x¯ tλt

–+ Czzt , (90a)

DxλEt

»xt+1

λt+1

–+ Fxλ

»xt

λt

–= DuEtut+1 + Fuut (90b)

+ DzEtzt+1 + Fzzt .

We assume that zt is governed by a stable vector autoregressive process of first orderwith normally distributed innovations εt :

zt = Πzt−1 + εt , εt ∼ N(0,Σ). (91)

Stability requires that the eigenvalues of the matrix Π lie within the unit circle.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 253 / 393

Page 254: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation The General Method

Loglinear approximation I

System Reduction:

We assume that the first equation can be solved for the vector ut :

ut = C−1u Cxλ

»xt

λt

–+ C−1

u Czzt . (92)

Shifting the time index one period into the future and taking expectations conditional oninformation as of period t yields:

Etut+1 = C−1u CxλEt

»xt+1

λt+1

–+ C−1

u CzEtzt+1. (93)

The solutions (92) and (93) allow us to eliminate ut and Etut+1 from (90b):“Dxλ − DuC−1

u Cxλ

”Et

»xt+1

λt+1

–= −

“Fxλ − FuC−1

u Cxλ

” »xt

λt

–+

“Dz + DuC−1

u Cz

”Etzt+1

+“

Fz + FuC−1u Cz

”zt

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 254 / 393

Page 255: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation The General Method

Loglinear approximation II

Assume that this system can be solved for Et(xt+1, λt+1)′. In other words, the matrix

Dxλ − DuC−1u Cxλ must be invertible. Using Etzt+1 = Πzt , which is implied by (91), we

get the following reduced dynamic system:

Et

»xt+1

λt+1

–= W

»xt

λt

–+ Rzt ,

W =“

Dxλ − DuC−1u Cxλ

”−1 “Fxλ − FuC−1

u Cxλ

”,

R =“

Dxλ − DuC−1u Cxλ

”−1

×h“

Dz + DuC−1u Cz

”Π +

“Fz − FuC−1

u Cz

”i.

(94)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 255 / 393

Page 256: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation The General Method

Loglinear approximation I

Change of Variables:

Multiple possibilities to factorize the matrix W :

1 Schur decomposition: S = T−1WT , S upper triangular, T ′ = T−1

Algorithm of King/Watson, more robust, a little bit more complicated → Heer,Maussner provide programs in Gauss/Fortran

2 Diagonalization: W = PΛP−1, where Λ is a diagonal matrix with the eigenvalues,P matrix with eigenvectors

Algorithm of King, Plosser, Rebelo, adapted from Burnside (1999), MATLABroutine: SolveLA.m

Derivation of the solution: exactly the same as in the simple example.

See also: Heer, Maussner, Chapter 2.3.2 for Schur decomposition, Burnside, Chapter3, for KPR algorithm.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 256 / 393

Page 257: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 257 / 393

Page 258: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 258 / 393

Page 259: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 259 / 393

Page 260: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Loglinear approximationThe real business cycle model

Loglinear solution of the real business cycle model

Our starting point are the first order conditions and the associated stationary solution.At the point of the stationary solution the loglinearized equations are:

λt = −ηct − θ(1− η)N

1− NNt ,

λt + (1− α)kt + Zt = (1− η)ct + ξ1Nt ,

αξ2Et kt+1 − Et λt+1 + λt = αξ2Et Nt+1 + ξ2Et Zt+1,

aEt kt+1 − (aη/β)kt = −(c/k)ct + α(y/k)Nt + (y/k)Zt ,

ξ1 :=`θ(1− η)− 1

´ N1− N

+ 1− α,

ξ2 := 1− βa−η(1− δ).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 260 / 393

Page 261: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Loglinear approximationThe real business cycle model

The matrices Cu , Cxλ, and Cz from the static equations (78a) are:

Cu:=

»−η −θ((1− η) N

1−N1− η ξ1

–, Cxλ:=

»0 1

1− α 1

–, Cz :=

»01

–.

The matrices of the dynamic part of the system are:

Dxλ:=

»αξ2 −1a 0

–, Fxλ:=

»0 1

−βa−η 0

–,

Du:=

»0 αξ2

0 0

–, Fu:=

»0 0

−(c/k) α(y/k)

–,

Dz :=

»ξ2

0

–, Fz :=

»0

y/k

–.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 261 / 393

Page 262: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Loglinear approximationThe real business cycle model

The matlab program ramsey4d.m computes the policy functions Lxx , Lxz , Lux , and Luz :

xt+1 = Lxx xt + Lxz zt ,

zt+1 = %zt + εt+1,»ct

Nt

–= Lux xt + Luz zt

Output from ramsey4d.g: Lxx = 0.9614, Lxz = 0.1299, Llx = −0.4635,Llz = −0.2014, Lux = (0.2512, 0.0448)′, Luz = (0.5581, 1.0535)′

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 262 / 393

Page 263: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Loglinear approximationThe real business cycle model

Time series simulation: 500 simulations of 50 periods

Iteration over the dynamics to get time series for kt , zt , ct , nt

For production, investment, and wages, the time series can be computed with the helpof:

yt = αNt + (1− α)kt + Zt ,

it = (y/i)yt − [(y/i)− 1]ct , y/i = (y/k)/(a + δ − 1)

wt = yt − Nt .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 263 / 393

Page 264: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Loglinear approximationPercentage deviation in simulation: y, c, i, n, w

0 10 20 30 40 50 60−0.25

−0.2

−0.15

−0.1

−0.05

0

0.05

0.1

0.15

0.2

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 264 / 393

Page 265: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Real Business Cycle ModelLoglinear Approximation: ramsey4d.m

Standard deviations in %

Variable σx

Output y 1.53Investment i 7.07

Labor n 0.91Consumption c 0.49

Wage w 0.62

Correlation with output

Close to one for i (0.99), n (1.0), c (1.00), and w (1.0)

Autocorrelation of output: 0.63

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 265 / 393

Page 266: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Loglinear approximationImpulse response functions

Impulse response functions

percentage deviations of model variables following a technology shock Z0 = 1 inperiod 0 and zero thereafter

illustrate the dynamics of the model in response to a shock

comparable to the empirical observations: impulse responses from VAR

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 266 / 393

Page 267: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 1: The real business cycle model

Loglinear approximationImpulse response functions

0 10 20 30 400

0.2

0.4

0.6

0.8

1z

0 10 20 30 400

0.5

1

1.5

2k and y

0 10 20 30 400

2

4

6

8

10c and i

0 10 20 30 400

0.5

1

1.5n and w

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 267 / 393

Page 268: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 268 / 393

Page 269: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 269 / 393

Page 270: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 270 / 393

Page 271: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

A monetary business cycle model

Money demand motive:1 Money-in-the-utility: Sidrauski2 Cash-in-advance: consumption, investment3 transaction costs4 store of value

Role of frictions: sticky prices/wages necessary for significant real effects: Calvo pricestaggering

→ microfoundation for Phillips curve: New Keynesian Phillips curve (forward-looking)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 271 / 393

Page 272: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

1. Households

The household maximizes the expected discounted stream of future utility

E0

∞Xt=0

βtu(Ct , 1− Nt)

with

u(Ct , 1− Nt) :=C1−η

t (1− Nt)θ(1−η)

1− η. (96)

subject to the budget constraint

Wt

PtNt + rtKt + Dt + Tt − TCt − Ct ≥

Mt+1 −Mt

Pt+ Kt+1 − (1− δ)Kt . (97)

Dt — dividendsMt — beginning of period t money stockTt — government transfers

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 272 / 393

Page 273: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

Transaction costs:

TCt = γ

„Ct

Mt+1/Pt

«κ

Ct , γ, κ > 0. (98)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 273 / 393

Page 274: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

2. Monetary Authority

exogenous money growth µt := Mt+1/Mt :

µt+1 = ρµµt + εµt , µt := lnµt − lnµ, εµt ∼ N(0, σµ). (99)

In the stationary equilibrium money grows at the rate µ− 1.

The government transfers seignorage to the households:

Tt =Mt+1 −Mt

Pt. (100)

With this specification, money is neutral, but not super-neutral.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 274 / 393

Page 275: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

3. Final goods producers

assemble the output of a large number Jt of intermediary producers to the single goodYt according to

Yt =

24J−1/εt

JtXj=1

Y (ε−1)/εjt

35ε/(ε−1)

, ε > 1. (101)

Pjt – price of the intermediary good jPt – price of the final good

Maximizing its profits PtYt −PJt

j=1 PjtYj subject to (101) produces the following demandfor good j :

Yjt =

„Pjt

Pt

«−ε Yt

Jt. (102)

ε is the price elasticity of demand for good j .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 275 / 393

Page 276: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

No profit condition (perfect competition and free entry):

Pt =

24 1Jt

JtXj=1

P1−εjt

351/(1−ε)

. (103)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 276 / 393

Page 277: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

4. Intermediary goods’ producers

J firmsmonopolistic competitionCalvo price setting: in each period, a fraction (1− ϕ) can adjust their pricesoptimally (type A), the remaining ϕ producers increase their prices by the averageinflation π (type N).

Production of good j :

Yjt = Zt(AtNjt)1−αK α

jt − F , α ∈ (0, 1),F > 0 (104)

with a deterministic process for labor augmenting technical progress,

At+1 = aAt , a ≥ 1,

and Zt is a stationary, stochastic process for total factor productivity that follows

Zt+1 = ρZ Zt + εZt , Zt = ln Zt , ε

Zt ∼ N(0, σZ ).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 277 / 393

Page 278: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

Price setting of type N firms:

PNt = πPNt−1. (105)

Type A are free to adjust their price to optimize discounted real profits until the firmreset its price optimally again:

maxPAt

Et

∞Xτ=t

ϕτ−t%τ

»„πτ−tPAt

«YAτ − gτ (YAτ + F )

s.t. YAτ =

„πτ−tPAt

«−ε Yτ

Jτ.

(106)

with the discount factor depending on marginal utility of wealth:

%τ = βτ−t Λτ

Λt. (107)

gτ – the firm’s variable unit costs

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 278 / 393

Page 279: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

Intermediary producers distribute their profits to the household sector. Thus,

Dt :=

JtXj=1

Pjt

PtYjt −

Wt

PtNjt − rtKjt . (108)

The Calvo price setting implies the following dynamics of the optimal price:

(1− ϕ)(1− ϕβa−η)

ϕgt = −βa−ηEt πt+1 + πt . (109)

→ NEW KEYNESIAN PHILLIPS CURVE

gt is a measure of market tension (deviation of the marginal costs from its steady statelevel)

derivation: see Heer/Maussner, Appendix 4

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 279 / 393

Page 280: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

Stationary equilibrium

Stationary variables: ct := Ct/At , yt := Yt/At , kt := Kt/At , λt := ΛtAηt .

In addition, we define the inflation factor πt := Pt/Pt−1 and real end-of-period moneybalances mt := Mt+1/(AtPt).

Properties:

(1) The productivity shock and the money supply shock equal their respective meansZt = Z ≡ 1 and µt = µ for all t .

(2) Inflation is constant: π = PtPt−1

for all t .

(3) All (scaled) variables are constant.

(4) All firms in the intermediary sector earn zero profits.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 280 / 393

Page 281: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximation IThe New Keynesian Phillips Curve

Implications:

inflation is directly proportional to the growth rate of money supply µ− 1:

π =µ

a.

The optimal relative price of type A firms is a markup on the firm’s marginal cost g:

PA

P=

ε

ε− 1g,

Therefore, PA = P = PA, and all firms are equal Nj = N/J, and Kj = K/J,

Profits amount to

Dj =YJ− g

„YJ

+ F«.

Imposing Dj = 0 for all j and using Y/J = (AN/J)1−α(K/J)α − (F/J) yields

j :=Jt

At=

N1−αkα

εF.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 281 / 393

Page 282: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximation IIThe New Keynesian Phillips Curve

Production is given by

y =ε− 1ε

N1−αkα.

Cost minimization implies

r = α(y/k).

implying

yk

=aη − β(1− δ)

αβ. (110a)

The former result allows to solve for the consumption-output ratio via theeconomy’s resource constraint (see (??)):

cy

=

„1 +

1− a− δ

y/k

« »1 + γ

„C

µ(M/P)

«κ–−1

.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 282 / 393

Page 283: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximation IIIThe New Keynesian Phillips Curve

The stationary version of the Euler condition for money balances delivers:

βa1−η

µ= 1− κγ

„C

µ(M/P)

«1+κ

. (110b)

The labor supply is given by the foc of the household:

N1− N

=1− α

θ

„1 +

1− a− δ

y/k

«−1

h(c/x), (110c)

h(c/x) :=1 + γ(c/x)κ

1 + γ(1 + κ)(c/x)κ,

cx

:=PCµM

.

⇒ k/y , and therefore k/N and y/N are independent of the money growth rate µ!!⇒ velocity of money c/x increases with money growth⇒ steady-state working hours are a decreasing function of the money growth rate

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 283 / 393

Page 284: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

Loglinearization: see Appendix 4.

− (η + ξ1)ct − ξ2Nt = λt − ξ1xt , (111)

(1− η)ct − ξ3Nt − wt = λt , (112)

πt = mt − xt + µt , (113)

ξ1 :=κγ(1 + κ)(c/x)κ

1 + γ(1 + κ)(c/x)κ,

cx

=C

µ(M/P),

ξ2 := θ(1− η)N

1− N,

ξ3 := [θ(1− η)− 1]N

1− N.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 284 / 393

Page 285: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

The loglinear cost-minimizing conditions deliver two further equations:

αNt + wt = αkt + gt + Zt , (114)

(α− 1)Nt + rt = (α− 1)kt + gt + Zt . (115)

and

yt − ϑ(1− α)Nt = ϑαkt + ϑZt . (116)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 285 / 393

Page 286: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

aEt kt+1 − (1− δ)kt − ξ4xt =yk

yt − ξ5ct , (117)

−Et λt+1 + λt = ξ6Et rt+1, (118)

Et λt+1 − λt − ξ7xt = −ξ7ct + Et πt+1, (119)

Etmt+1 − xt = 0, (120)

ξ4 := κγ(c/x)κ(c/k),

ξ5 := (1 + γ(1 + κ)(c/x)κ)(c/k),

ξ6 := 1− βa−η(1− δ),

ξ7 :=κγ(1 + κ)(c/x)1+κ

1− γκ(c/x)1+κ.

and the New Keynesian Phillips curve (109).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 286 / 393

Page 287: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

Control variables:

ut := [ct , Nt , yt , πt , wt , rt ]′.

State variables:

xt = [kt , mt ]′.

Exogenous variables:

zt = [Zt , µt ]′.

Costate:

λt = [λt , gt , xt ]′.

Why is m′ = mt+1 a costate and not a state?

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 287 / 393

Page 288: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

Calibration

β, α, a, δ and θ as usual from the steady state conditions

Problem: we cannot identify Zt easily:

yt = ϑ(1− α)Nt + ϑαkt + ϑZt(1− ϑ)jt , ϑ =ε

ε− 1. (121)

In our benchmark real business cycle model:

yt = (1− α)Nt + αkt + Zt .

Since ϑ > 1 we overstate the size of Zt .

Money supply in Germany: we fit an AR(1) process for µt

We use the average velocity of money 0.84 to fix γ

We fix κ with the help of the interest elasticity of money demand -0.2:

d(M/P)/(M/P)

dq/q=

−1(1 + κ)π(1− δ + r)

.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 288 / 393

Page 289: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

Preference parameters:

β = 0.994, η = 2.0, N = 0.13

Production:

a = 1.005, δ = 0.011, σZ = 0.0072 ρZ = 0.90 , α = 0.27

Money supply:

µ = 1.0167, ρµ = 0.0, σµ = 0.0173

Transaction costs:

C/(M/P) = 0.84, κ = 4.0

Market structure:

ϕ = 0.25, ε = 6.0

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 289 / 393

Page 290: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

0 5 10 15 200

0.5

1technology shock z

0 5 10 15 200

0.5

1k and m

0 5 10 15 20−0.5

0

0.5

1c and N

0 5 10 15 200

0.5

1

1.5y and w

0 5 10 15 20−0.5

0

0.5Pi

0 5 10 15 20−0.5

0

0.5

1r

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 290 / 393

Page 291: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

0 5 10 15 200

0.5

1money shock mu

0 5 10 15 20−1

−0.5

0

0.5k and m

0 5 10 15 20−0.5

0

0.5

1c and N

0 5 10 15 200

0.2

0.4y and w

0 5 10 15 200

1

2Pi

0 5 10 15 20−0.5

0

0.5

1r

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 291 / 393

Page 292: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Loglinear approximationThe New Keynesian Phillips Curve

Observations and problems:1 expansionary effect of higher money growth2 spike-like behavior: no persistence of inflation!3 no liquidity effect4 profits decline following a monetary expansion

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 292 / 393

Page 293: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Loglinear Approximation Application 2: A monetary business cycle model

Reading Assignments and Problems

Reading Assignment

Heer, Maussner, Chapter 2.3, 2.4.1., 2.4.3., Appendix A.4.

Problems1 Simulate time series and compute second moments for the New Keynesian model.

Compute the impulse responses for the mark-up ratio.2 Solve problems 2.5 and 2.6 in Heer/Maussner, pp 150-153.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 293 / 393

Page 294: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 294 / 393

Page 295: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 295 / 393

Page 296: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 296 / 393

Page 297: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximation

Function approximation

local approximation, e.g. log-linear approximation

approximation over an interval [a, b]

Taylor’s theorem

TheoremLet f : [a, b] → R be a n + 1 times continuously differentiable function on (a, b), let x bea point in (a, b). Then

f (x + h) = f (x) + f (1)(x)h + f (2)(x)h2

2+ · · ·+ f (n)(x)

hn

n!

+ f (n+1)(ξ)hn+1

(n + 1)!, ξ ∈ (x , x + h).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 297 / 393

Page 298: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximation

Local approximation in Rn

e.g. quadratic approximation:

f (x + h) ≈ f (x) + [∇f (x)]′h +12

h′H(x)h, (122)

where the approximation error φ(h), with φ(0¯) = 0, has the property

limh→0

¯h 6=0

φ(h)

‖h‖2 = 0,

∇f (x) := [D1f (x),D2f (x), . . . ,Dnf (x)]′

and the Hesse matrix

H(x) :=

26664D1D1f (x) D1D2f (x) . . . D1Dnf (x)D2D1f (x) D2D2f (x) . . . D2Dnf (x)

......

. . ....

DnD1f (x) DnD2f (x) . . . DnDnf (x)

37775Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 298 / 393

Page 299: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximation

Linear interpolation

Suppose we want to approximate f (x) at a given point x with the property x1 < x < x2.Linear interpolation uses the point

f (x) := f (x1) +f (x2)− f (x1)

x2 − x1(x − x1). (123)

Thus, f is approximated by the line through (x1, f (x1)) and (x2, f (x2)).

MATLAB command for one-dimensional interpolation:y1=interp1(x,y,xi,’linear’)x – vector of nodesy – vector of function valuesxi – vector containing the points at which to interpolate

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 299 / 393

Page 300: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationLinear interpolation

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 300 / 393

Page 301: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationcubic spline

Splines: smooth function that is piecewise polynomial

Cubic spline

Suppose the data set {(xi , yi)|i = 0, . . . , n}.xi are called the nodes of the spline.On each subinterval [xi−1, xi ], the spline s(x) is cubic:

s(x) = ai + bix + cix2 + dix3

How do we determine the 4n parameters ai , bi , ci and ci?

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 301 / 393

Page 302: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationcubic spline

1 2n interpolating conditions

yi = ai + bixi + cix2i + dix3

i

yi = ai+1 + bi+1xi + ci+1x2i + di+1x3

i

2 The first and second derivatives must agree at the interior nodes i = 1, . . . , n − 1providing 2n − 2 conditions:

bi + 2cixi + 3dix2i = bi+1 + 2ci+1xi + 3di+1x2

i

2ci + 6dixi = 2ci+1 + 6di+1xi

→ linear equations in the unknown parameters, 2 conditions are missing

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 302 / 393

Page 303: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationcubic spline

1 Natural spline: imposes

s′(x0) = 0 = s′(xn)

2 Hermite spline: we know the true slopes

s′(x0) = y ′0, s′(xn) = y ′n

3 secant Hermit spline: we choose s(x) to make

s′(x0) =s(x1)− s(x0)

x1 − x0, s′(xn) =

s(xn)− s(xn−1)

xn − xn−1

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 303 / 393

Page 304: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationLinear versus cubic spline interpolation

An example

>> x=0.1:0.1:1;>> y=log(x);>> xi=0.1:0.01:1;>> yi=log(xi);>> yi1=interp1(x,y,xi,’linear’);>> yi2=interp1(x,y,xi,’cubic’);>> plot(xi,yi,’k-’, xi,yi1, ’k:’, xi,yi2, ’k’);>> error1=yi-yi1;>> error2=yi-yi2;

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 304 / 393

Page 305: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

Orthogonal polynomials

Weierstrass Theorem: Any continuous real-valued function f defined on a boundedinterval [a, b] of the real line can be approximated to any degree of accuracy using apolynomial

Approximation of a function on f (x) on [a, b] by a family of polynomial:

f (x) =nX

i=0

αiϕi(x),

The monomials x i , i = 0, 1, . . . build a base B, for this space, i.e., every member ofC[a, b] can be represented by

∞Xi=0

αix i .

For this reason it is common to use a linear combination of the first p members of thisbase to approximate a continuous function f (x) ∈ C[a, b]:

f (x) ' α0 + α1x + α2x2 + · · ·+ αpxp.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 305 / 393

Page 306: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationLinear versus cubic spline interpolation

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−2.5

−2

−1.5

−1

−0.5

0

0.5

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 306 / 393

Page 307: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationLinear versus cubic spline interpolation: error

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−0.01

0

0.01

0.02

0.03

0.04

0.05

0.06

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 307 / 393

Page 308: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

Orthogonal polynomials

Weierstrass Theorem: Any continuous real-valued function f defined on a boundedinterval [a, b] of the real line can be approximated to any degree of accuracy using apolynomial

Approximation of a function on f (x) on [a, b] by a family of polynomial:

f (x) =nX

i=0

αiϕi(x),

The monomials x i , i = 0, 1, . . . build a base B, for this space, i.e., every member ofC[a, b] can be represented by

∞Xi=0

αix i .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 308 / 393

Page 309: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

Approximation by a linear combination of the first p members of this base:

f (x) ' α0 + α1x + α2x2 + · · ·+ αpxp.

Problem: multicollinearity of xp−1, xp

→ orthogonal polynomials

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 309 / 393

Page 310: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

Assume we want to approximate f (x) ∈ C[a, b] by

f (x) :=nX

i=1

αiϕi(x),

where P := (ϕ0(x), ϕ1(x), . . . ) is some family of polynomials.

Let w(x) be a weight function on [a, b], i.e. a function that has a finite integralZ b

aw(x)dx <∞

and that is positive almost everywhere on [a, b]

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 310 / 393

Page 311: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

Problem: Continuous least-squares approximation of f (x):

Choose the parameters αi , i = 0, 1, . . . n such that the weighted sum of squared errorsR(α, x) := f (x)− f (α, x) over all x ∈ [a, b] attains a minimum:

minα

Z b

aw(x)

"f (x)−

nXi=0

αiϕi(x)

#2

dx . (124)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 311 / 393

Page 312: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

The first order conditions for this problem are

0 = 2Z b

aw(x)

24f (x)−nX

j=0

αjϕj(x)

35ϕi(x)dx , i = 0, 1, . . . , n,

which may be rewritten asZ b

aw(x)f (x)ϕi(x)dx =

nXj=0

αj

Z b

aw(x)ϕj(x)ϕi(x)dx ,

i = 0, 1, . . . , n.

(125)

If the integral on the rhs of (125) vanishes for i 6= j and equals a constant ζj for i = j , itwill be easy to compute αi from

αi =1ζi

Z b

aw(x)f (x)ϕi(x)dx .

This motivates the following definition of orthogonal polynomials: A set of functions P iscalled orthogonal with respect to the weight function w(x) if and only if:Z b

aw(x)ϕi(x)ϕj(x)dx =

0 if i 6= j,ζi if i = j. (126)

If in addition ζi = 1 ∀i , the set of functions is said to be orthonormal.Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 312 / 393

Page 313: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

Chebyshev polynomials

The domain of Chebyshev polynomials is the interval [−1, 1], and the i-th member ofthis family is defined by

Ti(x) = cos(i arccos x). (127)

The weight function for whichR 1−1 w(x)Ti(x)Tj(x)dx = 0 for i 6= j is given by

w(x) :=1√

1− x2. (128)

In particular, the following holds:

Z 1

−1

Ti(x)Tj(x)√1− x2

dx =

8<:0 if i 6= j,π2 if i = j ≥ 1,π if i = j = 0.

(129)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 313 / 393

Page 314: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

Approximation of g(x) ∈ C[−1, 1]

g(α, x) :=12α0 +

nXi=1

αiTi(x) (130)

The coefficients of the continuous least squares approximation are given by

αi =2π

Z 1

−1

g(x)Ti(x)√1− x2

dx . (131)

→ α0 is multiplied by the factor 1/2 so that (131) also holds for i = 0 where the integral(129) for i = j = 0 is equal to ζ0 = π.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 314 / 393

Page 315: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

Approximation of f (z), f : [a, b] → R

Use the following transformation of z:

X (z) =2z

b − a− a + b

b − a, z ∈ [a, b] (132)

and the reverse transformation

Z (x) =(x + 1)(b − a)

2+ a, x ∈ [−1, 1]. (133)

With these transformations, we can define the function g(x) = f (Z (x)) on the interval[−1, 1] with approximation

f (z;α) =nX

i=0

αiTi (X (z)) . (134)

The coefficients of the continuous least squares approximation are then given by

αj =2π

Z b

a

f (z)Tj(X (z))p1− (X (z))2

dz. (135)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 315 / 393

Page 316: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationOrthogonal polynomials

Properties of Chebyshev polynomials

We can compute the Chebyshev polynomials recursively:

Ti+1(x) = 2xTi(x)− Ti−1(x). (136)

The first four Chebyshev polynomials are

T0(x) = cos(0 · arccos x) = 1,

T1(x) = cos(1 · arccos x) = x ,

T2(x) = 2xT1(x)− T0(x) = 2x2 − 1,

T3(x) = 2xT2(x)− T1(x) = 4x3 − 3x .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 316 / 393

Page 317: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev polynomials

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 317 / 393

Page 318: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev polynomials

Evaluation of a n-th degree Chebyshev polynomial at x

Algorithm: Chebyshev Evaluation

Purpose: Evaluate a n-th degree Chebyshev polynomial at x

Step 1: Initialize: use the n + 1-vector y to store the values of Ti(x) for i = 0, 1, . . . , n.Put y [1] = 1 and y [2] = x .

Step 2: For i = 2, 3, . . . , n − 1 compute:

yi+1 = 2xyi − yi−1.

Step 3: ReturnPn

i=0 aiyi .

Matlab program: chebeval.m

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 318 / 393

Page 319: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev polynomials

Zeros of the Chebyshev polynomials

xk := cos„

2k − 12n

π

«, k = 1, 2, . . . , n. (137)

Useful property: Chebychev node polynomial interpolants are very nearly optimalpolynomial approximations

mXk=1

Ti(xk )Tj(xk ) =

8<:0 i 6= j,m/2 i = j 6= 0,m i = j = 0.

(138)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 319 / 393

Page 320: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev polynomials

Computation of the Chebyshev coefficients a ∈ Rn

1 Computation of the integral (135)2 Interpolation at the n nodes: f and the approximation coincide at n nodes3 Regression on m > n nodes

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 320 / 393

Page 321: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev polynomials

Assume we want to approximate f (x) ∈ C[a, b] by a n-th degree Chebyshevpolynomial.

Let x = [x1, x2, . . . , xm] denote the m zeros of Tm(x).

The corresponding points in the interval [a, b] are zk := Z (xk ) with yk = f (zk ).

We choose α = [α0, α1, . . . , αn−1] to solve

minα

mXk=1

24yk −n−1Xj=0

αjTj(X (zk ))

352

.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 321 / 393

Page 322: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev polynomials

The respective first order conditions are:

mXk=1

T0yk =n−1Xj=0

αj

mXk=1

T0Tj(xk ) = mα0,

mXk=1

yk T1(xk ) =n−1Xj=0

αj

mXk=1

T1(xk )Tj(xk ) = (m/2)α1,

... =...,

mXk=1

yk Tn−1(xk ) =n−1Xj=0

αj

mXk=1

Tn−1(xk )Tj(xk ) = (m/2)αn−1,

(139)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 322 / 393

Page 323: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev polynomials

Algorithm: Chebyshev Regression

Purpose: Approximate f (z) ∈ C[a, b] withPn−1

j=0 αjTj(x).

Step 1: Choose the degree n − 1 of the approximating Chebyshev polynomial.Compute m ≥ n Chebyshev interpolation nodes xk from (137) and adjust thenodes to the interval [a, b] using (133).

Step 2: For k = 1, 2, . . . ,m, compute yk = f (zk ).

Step 3: Compute the Chebyshev coefficients: α0 = (1/m)Pm

k=1 yk . Fori = 1, 2, . . . , n − 1 the coefficients are given by:

αi =2m

mXk=1

yk Ti(xk ).

Matlab program: Chebcoef.m

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 323 / 393

Page 324: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev approximation of y = ex , n = 2, m = 10

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 11

1.2

1.4

1.6

1.8

2

2.2

2.4

2.6

2.8

x

y

approximationexact solution

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 324 / 393

Page 325: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev polynomials

Chebyshev coefficients for approximation of f (x) = ex on [0, 1]

Coefficient n = 2, m = 10 n = 5, m = 10α0 1.753 1.753α1 0.850 0.850α2 0.105 0.105α3 0.0087α4 0.0005α5 0.000027

Matlab program: fig83.m

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 325 / 393

Page 326: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationChebyshev polynomials

Theorem

If f ∈ Ck [−1, 1] has a Chebyshev representation f (x) =P∞

i=1 αiTi(x), then there is aconstant c such that

|αi | ≤cik , i ≥ 1. (140)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 326 / 393

Page 327: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximation IMultidimensional Approximation

Multidimensional Approximation

Choice of Bases

1 tensor product; e.g.ϕk (xi) ≡ xki . The set

T :=

(nY

i=1

ϕki (xi)|ki = 0, 1, . . . p

)

In the stochastic growth model with x = (K ,Z ), p = 2, T is given by

{K 0Z 0,K 0Z 1,K 0Z 2,K 1Z 0,K 1Z 1,K 1Z 2,K 2Z 0,K 2Z 1,K 2Z 2}

≡ {1,Z ,Z 2,K ,KZ ,KZ 2,K 2,K 2Z ,K 2Z 2}.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 327 / 393

Page 328: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximation IIMultidimensional Approximation

2 Complete set of polynomials:

Pnp =

((xk1

1 xk22 · · · xkn

n )

˛ nXi=1

ki = j, ki ≥ 0, j = 0, 1, 2, . . . , p

)

Thus, for x = (K ,Z ) and p = 2, the set is

P22 ={K 0Z 0| {z }

j=0

,K 1Z 0,K 0Z 1| {z }j=1

,K 2Z 0,K 1Z 1,K 0Z 2| {z }j=2

},

= {1,K ,Z ,K 2,KZ ,Z 2}.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 328 / 393

Page 329: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationMultidimensional Approximation

Chebyshev approximation in two dimensions

Let f (z1, z2) be a function on [a, b]× [c, d ]:

n1Xj1=0

n2Xj2=0

αj1 j2 Tj1(X (z1))Tj2(X (z2)). (141)

Choose m1 ≥ n1 + 1 and m2 ≥ n2 + 1 and compute the zeros of the m1-dimensionaland m2-dimensional Chebyshev polynomial, adjusted to the interval [a, b] and [c, d ],respectively:

yk1k2 := f (Z (x1k1),Z (x2k2)),

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 329 / 393

Page 330: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationMultidimensional Approximation

The least squares criterion

minm1X

k1=1

m2Xk2=1

24yk1k2 −n1X

j1=0

n2Xj2=0

αj1 j2 Tj1(x1k1)Tj2(x2k2)

352

.

yields the following first-order condition with respect to αj1 j2 :

m1Xk1=1

m2Xk2=1

yk1k2 Tj1(x1k1)Tj2(x2k2)

=

m1Xk1=1

m2Xk2=1

n1Xi1=0

n2Xi2=0

αi1 i2 Ti1(x1k1)Ti2(x2k2)Tj1(x1k1)Tj2(x2k2)

=

n1Xi1=0

n2Xi2=0

αi1 i2

m1Xk1=1

Ti1(x1k1)Tj1(x1k1)| {z }= 0 if j1 6= i1= m1/2 if j1 = i1 6= 0= m1 if j1 = i1 = 0

m2Xk2=1

Ti2(x2k2)Tj2(x2k2)| {z }= 0 if j2 6= i2= m2/2 if j2 = i2 6= 0= m2 if j2 = i2 = 0

.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 330 / 393

Page 331: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Function Approximation

Function approximationMultidimensional Approximation

Therefore, we get the following estimator:

α00 =1

m1m2

m1Xk1=1

m2Xk2=1

yk1k2 ,

α0j2 =1

m1

2m2

m1Xk1=1

m2Xk2=1

yk1k2 Tj2(x2k2),

αj10 =2

m1

1m2

m1Xk1=1

m2Xk2=1

yk1k2 Tj1(x1k1),

αj1 j2 =2

m1

2m2

m1Xk1=1

m2Xk2=1

yk1k2 Tj1(x1k1)Tj2(x2k2).

(142)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 331 / 393

Page 332: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 332 / 393

Page 333: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 333 / 393

Page 334: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 334 / 393

Page 335: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Numerical integration

1. Newton-Cotes Formulas

Z b

af (x)dx ≈

nXi=1

ai f (xi). (143)

fix nodes xi , usually equispaced

approximate f (x) by piecewise polynomials: choice of ai

e.g. linear Lagrange polynomial:

P1(x) =x − ba− b

f (a) +x − ab − a

f (b) (144)

results in:Z b

af (x)dx ≈ b − a

2[f (a) + f (b)] . (145)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 335 / 393

Page 336: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Numerical integration

2. Gaussian formulas

choose both xi and ai optimally

Importance of orthogonal families of polynomials for numerical integration:

TheoremSuppose that {ϕi(x)}∞i=0 is an orthonormal family of polynomials with respect to theweight function w(x) on [a, b] with ϕi(x) = qix i + qi−1x i−1 + . . .+ q0. Let xi ,i = 1, . . . , n, be the n zeros of ϕn. Then a < x1 < · · · < xn < b, and if f ∈ C(2n)[a, b],then Z b

aw(x)f (x)dx =

nXi=1

ωi f (x i) +f 2n(ζ)

q2n(2n)!

, (146)

for some ζ ∈ [a, b], where

ωi = − qn+1/qn

ϕ′n(xi)ϕn+1(xi)> 0.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 336 / 393

Page 337: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Numerical integration I

Accordingly, we can evaluate the integral of a polynomial of degree 2n − 1 exactly byapplying formula (146).

Gauss-Chebyshev quadrature

constant weights ωi

The Gauss-Chebyshev quadrature formula for a function f (x) on the interval[−1, 1] is defined by:Z 1

−1

f (x)√1− x2

dx =π

n

nXi=1

f (x i) +π

22n−1

f (2n)(ζ)

(2n)!

for some ζ ∈ [−1, 1], where the quadrature nodes x i are the zeros of theChebyshev polynomial Tn(x)

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 337 / 393

Page 338: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Numerical integration II

For integrals of the formR b

a f (z)dz, we use (133) to adjust [−1, 1] to [a, b]. Sincethe linear transformation (133) implies

dz =b − a

2dx ,

we can derive the following approximation:Z b

af (z)dz =

Z 1

−1f (Z (x))

b − a2

√1− x2

√1− x2

dx

≈ π(b − a)

2n

nXi=1

f„

(x i + 1)(b − a)

2+ a

« q1− x2

i ,

(147)

where the x i , again, are the Chebyshev zeros from (137).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 338 / 393

Page 339: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Gauss Hermite quadrature

E(f (z)) ' π−1/2nX

i=1

ωi f“√

2σx + µ”. (148)

For n = 2, . . . , 4 the integration nodes and weights are provided in table 8.2,Heer/Maussner.

usually applied to evaluate conditional expectations where the stochastic variableis distributed normally

weight function is ω(x) = e−x2

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 339 / 393

Page 340: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Assume that z ∼ N(µ, σ). Then

E(f (z)) := (2πσ2)−1/2Z ∞

−∞f (z)e[(z−µ)2/2σ2]dz.

Since

x =z − µ√

has a standard normal distribution (i.e., E(x) = 0 and var(x) = 1), we get

E(f (z)) = π−1/2Z ∞

−∞f

“√2σx + µ

”e−x2

dx ,

where we used

dz =√

2σdx .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 340 / 393

Page 341: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Numerical integration

Multidimensional integration

use product rules: curse of dimensionality

monomial formulas

Computation of the integral of f (z1, . . . , zn) over the n-dimensional rectangle[a1, b1]× [a2, b2]× . . . [an, bn] the Gauss-Chebyshev quadrature (147) impliesZ b1

a1

. . .

Z bn

an

f (z1, . . . , zn)dz1 . . . dzn

'πn(b1 − a1) . . . (bn − an)

(2m)n

mXi1=1

· · ·mX

in=1

f (Z (x1), . . . ,Z (xn))

q1− x2

i1. . .

q1− x2

in .

(149)

In this formula Z (xi) denotes the linear transformation given in equation (133), and xi isthe i-th the zero of the Chebyshev polynomial of degree m.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 341 / 393

Page 342: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Numerical integration

⇒ Matlab provides only quadrature for Newton-Codes formula: Simpson rule(approximation with piecewise second-order polynomials)

quad(’f1’,0,1)

evaluate the function f1 over the interval [0, 1].

Matlab also provides routine for 2- and 3-dimensional Simpson rule integration.

See our Matlab code gc_int1.m and gh_int1.m for one-dimensional integration withGauss Chebyshev and Gauss Hermite, respectively.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 342 / 393

Page 343: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Matlab Program

function v=gc_int1(f,d,n)temp=1:1:n;temp=temp’;x=cos(((2*temp-1)/(2*n))*pi);z=(x+1).*(d(2)-d(1))*0.5 + d(1);sum=0;

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 343 / 393

Page 344: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Matlab Program

for i=1:ny=feval(f,z(i));sum=sum+y*sqrt(1-x(i)^2);

endsum=pi*(d(2)-d(1))*sum;v=sum/(2*n);

→ evaluate f (x) = ex with Simpson rule and Gauss Chebyshev quadrature

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 344 / 393

Page 345: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

More Numerical Methods Numerical Integration

Reading Assignments and Problems

Reading Assignment

Heer, Maussner, Chapter 8.2 and 8.3

Judd, Chapter 6.9, optional chapter 6

Miranda, Fackler, Chapter 5, optional: Chapter

Problems1 Write program codes chebeval2.m and chebcoef2.m that evaluate a complete

Chebyshev polynomial of order n1 × n2 and compute the coefficients in order toapproximate a two-dimensional function f (x) : [a, b]× [c, d ] → R. Test your codewith the help of the function f (x , y) = x ln(y) on the interval [0, 1]× [1, 5].

2 Write program codes for two-dimensional integration with the help ofGauss-Chebyshev and Gauss-Hermite quadrature.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 345 / 393

Page 346: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods A simple example

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 346 / 393

Page 347: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods A simple example

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 347 / 393

Page 348: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods A simple example

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 348 / 393

Page 349: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods A simple example

Projection methods

A simple example

Consider the ordinary differential equation

x(t) + x(t) = 0, x(0) = 1, (150)

with solution

x(t) = e−t .

Suppose we use the monomials (1, t , t2) to approximate the solution in the interval[0, 2]:

x(t) = 1 + γ1t + γ2t2. (151)

We have set γ0 = 1 to satisfy the boundary condition x(0) = 1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 349 / 393

Page 350: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods A simple example

Projection methods

Let us define the residual function:

R(γ, t) := γ1 + 2γ2t| {z }dx/dt

+ 1 + γ1t + γ2t2| {z }x(t)

(152)

Our aim: Choose (γ1, γ2) to make the residual small.

Least squares:

minγ1,γ2

Z 2

0R(γ, t)2dt . (153)

The first-order conditions for this problem are given by the following two equations:

0 =

Z 2

0R(γ, t)

∂R(γ, t)∂γ1

dt ,

0 =

Z 2

0R(γ, t)

∂R(γ, t)∂γ2

dt .

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 350 / 393

Page 351: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods A simple example

Projection methods

In our example, explicit analytical solution:

−4 = 823γ1 + 16γ2,

−623

= 16γ1 + 331

15γ2.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 351 / 393

Page 352: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods A simple example

Projection methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 352 / 393

Page 353: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods A simple example

Projection methods

Galerkin method

multiplying the residual by the basis functions

0 =

Z 2

0R(γ, t)tdt ,

0 =

Z 2

0R(γ, t)t2dt .

(154)

Computing the integrals on the rhs of (154) gives a second set of linear equations inthe unknown parameters γ1 and γ2:

−2 = 423γ1 + 9

13γ2,

−223

= 623γ1 + 14

25γ2.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 353 / 393

Page 354: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods A simple example

Projection methods

Collocation

Residual function is equal to zero at a given set of points.

Suppose we choose t1 = 1 and t2 = 2. This gives the linear system

−1 = 2γ1 + 3γ2,

−1 = 3γ1 + 8γ2.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 354 / 393

Page 355: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods The general framework

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 355 / 393

Page 356: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods The general framework

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 356 / 393

Page 357: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods The general framework

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 357 / 393

Page 358: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods The general framework

Projection methods I

The general framework

We want to approximate an unknown function f : X → Y , where X and Y aresubsets of Rn and Rm, respectively.

This function is implicitly defined by the functional equation F (f ) = 0, whereF : C1 → C2. C1 and C2 are given spaces of functions, e.g., the set of allcontinuously differentiable functions on [a, b].

Given a family of polynomials P := {ϕi}∞i=0, we approximate f by a finite linearcombination of the first p + 1 members of this family:

f (x) =

pXi=0

γiϕi(x), x ∈ X ⊂ Rn. (155)

The residual function is obtained by substituting f into the functional equation:

R(γ, x) := F (f (γ, x)), γ := (γ0, . . . , γp).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 358 / 393

Page 359: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods The general framework

Projection methods II

Suppose there is a set of test functions {gi(x)}pi=0 and a weight function w(x).

Together with R they define an inner product given byZX

w(x)R(γ, x)gi(x)dx.

On a function space, this inner product induces a norm (i.e., a measure ofdistance) on this space and we choose the vector of parameters γ so thatZ

Xw(x)R(γ, x)gi(x)dx = 0, ∀i = 0, 1, . . . , n. (156)

Three possible choices of gi :1 The least squares solution puts gi ≡ ∂R/∂γi and w ≡ 1.2 The Galerkin solution chooses gi ≡ ϕi and w ≡ 1.3 The collocation method uses the Dirac delta function weight function,

w(x) =

0 if x 6= xi ,1 if x = xi ,

and puts gi ≡ 1.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 359 / 393

Page 360: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods The general framework

Projection methods I

Algorithm: Projection Method

Prupose: Approximate the solution f : X → Y of a functional equation F (f ) = 0.

Step 1: Choose a bounded state space X ⊂ Rn and a family of functionsϕi(x) : X → Y , i = 0, 1, . . . .

Step 2: Choose a degree of approximation p and let

f (γ, x) =

pXi=0

γiϕi(x).

Step 3: Define the residual function:

R(γ, x) := F (f (γ, x)).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 360 / 393

Page 361: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods The general framework

Projection methods II

Step 4: Choose a projection function gi , a weight function w and compute the innerproduct:

Gi :=

ZX

w(x)R(f¯γ, x)gi(x)dx, i = 0, . . . , n.

Find the value of γ that solves Gi = 0, or, in the case of least squaresprojection (gi = ∂R/∂γi and w ≡ 1), minimizeZ

XR(γ, x)2dx

with respect to γ.

Step 5: Verify the quality of the candidate solution γ. If necessary, return to step 2 andincrease the degree of approximation p or even return to step 1 and choose adifferent family of basis functions.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 361 / 393

Page 362: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods The general framework

Projection methods IBuilding blocks

1 Approximating Function

prime candidate are orthogonal polynomials: Chebyshev functionsProblem of monomials: collinearity

2 Residual Function:

Consider the Euler equation of the deterministic growth model:

0 =u′(Ct)

u′(Ct+1)− βf ′(Kt+1),

Kt+1 = f (Kt)− Ct ,

Possible residual functions:

R1(γ,K ) :=u′[C(γ,K )]

u′[C(γ, f (K )− C(γ,K ))]

− βf ′[f (K )− C(γ,K )].

(157)

R2(γ,K ) := u′(C(γ,K ))

− βu′[C(γ, f (K )− C(γ,K ))]f ′[f (K )− C(γ,K )]

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 362 / 393

Page 363: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods The general framework

Projection methods IIBuilding blocks

3 Projection:I Least squares: often fails in multi-dimensional state spaceI Galerkin: time-consuming in multi-dimensional state space due to the integration stepI Collocation: often very fast, problem to pick the nodes if polynomial is not the tensor

product, but only a complete polynomial

Problem: finding an initial value for γ.

Possible solution: coefficients from log-linear solution4 Accuracy of solution

I study the behavior of the residualI study the behavior of the γi : do they drop off nicely?I den Haan-Marcet statisticI compare a simple case to solution with another method, e.g. from value function

iteration or log-linear

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 363 / 393

Page 364: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 364 / 393

Page 365: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 365 / 393

Page 366: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 366 / 393

Page 367: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Projection methodsDeterministic Ramsey model

Application: deterministic Ramsey model

maxC0,C1,...

U0 =∞Xt=0

βt C1−ηt − 11− η

, β ∈ (0, 1) , η > 0,

s.t. (158)

Kt+1 + Ct ≤ K αt + (1− δ)Kt , α ∈ (0, 1),

0 ≤ Ct ,0 ≤ Kt+1,

9=; t = 0, 1, . . . ,

K0 given,

The Euler equation of this problem is given by:»Ct+1

Ct

–−η

β“

1− δ + αK α−1t+1

”− 1 = 0. (159)

From this equation we derive the steady state value of the capital stock:

K ∗ =

»αβ

1− β(1− δ)

–1/(1−α)

.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 367 / 393

Page 368: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Projection methods IDeterministic Ramsey model

Implementation: Ramseyproj.m

Choice of the state space [K ,K ] that embeds the steady state value K ∗:

→ should contain the ergodic set→ we choose X := [0.5K ∗, 1.5K ∗]→ try others

→ sometimes it may be helpful to choose two sets X ⊂ X ′. You approximate thepolicy function over the set X ′ and compute the residual over X .

We approximate the consumption function C(K ) with the help of a Chebyshevpolynomial of order p,

C(γ,K ) :=

pXj=0

γjTj(K (K )),

where K (K ) maps the capital stock K into the interval [−1, 1]

Initial guess of γ:1 Solution from Log-Linearization2 Solution from Value Function Iteration and approximation with Chebyshev regression →

our implementation

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 368 / 393

Page 369: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Projection methods IIDeterministic Ramsey model

3 Genetic search: see Heer/Maussner, ramsey2b.g4 Homotopy: Start from known initial solution, e.g. with δ = 0 and increase δ step by

step and use the new solution for γ in the next iteration

Computation of the residual function:

R2(γ,K ) := u′(C(γ,K ))

− βu′[C(γ, f (K )− C(γ,K ))]f ′[f (K )− C(γ,K )]

1 Given γ and K0 ∈ [K , K ] we compute C0 := C(γ, K0).

→ C0 > 0?2 From C0 we compute the future stock of capital K1 from the resource constraint:

K1 = K α + (1− δ)K − C0.

→ K1 ∈ X?3 Given K1 we get C1 := C(γ, K1).→ C1 > 0?

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 369 / 393

Page 370: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Projection methods IIIDeterministic Ramsey model

4 In this final step we compute the residual from

R(γ, K0) :=

"C1

C0

#−η “1− δ + αK α−1

1

”− 1.

Galerkin projection: We use Gauss Chebyshev quadrature with 100 nodes andsolve the system of p + 1 non-linear equations:

π(K − K )

2L

LXl=1

R(γ,K (Kl))Ti(Kl)

q1− K 2

l ,

i = 0, 1, . . . , p.

(160)

Chebyshev collocation: we determine the coefficients γ0, . . . , γp from theconditions:

R(γ,K (Ki)) = 0, ∀i = 0, 2, . . . , p, (161)

where, again, Ki is the i-th zero of the Chebyshev polynomial of order p + 1.

We solve the non-linear equation problem with Broyden’s algorithm.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 370 / 393

Page 371: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Projection methods

Solution from ramseyproj.m

Chebyshev coefficient for Collocation and Galerkin:

aCol =

[email protected]

−0.03470.0052

−0.0008

1CCCCA aGal =

[email protected]

−0.03460.0051

−0.0009

1CCCCA

Running time: 0.064 and 0.471 seconds

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 371 / 393

Page 372: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Projection methodsCollocation solution of Ramsey model

0 10 20 30 40 50 60 70 80 90

1.4

1.6

1.8

2

2.2

2.4

2.6

2.8

3

3.2

capital stock

c

value functioncollocation

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 372 / 393

Page 373: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Projection methodsCollocation solution of Ramsey model

0 10 20 30 40 50 60 70 80 90

1.4

1.6

1.8

2

2.2

2.4

2.6

2.8

3

3.2

capital stock

c

collocationGalerkin

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 373 / 393

Page 374: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Projection methodsResidual: Collocation solution

20 30 40 50 60 70 80−3

−2

−1

0

1

2

3

4

5x 10−5

capital stock

resi

dual

collocationGalerkin

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 374 / 393

Page 375: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Projection Methods Application: Deterministic Ramsey model

Reading Assignments and Problems

Reading Assignment

Heer, Maussner, Chapter 4.1.-4.3.2.

Judd, Chapter 11, optional

Problems1 Compute the stochastic growth model with non-negative investment as in section

4.3.2 in Heer/Maussner. Write a Matlab program. Compute the second momentsof the model variables (after HP filtering) for σ ∈ {0.0072, 0.05}. Simulate themodel and compute the average error of the Euler equation. In order to computethe expectation for the residual use Gauss Hermite quadrature with 10 points.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 375 / 393

Page 376: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Perturbation methods

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 376 / 393

Page 377: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Perturbation methods

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 377 / 393

Page 378: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Perturbation methods

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 378 / 393

Page 379: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Perturbation methods

Perturbation methods

Perturbation methods

local approximation of f (x)

higher-order polynomial

higher accuracy than loglinear or linear approximationproblems:

1 computation of the higher-order derivatives: numerical derivatives are often not exactenough

→ problem in Gauss or Fortran, Matlab is able to compute analytical derivatives→ you may want to download the code by Schmitt-Grohe and Uribe

2 solution boils down to solving the log-linearization and additional non-linear equations:easy computational problem

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 379 / 393

Page 380: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Parameterized expectations

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 380 / 393

Page 381: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Parameterized expectations

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 381 / 393

Page 382: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Parameterized expectations

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 382 / 393

Page 383: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Parameterized expectations

Perturbation methods

Parameterized expectations: An example

Kt+1 = ZtK αt + (1− δ)Kt − Ct , (162a)

C−ηt = βEt

ˆC−η

t+1

“1− δ + αZt+1K α−1

t+1

” ˜. (162b)

Remember, Ct denotes consumption, Kt the stock of capital, and Zt is the size of theshock to total factor productivity that evolves over time according to

Zt = Z %t−1eεt , εt ∼ N(0, σ2). (162c)

→ solution is time-invariant function Kt+1 = g(Kt ,Zt).

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 383 / 393

Page 384: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Parameterized expectations

Perturbation methods

Solution for consumption:

C(Kt ,Zt) := ZtK αt + (1− δ)Kt − g(Kt ,Zt)

and Ct+1 = C(g(Kt ,Zt),Zt+1).

Let φ(Kt ,Zt , εt+1) be the expression inside the expectations operator Et in a function:

φ(Kt ,Zt , εt+1) :=C(g(Kt ,Zt),Z %t eεt+1)−η

ד

1− δ + αZ %t eεt+1 g(Kt ,Zt)

α−1”.

Since the innovations to are normal variables with density π(ε), we get E via integrationof φ(·)π(ε):

E(Kt ,Zt) :=

Z ∞

−∞φ(Kt ,Zt , ε)π(ε)dε.

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 384 / 393

Page 385: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Parameterized expectations

Perturbation methods

Approximation of E

Approximate E by a simple parameterized function, e.g.

ψ(γ1, γ2, γ3,Kt ,Zt) = γ1K γ2t Z γ3

t

Make an initial guess of the parameter γ.

Given K0 and Z0, we can compute the rhs of equation (162b) and solve the systemof two equations (162) for K1 and C0.

With K1 at hand, Z1 derived from Z0, and a draw from the N(0, σ2)-distribution, wecan use E(K1,Z1) and (162) again to solve for (K2,C1).

Simulate a time series: Repeating these steps over and over we can trace out anentire time path for the variables of our model economy.

Minimize the mean squared error in forecasting E with respect to the parameter γMain difference to projection methods:

1 Simulates a time series with the model2 Uses a non-linear regression step to update γ3 The residual is weighted by its probability

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 385 / 393

Page 386: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook The curse of dimensionality

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 386 / 393

Page 387: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook The curse of dimensionality

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 387 / 393

Page 388: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook The curse of dimensionality

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 388 / 393

Page 389: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook The curse of dimensionality

Curse of dimensionality

Curse of dimensionality

If the dimension ns of the state space is getting large, it is difficult to find a solution

Value function iteration: difficult for ns > 1

Log-linearization: no problem, but may be inaccurateProjection methods:

I ns � 15 is troublesomeI Galerkin: integration step is too time-consuming even with complete polynomialsI Chebyshev collocation: problem to fix collocation nodes for complete polynomials

(Smolyak’s Algorithm)

Projection methods: preliminary research results indicate that they may perform ina rather satisfactory manner for high dimensions

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 389 / 393

Page 390: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Heterogeneous agents

Contents I1 The Deterministic Finite-Horizon Ramsey Model

The Ramsey ProblemThe Kuhn-Tucker ProblemNumerical solution

2 Numerical Methods: Non-Linear EquationsThe problemBisectionNewton’s Method

3 The Infinite-Horizon Ramsey ModelThe modelDynamic ProgrammingTransition DynamicsDifference Equations

4 Linear AlgebraReview: Basics from Linear AlgebraLinear Equations

5 Application: Reverse Shooting6 The Stochastic Ramsey Model

The modelStochastic Dynamic Programming

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 390 / 393

Page 391: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Heterogeneous agents

Contents II7 Real Business Cycle Model

Growth, Leisure and Business CyclesThe benchmark real business cycle modelCalibration of the benchmark modelComputation of the benchmark model 1: Value function iterationEvaluation of the Model

8 Loglinear ApproximationIllustrative ExampleThe General MethodApplication 1: The real business cycle modelApplication 2: A monetary business cycle model

9 More Numerical MethodsFunction ApproximationNumerical Integration

10 Projection MethodsA simple exampleThe general frameworkApplication: Deterministic Ramsey model

11 OutlookPerturbation methods

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 391 / 393

Page 392: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Heterogeneous agents

Contents IIIParameterized expectationsThe curse of dimensionalityHeterogeneous agents

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 392 / 393

Page 393: Munich Graduate Program Burkhard Heer · PDF fileMunich Graduate Program Burkhard Heer ... The Kuhn-Tucker Problem ... The Kuhn-Tucker Problem The Ramsey Problem max (C0,...,CT) U(C

Outlook Heterogeneous agents

Heterogeneous agents I

Heterogeneous agents

Exogenous source of heterogeneity:1 innate abilities2 education3 individual productivities4 wage5 age

Endogenous distribution1 wealth2 income

Question: Does the distribution of income and wealth effect the endogenousaggregate variables like savings, total income and employment?

computation of the endogenous distribution difficult and time-consuming

computation of the dynamics of the distribution: very difficult:→ see Chapters 5-7 in Heer/Maussner

Burkhard Heer (University of Bolzano-Bozen, Italy) Computational Economics 4. September 2006 393 / 393