solving and estimating heterogeneous agent models with

208
1/178 Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods Short Course CEMFI R. Luetticke UCL, CEPR & CfM March 2021

Upload: others

Post on 19-Apr-2022

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Solving and Estimating Heterogeneous Agent Models with

1/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Solving and EstimatingHeterogeneous Agent Modelswith Aggregate Uncertaintyby Perturbation Methods

Short Course CEMFI

R. LuettickeUCL, CEPR & CfM

March 2021

Page 2: Solving and Estimating Heterogeneous Agent Models with

2/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Heterogeneous agents models with aggregate uncertainty

These models are computational demanding to solve

I The original Krusell and Smith (1997, 1998) algorithm is notoriously slow

I Therefore, many papers study transitions

I or are restricted to relatively simple household decisions

I We depart from the Reiter (2002, 2009) perturbation method

I And (try to) provide an accessible algorithm that can deal with high-dimensionalheterogeneity

Page 3: Solving and Estimating Heterogeneous Agent Models with

2/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Heterogeneous agents models with aggregate uncertainty

These models are computational demanding to solve

I The original Krusell and Smith (1997, 1998) algorithm is notoriously slow

I Therefore, many papers study transitions

I or are restricted to relatively simple household decisions

I We depart from the Reiter (2002, 2009) perturbation method

I And (try to) provide an accessible algorithm that can deal with high-dimensionalheterogeneity

Page 4: Solving and Estimating Heterogeneous Agent Models with

3/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Reiter (2002): Solve by perturbation

I Models can be written as a non-linear difference equation:EF(Xt, Xt+1, Yt, Yt+1, εt+1) = 0

The heterogeneous agent model:

I that is function valued and

I needs to be linearized around the stationary equilibrium (StE)

I Functions need to be approximated by finite dimensional objects (e.g. coefficients ofpolynomials, splines, etc.)

I We show how to do this in a smart efficient way

Page 5: Solving and Estimating Heterogeneous Agent Models with

3/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Reiter (2002): Solve by perturbation

I Models can be written as a non-linear difference equation:EF(Xt, Xt+1, Yt, Yt+1, εt+1) = 0

The heterogeneous agent model:

I that is function valued and

I needs to be linearized around the stationary equilibrium (StE)

I Functions need to be approximated by finite dimensional objects (e.g. coefficients ofpolynomials, splines, etc.)

I We show how to do this in a smart efficient way

Page 6: Solving and Estimating Heterogeneous Agent Models with

4/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Course outline

Basics

I Standard incomplete markets model

I Perturbation approach

Solving SIM by perturbation

I Our reduction method

I Application: Solving the Krusell&Smith model

I Comparison to MIT shock solution

HANK models

I Application: Estimation of HANK models

Page 7: Solving and Estimating Heterogeneous Agent Models with

5/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Resources

I Lecture slides

I Coding exercisesI I provide templates for their solution in MATLAB or Julia.

Page 8: Solving and Estimating Heterogeneous Agent Models with

6/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Heterogeneous agents models with aggregate uncertainty

Available codes:

I Perturbation vs MIT shock for KS model (Matlab)https://github.com/ralphluet/KS_Perturbation_vs_MIT

I Perturbation with our reduction for KS and HANK models (Matlab)https://github.com/ralphluet/perturbation_codes

I Perturbation with our reduction for HANK models (Python)https://github.com/econ-ark/BayerLuetticke

I Perturbation with our reduction for estimating HANK models (Julia)https://github.com/BenjaminBorn/HANK_BusinessCycleAndInequality

Page 9: Solving and Estimating Heterogeneous Agent Models with

7/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Literature - Academic articles

Perturbation:

I Reiter (2002, 2009), Ahn et al. (2018), Bayer and Luetticke (2020), and Bayer et al.(2019)

I ...

MIT shock:

I Boppart et al. (2018) and Auclert et al. (2019)

I ...

Global:

I Carroll (2006) and Hintermaier and Koeniger (2010)

I ...

Page 10: Solving and Estimating Heterogeneous Agent Models with

8/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Literature - Textbooks

I Heer, B. and A. Maussner (2009), ”Dynamic General Equilibrium Modelling”, 2nd edition,Springer, Berlin.Getting started: Ch. 1, 4, 7, 8

I Adda, J. and R. Cooper (2004): ”Dynamic Economics”, MIT Press, Cambridge.Partial Equilibrium only, Many Applications with Non-Convex Budget Sets.

I Ljungqvist, L. und T. Sargent (2012): ”Recursive Macroeconomic Theory”, 3rd ed., MITpress, Cambridge.Economic Theory Background

I Stockey, N.L. and Lucas, R.E. with E.C. Prescott (1989): ”Recursive Methods inEconomic Dynamics”, Chapters 4 and 9, Havard University Press, Cambridge.Mathematical Background to Dynamic Programming

I An excellent quantitative econ source (for Python and Julia though):lectures.quantecon.org by Tom Sargent et al.

Page 11: Solving and Estimating Heterogeneous Agent Models with

9/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

SIMModel Setup

Page 12: Solving and Estimating Heterogeneous Agent Models with

10/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Recursive Dynamic Planning Problem

Consider a household problem in presence of aggregate and idiosyncratic risk

I St is an (exogenous) aggregate state

I sit is a partly endogenous idiosyncratic state

I µt is the distribution over s

I Bellman equation:

ν(sit, St, µt) = maxx∈Γ(sit,Pt)

u(sit, x) + βEν(sit+1(x, sit), St+1, µt+1)

Page 13: Solving and Estimating Heterogeneous Agent Models with

10/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Recursive Dynamic Planning Problem

Consider a household problem in presence of aggregate and idiosyncratic risk

I St is an (exogenous) aggregate state

I sit is a partly endogenous idiosyncratic state

I µt is the distribution over s

I Euler equation:

u′[x(sit, St, µt)] = βR(St, µt)Eu′[x(sit+1, St+1, µt+1)],

Page 14: Solving and Estimating Heterogeneous Agent Models with

11/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

No aggregate risk

Recall how to solve for a stationary equlibrium:

I Discretize the state space (vectorized)

I Optimal policy h(sit; P) induces flow utility uh and transition probability matrix Πh

Page 15: Solving and Estimating Heterogeneous Agent Models with

12/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

No aggregate risk

I Discretized Bellman equation

ν = uh + βΠhν (1)

holds for optimal policy (assuming a linear interpolant for the continuation value)

I and for the law of motion for the distribution (histograms)

dµ = dµΠh (2)

Page 16: Solving and Estimating Heterogeneous Agent Models with

13/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

No aggregate risk

Equilibrium requires

I h is the optimal policy given P and ν (being a linear interpolant)

I ν and dµ solve (1) and (2)

I Markets clear (some joint requirement on h, µ, P, denoted as Φ(h, µ, P) = 0)

This can be solved for efficiently

I dµ is vector corresponding to the unit-eigenvalue of ΠhI Using fast solution techniques for the DP, e.g. EGM

I Using a root-finder to solve for P

Page 17: Solving and Estimating Heterogeneous Agent Models with

14/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Equilibrium

I Market clearing depends on the specific model

I In an Aiyagari model, we require that

r + δ = FK(K, L), w = FL(K, L)

where in the most simple case aggregate labor supply is exogenously given. Then, pricesare only a function of K and the equilibrium condition is simply

KS(P(K)) = K

I In a Huggett model, aggregate bond supply is zero and

KS(r) = 0

is the equilibrium condition.

Page 18: Solving and Estimating Heterogeneous Agent Models with

14/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Equilibrium

I Market clearing depends on the specific model

I In an Aiyagari model, we require that

r + δ = FK(K, L), w = FL(K, L)

where in the most simple case aggregate labor supply is exogenously given. Then, pricesare only a function of K and the equilibrium condition is simply

KS(P(K)) = K

I In a Huggett model, aggregate bond supply is zero and

KS(r) = 0

is the equilibrium condition.

Page 19: Solving and Estimating Heterogeneous Agent Models with

14/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Equilibrium

I Market clearing depends on the specific model

I In an Aiyagari model, we require that

r + δ = FK(K, L), w = FL(K, L)

where in the most simple case aggregate labor supply is exogenously given. Then, pricesare only a function of K and the equilibrium condition is simply

KS(P(K)) = K

I In a Huggett model, aggregate bond supply is zero and

KS(r) = 0

is the equilibrium condition.

Page 20: Solving and Estimating Heterogeneous Agent Models with

15/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Computer Exercise 1Aiyagari model

ExerciseSolve the Aiyagari model as spelled out in Bayer and Luetticke (2020). The productionfunction is

F (K, N) = KαN1−α,

where N = ni is common across households (GHH preferences)

Solve the steady state using the EGM and Young’s method.

Page 21: Solving and Estimating Heterogeneous Agent Models with

16/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Excursus: Endogenous Grid Method

I Most solution methods involve root-finding.

I This is numerically intense.

I Carroll (2006) proposes a method to solve dynamic optimization problems without relyingon root-solving.

I This method makes the grid and not the policy “endogenous”.

Page 22: Solving and Estimating Heterogeneous Agent Models with

16/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Excursus: Endogenous Grid Method

I Most solution methods involve root-finding.

I This is numerically intense.

I Carroll (2006) proposes a method to solve dynamic optimization problems without relyingon root-solving.

I This method makes the grid and not the policy “endogenous”.

Page 23: Solving and Estimating Heterogeneous Agent Models with

16/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Excursus: Endogenous Grid Method

I Most solution methods involve root-finding.

I This is numerically intense.

I Carroll (2006) proposes a method to solve dynamic optimization problems without relyingon root-solving.

I This method makes the grid and not the policy “endogenous”.

Page 24: Solving and Estimating Heterogeneous Agent Models with

16/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Excursus: Endogenous Grid Method

I Most solution methods involve root-finding.

I This is numerically intense.

I Carroll (2006) proposes a method to solve dynamic optimization problems without relyingon root-solving.

I This method makes the grid and not the policy “endogenous”.

Page 25: Solving and Estimating Heterogeneous Agent Models with

17/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I The idea is akin to forward induction: “Given the state I am in now, what must have beenthe state I was in before, if I behaved rational”.

I The method deals with occasionally binding constraints, but requires

I differentiability of the value function everywhere,I (in its basic form) first order conditions that are sufficient, andI monotone policy function (isomorphisms)

Page 26: Solving and Estimating Heterogeneous Agent Models with

17/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I The idea is akin to forward induction: “Given the state I am in now, what must have beenthe state I was in before, if I behaved rational”.

I The method deals with occasionally binding constraints, but requires

I differentiability of the value function everywhere,I (in its basic form) first order conditions that are sufficient, andI monotone policy function (isomorphisms)

Page 27: Solving and Estimating Heterogeneous Agent Models with

17/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I The idea is akin to forward induction: “Given the state I am in now, what must have beenthe state I was in before, if I behaved rational”.

I The method deals with occasionally binding constraints, but requiresI differentiability of the value function everywhere,

I (in its basic form) first order conditions that are sufficient, andI monotone policy function (isomorphisms)

Page 28: Solving and Estimating Heterogeneous Agent Models with

17/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I The idea is akin to forward induction: “Given the state I am in now, what must have beenthe state I was in before, if I behaved rational”.

I The method deals with occasionally binding constraints, but requiresI differentiability of the value function everywhere,I (in its basic form) first order conditions that are sufficient, and

I monotone policy function (isomorphisms)

Page 29: Solving and Estimating Heterogeneous Agent Models with

17/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I The idea is akin to forward induction: “Given the state I am in now, what must have beenthe state I was in before, if I behaved rational”.

I The method deals with occasionally binding constraints, but requiresI differentiability of the value function everywhere,I (in its basic form) first order conditions that are sufficient, andI monotone policy function (isomorphisms)

Page 30: Solving and Estimating Heterogeneous Agent Models with

18/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I Consider the dynamic programming problem

V (s, ξ) = maxs′≥b

u((1 + r)s− s′ + ξ

)+ βEV

(s′, ξ ′

).

I The first-order condition

u′((1 + r)s− s′ + ξ

)= (1 + r)βEu′((1 + r)s′ − s′′ + ξ ′) + λ (3)

characterizes the optimal solution. Where λ = 0 if s′ > b

Page 31: Solving and Estimating Heterogeneous Agent Models with

18/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I Consider the dynamic programming problem

V (s, ξ) = maxs′≥b

u((1 + r)s− s′ + ξ

)+ βEV

(s′, ξ ′

).

I The first-order condition

u′((1 + r)s− s′ + ξ

)= (1 + r)βEu′((1 + r)s′ − s′′ + ξ ′) + λ (3)

characterizes the optimal solution. Where λ = 0 if s′ > b

Page 32: Solving and Estimating Heterogeneous Agent Models with

19/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

The algorithm works iteratively and solves for the policy function directly:

1. Start with a policy guess (for simplicity for consumption).

2. Thereby, obtain values for the RHS of (3) for each grid point.

3. Then solve for the current state s such that (3) holds for each s′.4. This yields a set of inner solution pairs {s′, (s, ξ)} to be inverted.

5. It also identifies the current states s for which the constraint binds.

6. Go back to 2. and iterate until convergence.

Page 33: Solving and Estimating Heterogeneous Agent Models with

19/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

The algorithm works iteratively and solves for the policy function directly:

1. Start with a policy guess (for simplicity for consumption).

2. Thereby, obtain values for the RHS of (3) for each grid point.

3. Then solve for the current state s such that (3) holds for each s′.4. This yields a set of inner solution pairs {s′, (s, ξ)} to be inverted.

5. It also identifies the current states s for which the constraint binds.

6. Go back to 2. and iterate until convergence.

Page 34: Solving and Estimating Heterogeneous Agent Models with

19/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

The algorithm works iteratively and solves for the policy function directly:

1. Start with a policy guess (for simplicity for consumption).

2. Thereby, obtain values for the RHS of (3) for each grid point.

3. Then solve for the current state s such that (3) holds for each s′.

4. This yields a set of inner solution pairs {s′, (s, ξ)} to be inverted.

5. It also identifies the current states s for which the constraint binds.

6. Go back to 2. and iterate until convergence.

Page 35: Solving and Estimating Heterogeneous Agent Models with

19/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

The algorithm works iteratively and solves for the policy function directly:

1. Start with a policy guess (for simplicity for consumption).

2. Thereby, obtain values for the RHS of (3) for each grid point.

3. Then solve for the current state s such that (3) holds for each s′.4. This yields a set of inner solution pairs {s′, (s, ξ)} to be inverted.

5. It also identifies the current states s for which the constraint binds.

6. Go back to 2. and iterate until convergence.

Page 36: Solving and Estimating Heterogeneous Agent Models with

19/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

The algorithm works iteratively and solves for the policy function directly:

1. Start with a policy guess (for simplicity for consumption).

2. Thereby, obtain values for the RHS of (3) for each grid point.

3. Then solve for the current state s such that (3) holds for each s′.4. This yields a set of inner solution pairs {s′, (s, ξ)} to be inverted.

5. It also identifies the current states s for which the constraint binds.

6. Go back to 2. and iterate until convergence.

Page 37: Solving and Estimating Heterogeneous Agent Models with

19/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

The algorithm works iteratively and solves for the policy function directly:

1. Start with a policy guess (for simplicity for consumption).

2. Thereby, obtain values for the RHS of (3) for each grid point.

3. Then solve for the current state s such that (3) holds for each s′.4. This yields a set of inner solution pairs {s′, (s, ξ)} to be inverted.

5. It also identifies the current states s for which the constraint binds.

6. Go back to 2. and iterate until convergence.

Page 38: Solving and Estimating Heterogeneous Agent Models with

20/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I Say c(n) is the policy function in iteration n. Then, we can be calculate the necessaryassets s as

(1 + r)s∗(s′, ξ) = s′ − ξ + c∗(s′, ξ)

c∗(s′, ξ) = u′−1{(1 + r)βEξu′

[c(n)(s′, ξ ′)

]}

I For a given grid of points s′, s∗ is typically off-grid!

I However, we have solved a policy function for some asset levels:

(s∗, ξ)→ c∗(s′, ξ)

Page 39: Solving and Estimating Heterogeneous Agent Models with

20/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I Say c(n) is the policy function in iteration n. Then, we can be calculate the necessaryassets s as

(1 + r)s∗(s′, ξ) = s′ − ξ + c∗(s′, ξ)

c∗(s′, ξ) = u′−1{(1 + r)βEξu′

[c(n)(s′, ξ ′)

]}I For a given grid of points s′, s∗ is typically off-grid!

I However, we have solved a policy function for some asset levels:

(s∗, ξ)→ c∗(s′, ξ)

Page 40: Solving and Estimating Heterogeneous Agent Models with

20/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Endogenous Grid Method

I Say c(n) is the policy function in iteration n. Then, we can be calculate the necessaryassets s as

(1 + r)s∗(s′, ξ) = s′ − ξ + c∗(s′, ξ)

c∗(s′, ξ) = u′−1{(1 + r)βEξu′

[c(n)(s′, ξ ′)

]}I For a given grid of points s′, s∗ is typically off-grid!

I However, we have solved a policy function for some asset levels:

(s∗, ξ)→ c∗(s′, ξ)

Page 41: Solving and Estimating Heterogeneous Agent Models with

21/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Policy functions on a fixed grid

I For well behaved felicity functions u, s∗ and c∗ are monotone in s′. This allows us to moveto the next iteration making use of the following two implications:

I For a given ξ we can obtain consumption policies c(n+1)(s, ξ) by interpolating c∗ ats∗(s′1 = b, ξ) ≤ s ≤ s∗(s′n, ξ).

I For any s < s∗(s′1, ξ) households would like to choose assets lower than the borrowing limit.Of course they cannot. Hence, we know their asset policy: s′(s, ξ) = b and their

consumption is c(n+1)(s, ξ) = (1 + r)s + ξ − b.

I We then iterate c(n) until convergence.

Page 42: Solving and Estimating Heterogeneous Agent Models with

21/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Policy functions on a fixed grid

I For well behaved felicity functions u, s∗ and c∗ are monotone in s′. This allows us to moveto the next iteration making use of the following two implications:I For a given ξ we can obtain consumption policies c(n+1)(s, ξ) by interpolating c∗ at

s∗(s′1 = b, ξ) ≤ s ≤ s∗(s′n, ξ).

I For any s < s∗(s′1, ξ) households would like to choose assets lower than the borrowing limit.Of course they cannot. Hence, we know their asset policy: s′(s, ξ) = b and their

consumption is c(n+1)(s, ξ) = (1 + r)s + ξ − b.

I We then iterate c(n) until convergence.

Page 43: Solving and Estimating Heterogeneous Agent Models with

21/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Policy functions on a fixed grid

I For well behaved felicity functions u, s∗ and c∗ are monotone in s′. This allows us to moveto the next iteration making use of the following two implications:I For a given ξ we can obtain consumption policies c(n+1)(s, ξ) by interpolating c∗ at

s∗(s′1 = b, ξ) ≤ s ≤ s∗(s′n, ξ).I For any s < s∗(s′1, ξ) households would like to choose assets lower than the borrowing limit.

Of course they cannot. Hence, we know their asset policy: s′(s, ξ) = b and their

consumption is c(n+1)(s, ξ) = (1 + r)s + ξ − b.

I We then iterate c(n) until convergence.

Page 44: Solving and Estimating Heterogeneous Agent Models with

21/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

Policy functions on a fixed grid

I For well behaved felicity functions u, s∗ and c∗ are monotone in s′. This allows us to moveto the next iteration making use of the following two implications:I For a given ξ we can obtain consumption policies c(n+1)(s, ξ) by interpolating c∗ at

s∗(s′1 = b, ξ) ≤ s ≤ s∗(s′n, ξ).I For any s < s∗(s′1, ξ) households would like to choose assets lower than the borrowing limit.

Of course they cannot. Hence, we know their asset policy: s′(s, ξ) = b and their

consumption is c(n+1)(s, ξ) = (1 + r)s + ξ − b.

I We then iterate c(n) until convergence.

Page 45: Solving and Estimating Heterogeneous Agent Models with

22/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

EGM: Further issues

I One important issue is how to choose starting guesses for c(0). Here it is useful to recallthat the infite horizon planning problem can be viewed as the limit of a finite horizonproblem. Hence start with c(0) = (1 + r)s + ξ (if possible).

I There are extensions on

I How to deal with multiple assets (Hintermaier and Koeniger, 2010): Find the assetcombinations in t + 1 that can be optimal using FOCs, then map back from only theseoptimal points.

I How to deal with non-convex setups (Fella, 2015): Use the fact that FOCs are stillnecessary and compare potential solutions.

Page 46: Solving and Estimating Heterogeneous Agent Models with

22/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

EGM: Further issues

I One important issue is how to choose starting guesses for c(0). Here it is useful to recallthat the infite horizon planning problem can be viewed as the limit of a finite horizonproblem. Hence start with c(0) = (1 + r)s + ξ (if possible).

I There are extensions on

I How to deal with multiple assets (Hintermaier and Koeniger, 2010): Find the assetcombinations in t + 1 that can be optimal using FOCs, then map back from only theseoptimal points.

I How to deal with non-convex setups (Fella, 2015): Use the fact that FOCs are stillnecessary and compare potential solutions.

Page 47: Solving and Estimating Heterogeneous Agent Models with

22/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

EGM: Further issues

I One important issue is how to choose starting guesses for c(0). Here it is useful to recallthat the infite horizon planning problem can be viewed as the limit of a finite horizonproblem. Hence start with c(0) = (1 + r)s + ξ (if possible).

I There are extensions onI How to deal with multiple assets (Hintermaier and Koeniger, 2010): Find the asset

combinations in t + 1 that can be optimal using FOCs, then map back from only theseoptimal points.

I How to deal with non-convex setups (Fella, 2015): Use the fact that FOCs are stillnecessary and compare potential solutions.

Page 48: Solving and Estimating Heterogeneous Agent Models with

22/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Endogenous Grid Method

EGM: Further issues

I One important issue is how to choose starting guesses for c(0). Here it is useful to recallthat the infite horizon planning problem can be viewed as the limit of a finite horizonproblem. Hence start with c(0) = (1 + r)s + ξ (if possible).

I There are extensions onI How to deal with multiple assets (Hintermaier and Koeniger, 2010): Find the asset

combinations in t + 1 that can be optimal using FOCs, then map back from only theseoptimal points.

I How to deal with non-convex setups (Fella, 2015): Use the fact that FOCs are stillnecessary and compare potential solutions.

Page 49: Solving and Estimating Heterogeneous Agent Models with

23/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Policy functions as Markov Chains

Excursus: Policy functions inducing a Markov chain (Young’s method)

Suppose we have solved a dynamic programming problem

V(s, ξ) = maxs′

u(s, s′) + βEξ ′V(s′, ξ ′)

at nodes (s, ξ) ∈ S× Ξ by linearly interpolating V off nodes, where S and Ξ are indexed setsS = {s1, . . . , sn}, Ξ = {ξi, . . . , ξm}.

(For exposition we assume that S is one dimensional, but everything extends to higherdimensional S.)

Page 50: Solving and Estimating Heterogeneous Agent Models with

24/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Policy functions as Markov Chains

Policy functions and indexes

Then, we have obtained a policy function

s∗(s, ξ) = arg maxs′

u(s, s′) + βEξ ′V(s′, ξ ′).

Now let i∗(s, ξ) be the index of the next smallest element in S relative to s∗, i.e. s∗ ∈ [si, si+1).

Page 51: Solving and Estimating Heterogeneous Agent Models with

25/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Policy functions as Markov Chains

Policy functions: Linear interpolation weights

Define weights w(s, ξ) = s∗−si∗si∗+1−si∗

.

I then the linearly interpolated value function is given by

V(s, ξ) = u [s, s∗(s, ξ)] + [1−w(s, ξ)]EξV(si∗ , ξ ′) + w(s, ξ)EξV(si∗+1, ξ ′)

I Observe that V′ is now only on grid in the s dimension!

Page 52: Solving and Estimating Heterogeneous Agent Models with

26/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Policy functions as Markov Chains

Policy functions: Linear interpolation weights

Now assume the evolution of ξ is given by a discrete Markov chain.

I then the linearly interpolated value function is given by

V(si, ξj) = u[sh, s∗(si, ξj)

](4)

+ ∑j′

pjj′{ [

1−w(si, ξj)]

V(si∗ , ξj′) + w(si, ξj)V(si∗+1, ξj′)}

I Observe that V′ fully on grid!

Page 53: Solving and Estimating Heterogeneous Agent Models with

27/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Policy functions as Markov Chains

Policy functions: Linear interpolation weights

Moreover, we can reinterpret the weights

I Define

γ(i,j)→(i′ ,j′) =

pjj′[1−w(si, ξj)

]if i′ = i∗(i, j)

pjj′w(si, ξj) if i′ = i∗(i, j) + 10 else

(5)

I Then Γ :=[γ(i,j)→(i′ ,j′)

](i′ ,j′)(i,j)

is a stochastic (transition) matrix

I of a DMC on the vectorized state space.

Page 54: Solving and Estimating Heterogeneous Agent Models with

28/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

SIM

Policy functions as Markov Chains

Policy functions: Transition probability matrix

Why is this useful?

I We can reinterpret the linear interpolant:The decision maker chooses only (fair) lotteries over on-grid points.

Vt = maxs′

u(s, s′) + βΓs′Vt+1

I This we can use to obtain the ergodic distribution of states the planning problem induceswithout simulation and therefore fast.

I If an ergodic distribution exists, it is given by the left unit eigenvector of

Γ = [γ(i, j)]j=1...Ni=1...N, as

µt+1 = µtΓ.

Page 55: Solving and Estimating Heterogeneous Agent Models with

29/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Introducing aggregate risk

Introducing aggregate risk

With aggregate risk

I Prices and distributions change over time

Yet, for the household

I Only prices and continuation values matter

I Distributions do not influence the decisions directly

Page 56: Solving and Estimating Heterogeneous Agent Models with

30/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Introducing aggregate risk

Redefining equilibrium (Reiter, 2002)

A sequential equilibrium with recursive individual planning

I A sequence of discretized Bellman equation, such that

νt = uPt + βΠht νt+1 (6)

holds for optimal policy, ht (which results from νt+1 and Pt)

I and a sequence of histograms, such that

dµt+1 = dµtΠht (7)

holds given the optimal policy

I (Policy functions, ht, that are optimal given Pt, νt+1)

I Prices, distributions and policies lead to market clearing

Page 57: Solving and Estimating Heterogeneous Agent Models with

31/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Introducing aggregate risk

Compact notation (Schmitt-Grohe and Uribe, 2004)The equilibrium conditions as a non-linear difference equation

I Controls: Yt =[νt Pt ZY

t]

and

I States: Xt =[µt St ZX

t]

where Zt are purely aggregate states/controls

I Define

F (dµt, St, dµt+1, St+1, νt, Pt, νt+1, Pt+1, εt+1) (8)

=

dµt+1 − dµtΠht

νt −(uht + βΠht νt+1

)St+1 −H(St, dµt, εt+1)

Φ(ht, dµt, Pt, St)εt+1

s.t.

ht(s) = arg maxx∈Γ(s,Pt)

u(s, x) + βEνt+1(s′) (9)

Page 58: Solving and Estimating Heterogeneous Agent Models with

32/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Introducing aggregate risk

Compact notation (Schmitt-Grohe and Uribe, 2004)

In words

I First set of equations: Difference of one forward iteration of the distribution to assumedvalue.

I Second set of equations: Difference of one backward iteration of the value function (orpolicy functions in EGM) to assumed value.

I Last two sets of equations: Macro model.

Page 59: Solving and Estimating Heterogeneous Agent Models with

33/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Introducing aggregate risk

Compact notation (Schmitt-Grohe and Uribe, 2004)

The equilibrium conditions as a non-linear difference equation

I Function-valued difference equation EF(Xt, Xt+1, Yt, Yt+1, εt+1) = 0I turns real-valued when we replace the functions by their discretized counterparts

I Standard techniques to solve by perturbation (Dynare etc)

Page 60: Solving and Estimating Heterogeneous Agent Models with

34/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Perturbation References: General

I General:1. A First Look at Perturbation Theory by James G. Simmonds and James E. Mann Jr.2. Advanced Mathematical Methods for Scientists and Engineers: Asymptotic Methodsand Perturbation Theory by Carl M. Bender, Steven A. Orszag.

I This lecture:1. “Perturbation Methods for General Dynamic Stochastic Models” by Hehui Jin andKenneth Judd.2. “Computational Methods for Economists” by Jesus Fernandez-Villaverde.3. “Solving Dynamic General Equilibrium Models Using a Second-Order Approximation tothe Policy Function” by Martin Uribe and Stephanie Schmitt-Grohe.

Page 61: Solving and Estimating Heterogeneous Agent Models with

35/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Non-linear difference equation

I A large class of economic models can be written as a set of non-linear difference equationsof the form

Etf (st+1, st, ct+1, ct) = 0

where s are all state and c are all control variables now.

Page 62: Solving and Estimating Heterogeneous Agent Models with

36/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Perturbation methods

I More generally, functional equations of the form:

H(d) = 0

for an unknown decision rule d.

I Perturbation solves the problem by specifying:

dn(x, θ) =n

∑i=0

θi(x− x0)i

I We use implicit-function theorems to find coefficients θi’s

I Inherently local approximation.

Page 63: Solving and Estimating Heterogeneous Agent Models with

37/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Motivation

I Many complicated mathematical problems have:I either a particular caseI or a related problem

that is easy to solve.

I Often, we can use the solution of the simpler problem as a building block of the generalsolution.

I Sometimes perturbation is known as asymptotic methods.

Page 64: Solving and Estimating Heterogeneous Agent Models with

38/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

A simple example

I Imagine we want to compute√

26 by hand

I Note that: √26 =

√25 ∗ 1.04 = 5 ∗

√25 ∗ 1.04 ≈ 5 ∗ 1.02 = 5.1

I Exact solution:√

26 = 5.09902I More generally:

√x =

√y2 ∗ (1 + ε) = y ∗

√(1 + ε) ≈ y ∗ (1 + ε)

I Accuracy depends on how big ε is

Page 65: Solving and Estimating Heterogeneous Agent Models with

39/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Applications in economics

I Judd and Guu (1993) showed how to apply it to economic problems

I Recently, perturbation methods have been gaining much popularity

I In particular, second- and third-order approximations are easy to compute and notablyimprove accuracy

I Perturbation theory is the generalization of the well-known linearization strategy

I Hence, we can use much of what we already know about linearization

Page 66: Solving and Estimating Heterogeneous Agent Models with

40/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Regular versus singular perturbations

I Regular perturbation: a small change in the problem induces a small change in thesolution.

I Singular perturbation: a small change in the problem induces a large change in thesolution.

I Example: excess demand function.

I Most problems in economics involve regular perturbations.

I Sometimes, however, we can have singularities.Example: introducing a new asset in an incomplete market model.

Page 67: Solving and Estimating Heterogeneous Agent Models with

41/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Perturbation methods

I Back to our economic model cast in the following form:

Etf (st+1, st, ct+1, ct) = 0

where s are state and c are control variables.

I Rewrite f introducing a parameter for uncertainty :

Etf (st+1, st, ct+1, ct; σ) = 0

.

Page 68: Solving and Estimating Heterogeneous Agent Models with

42/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Evolution of states

I Dynamic stochastic general equilibrium models in addition have a structure where a subsetof state variables s1

t are predetermined and endogenous while the remainder areexogenously driven as

s2t+1 = H2(s2

t , σ) + σΣεt+1

where εt+1 are i.i.d. with zero mean, unit covariance and bounded support.

I Stacking all state variables, we can write

st+1 = [H1(st, σ); H2(st, σ)] + σηεt+1

I with η = [0; Σ]

Page 69: Solving and Estimating Heterogeneous Agent Models with

43/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Evolution of controls

I That ct is a control means that there is a function ct = G(st, σ)

I The goal is to solve for the unknown H1 and G.

Page 70: Solving and Estimating Heterogeneous Agent Models with

44/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local approximation

I Take a Taylor series approximation of G and H:

G(s, σ) = G(s∗, σ∗) + Gs(s∗, σ∗)(s− s∗) + Gσ(s∗, σ∗)(σ− σ∗)

+ 1/2Gss(s∗, σ∗)(s− s∗)2 + Gsσ(s∗, σ∗)(s− s∗)(σ− σ∗)

+ 1/2Gσσ(s∗, σ∗)(σ− σ∗)2 + ...

H(s, σ) = H(s∗, σ∗) + Hs(s∗, σ∗)(s− s∗) + Hσ(s∗, σ∗)(σ− σ∗)

+ 1/2Hss(s∗, σ∗)(s− s∗)2 + Hsσ(s∗, σ∗)(s− s∗)(σ− σ∗)

+ 1/2Hσσ(s∗, σ∗)(σ− σ∗)2 + ...

Page 71: Solving and Estimating Heterogeneous Agent Models with

45/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local approximation

I Replace s and c in F:

F(s, σ) ≡ Etf (H(st, σ) + σηεt+1, st, G[H(st, σ) + σηεt+1, σ], G(st, σ))

= 0

I The goal is to solve for the unknown H1 and G.

I Local approximation means that we solve for H1, G by taking a Taylor expansion of Faround the non-stochastic steady state s∗, for which σ∗ = 0.

Page 72: Solving and Estimating Heterogeneous Agent Models with

46/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local approximation

I Define non-stochastic steady state as vectors (s∗, c∗) :

f (s∗, s∗, c∗, c∗) = 0

I c∗ = G(s∗, 0) and s∗ = H(s∗, 0)

I Note that if σ = 0, then Etf = f

Page 73: Solving and Estimating Heterogeneous Agent Models with

47/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local approximation

I Approximation of G and H around the point (s, σ) = (s∗, 0)

G(s, 0) = G(s∗, 0) + Gs(s∗, 0)(s− s∗) + Gσ(s∗, 0)σH(s, 0) = H(s∗, 0) + Hs(s∗, 0)(s− s∗) + Hσ(s∗, 0)σ

I G(s∗, 0), H(s∗, 0) identified by steady state values

I Remaining coefficients are identified by:

Fs(s∗, 0) = 0Fσ(s∗, 0) = 0

Page 74: Solving and Estimating Heterogeneous Agent Models with

48/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local approximation

I Take derivative of F w.r.t. uncertainty :

Fσ(s∗, 0) = Etfs′(Hσ + ηε′) + fc′ [Gs(Hσ + ηε′) + Gσ] + fcGσ

= fs′Hσ + fc′ [GsHσ + Gσ] + fcGσ

= 0

I This is a system of n equations:

(fs′ + fc′Gs fc′ + fc

) (Hσ

)= 0

I This equation is linear and homogeneous in Hσ, Gσ. Thus we have that Hσ = 0 andGσ = 0.

Page 75: Solving and Estimating Heterogeneous Agent Models with

49/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local approximation

Important theoretical result:

I In words, up to first order, we do not need to adjust the steady state solution whenchanging aggregate risk σ.

I Expected values of st and ct are equal to their non-stochastic steady-state values.

I In a first order approximation the certainty equivalence principle holds, i.e., the policyfunction is independent of the variance-covariance matrix of ε.

I Interpretation: no precautionary behavior.

Page 76: Solving and Estimating Heterogeneous Agent Models with

50/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local approximation

I Differentiation w.r.t s yields:

Fs(s∗, 0) = fs′Hs + fs + fc′GsHs + fcGs = 0

I In matrix form: (fs′ fc′

) ( IGs

)Hs = −

(fs fc

) ( IGs

)

Page 77: Solving and Estimating Heterogeneous Agent Models with

51/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local approximation

I Let A = [fs′ fc′ ] and B = [fs fc]I Let st ≡ st − s∗, then postmultiply:

A(

IGs

)Hsst = −B

(I

Gs

)st

I Consider a perfect foresight equilibrium. In this case, Hsst = st+1

A(

IGs

)st+1 = −B

(I

Gs

)st

Page 78: Solving and Estimating Heterogeneous Agent Models with

52/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local approximation

I This leaves us with a system of quadratic equations that we need to solve for Hs, Gs.

I Procedures to solve rational expectations models:

1. Blanchard and Kahn (1980).2. Uhlig (1999).3. Sims (2000).4. Klein (2000).

Page 79: Solving and Estimating Heterogeneous Agent Models with

53/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local properties of the solution I

I Perturbation is a local method.

I It approximates the solution around the deterministic steady state of the problem.

I It is valid within a radius of convergence.

Page 80: Solving and Estimating Heterogeneous Agent Models with

54/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Local properties of the solution II

I What is the radius of convergence of a power series around x? An r ∈ R∞+ such that

∀x′, |x′ − z′| < r, the power series of x will converge.

I A Remarkable Result from Complex Analysis:The radius of convergence is always equal to the distance from the center to the nearestpoint where the decision rule has a (non-removable) singularity. If no such point existsthen the radius of convergence is infinite.

I Singularity here refers to poles, fractional powers, and other branch powers ordiscontinuities of the functional or its derivatives.

Page 81: Solving and Estimating Heterogeneous Agent Models with

55/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Solution

I Using an eigenvalue decomposition of Hs = PΛP−1 we obtain,

AZΛ = BZ Z = [I; Gs]PA = [∂Fs′ , ∂Fc′ ] B = −[Fs, Fc]

which implies that the solution corresponds to a subset of the solutions to the generalizedeigenvalue problem

AXD = BX

I But which?

I If we have a stable system, then limt→∞ Hts = 0. Therefore, we are searching for the

exactly ns eigenvalues smaller than unity.

Page 82: Solving and Estimating Heterogeneous Agent Models with

56/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Solution

I Splitting all solutions to the eigenvalue problem above and below eigenvalues of 1, weobtain

A[

X11 X21X12 X22

] [D1 00 D2

]= B

[X11 X21X12 X22

]and therefore

Hs = X11D1X−111

andGs = X12X−1

11

Page 83: Solving and Estimating Heterogeneous Agent Models with

57/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Alternative Solution: Time IterationI Rendahl (2018) extends linear time iteration

I Intuitive, robust, and easy to implement algorithm. Now x is vector of all controls andstates. Fn is transition matrix of states and controls.

I Rewrite difference equation in “end of last period” notation

Axt−1 + Bxt + Cxt+1 = 0

I Let Fn be a candidate solution:

Axt−1 + Bxt + CFnxt = 0

xt = −(B + CFn)−1Axt−1

I Thus update guess Fn+1 as

Fn+1 = −(B + CFn)−1A

Page 84: Solving and Estimating Heterogeneous Agent Models with

58/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Higher order approximations

I Obtaining higher-order approximations to the solution of the non-linear system is asequential procedure.

I The coefficients of the ith term of the jth-order approximation are given by the coefficientsof the ith term of the ith order approximation, for j > 1 and i < j.

I More importantly, obtaining the coefficients of the ith order terms of the approximatesolution given all lower-order coefficients involves solving a linear system of equations.

Page 85: Solving and Estimating Heterogeneous Agent Models with

59/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Notation: Tensors

I General trick from physics.

I An nth -rank tensor in a m-dimensional space is an operator that has n indices and mn

components and obeys certain transformation rules.

I [Fy]iα is the (i, α) element of the derivative of F with respect to y:

1. The derivative of F with respect to y is an n x ny matrix.

2. Thus, [Fy]iα is the element of this matrix located at the intersection of the i-th row and α-thcolumn.

3. Thus, [Fy]iα[Gx]αβ[Hx]βj = ∑

nyα=1 ∑nx

β=1∂Fi

∂yα∂Gα

∂xβ∂Hβ

∂xj

I [Fyy]iαγ

1. Fiyy is a three dimensional array with n rows, ny columns, and ny pages.

2. [Fyy]iαγ denotes the element at the intersection of row i, column α, and page γ

Page 86: Solving and Estimating Heterogeneous Agent Models with

60/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Second order approximation

I Derivatives of F(s, σ):

[Fss(s∗, 0)]ijk = 0

[Fσσ(s∗, 0)]i = 0

[Fsσ(s∗, 0)]ij = 0

Page 87: Solving and Estimating Heterogeneous Agent Models with

61/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Second order approximation

I Cross derivatives are equal to zero when evaluated at (s∗, 0):

[Fσs(s∗, 0)]ij =[Fs′ ]iβ[Hσs]

βj + [Fc′ ]

iα[Gs]

αβ[Hσs]

βj + [Fc′ ]

iα[Gσs]

αγ[Hs]

γj

+ [Fc]iα[Gσs]

αj = 0

I This is a system of n x ns equations in the n x ns unknowns given by the elements of Gσsand Hσs.

I The system is homogeneous in the unknowns. Thus, if a unique solution exists, it is givenby Gσs = 0 and Hσs = 0.

Page 88: Solving and Estimating Heterogeneous Agent Models with

62/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Second order approximation

Important theoretical result:

I The coefficients of the policy function on the terms that are linear in the state vector donot depend on the size of the variance of the underlying shocks

I Uncertainty only affects the constant term in the policy function

Page 89: Solving and Estimating Heterogeneous Agent Models with

63/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Second order approximationI Approximation of G and H around the point (s, σ) = (s∗, 0)

[G(s, σ)]i =[G(s∗, 0)]i + [Gs(s∗, 0)]ia[(s− s∗)]a

+12[Gss(s∗, 0)]iab[(s− s∗)]a[(s− s∗)]b

+12[Gσσ(s∗, 0)]i[σ2]

[H(s, σ)]j =[H(s∗, 0)]j + [Hs(s∗, 0)]ja[(s− s∗)]a

+12[Hss(s∗, 0)]jab[(s− s∗)]a[(s− s∗)]b

+12[Hσσ(s∗, 0)]j[σ2]

Page 90: Solving and Estimating Heterogeneous Agent Models with

64/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Second order approximation

I Approximation of G and H around the point (s, σ) = (s∗, 0) ctd

I The unknowns of this expansion are [Gss(s∗, 0)]i, [Gσσ(s∗, 0)]i, [Hss(s∗, 0)]j, and[Hσσ(s∗, 0)]j

I Derivatives of F(s, σ) yield as many equations as we have unknowns. Perfectly identifiedlinear system!

Page 91: Solving and Estimating Heterogeneous Agent Models with

65/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Second order approximation

I System of nxnsxns linear equations in the nxnsxns unknowns given by the elements of Gssand Hss.

Page 92: Solving and Estimating Heterogeneous Agent Models with

66/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Higher order approximations

I We can iterate this procedure as many times as we want.

I We can obtain n-th order approximations.

I Levintal (2017) uses tensor-unfolding to work with higher-order derivatives

I Problems:1. Existence of higher order derivatives.2. Numerical instabilities.3. Computational costs.

Page 93: Solving and Estimating Heterogeneous Agent Models with

67/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Example: Simple RBC

Page 94: Solving and Estimating Heterogeneous Agent Models with

68/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Stochastic neoclassical growth model

max E0

∑t=0

βt log ct

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

zt = ρzt−1 + σεt, ε ∼ N (0, 1)

I Note: full depreciation.

I Equilibrium conditions:

1ct

=βEt1

ct+1αezt+1kα−1

t+1

ct + kt+1 =ezt kαt

zt =ρzt−1 + σεt

Page 95: Solving and Estimating Heterogeneous Agent Models with

69/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Solution and steady state

I Exact solution (found by ”guess and verify”):

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

kt =(αβ)ezt kαt

I Steady state is also easy to find:

k =(αβ)1

1−α

c =(αβ)α

1−α − (αβ)1

1−α

z =0

Page 96: Solving and Estimating Heterogeneous Agent Models with

70/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

The goalI We are searching for decision rules:

ct =c(kt, zt)

kt+1 =k(kt, zt)

I Then we have:

1c(kt, zt)

=βEt1

c(k(kt, zt), zt+1)αezt+1k(kt, zt)

α−1

c(kt, zt) + k(kt, zt) =ezt kαt

zt =ρzt−1 + σεt

I This is a system of functional equations (after substituting zt)

Page 97: Solving and Estimating Heterogeneous Agent Models with

71/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

A perturbation solution

I Add perturbation parameter σI When σ = 0 deterministic case (with z0 = 0 and ezt = 1)I When σ > 0 stochastic case

I Now we are searching for decision rules:

ct =c(kt, zt; σ)

kt+1 =k(kt, zt; σ)

Page 98: Solving and Estimating Heterogeneous Agent Models with

72/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Taylor’s theorem

I We will build a local approximation around (k∗, 0; 0)I Given equilibrium conditions:

1c(kt, zt; σ)

= βEt1

c(k(kt, zt; σ), ρzt + σεt+1; σ)αeρzt+σεt+1k(kt, zt; σ)α−1

c(kt, zt; σ) + k(kt, zt; σ) = eρzt−1+σεt kαt

I Take derivatives w.r.t. kt, zt, σ and evaluate them around (k∗, 0; 0)

Page 99: Solving and Estimating Heterogeneous Agent Models with

73/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Compact Notation

F(kt, zt, σ) = Et

(1

c(kt,zt;σ)− βEt

αeρzt+σεt+1 k(kt,zt;σ)α−1

c(k(kt,zt;σ),ρzt+σεt+1;σ)c(kt, zt; σ) + k(kt, zt; σ)− eρzt−1+σεtkα

t

)=

(00

)I Note that:

F(kt, zt, σ) = H(ct, ct+1, kt, kt+1, zt; σ)

= H(c(kt, zt; σ), c(k(kt, zt; σ), zt; σ), kt, k(kt, zt; σ), zt; σ)

I Because F(kt, zt, σ) must be equal to zero for any possible values of k , z , and σ, thederivatives of any order of F must also be zero.

Page 100: Solving and Estimating Heterogeneous Agent Models with

74/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

First-order approximation

I Take first-order derivatives of F(kt, zt, σ) around (k∗, 0; 0)

Fk(k, 0; 0) = 0Fz(k, 0; 0) = 0Fσ(k, 0; 0) = 0

Page 101: Solving and Estimating Heterogeneous Agent Models with

75/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Second-order approximationI Take second-order derivatives of F(kt, zt, σ) around (k∗, 0; 0)

Fkk(k, 0; 0) = 0Fkz(k, 0; 0) = 0Fkσ(k, 0; 0) = 0Fzz(k, 0; 0) = 0Fzσ(k, 0; 0) = 0Fσσ(k, 0; 0) = 0

I We substitute the coefficients that we already know.

I A linear system of 12 equations on 12 unknowns.

I Cross-terms on kσ and zσ are zero.

I More general result: all the terms in odd derivatives of σ are zero.

Page 102: Solving and Estimating Heterogeneous Agent Models with

76/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Correction for risk

I We have the term 1/2cσσ(k, 0; 0)

I Captures precautionary behavior.

I We do not have certainty equivalence any more!

I Important advantage of second order approximation.

I Changes ergodic distribution of states.

Page 103: Solving and Estimating Heterogeneous Agent Models with

77/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Higher-order terms

I We can continue the iteration for as long as we want.

I Great advantage of procedure: it is recursive!

I Often, a few iterations will be enough.

I The level of accuracy depends on the goal of the exercise: e.g. Welfare analysis: Kim andKim (2001).

Page 104: Solving and Estimating Heterogeneous Agent Models with

78/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Computer Exercise 2

ExerciseSolve the simple stochastic growth model using perturbation methods. For this purpose, firstwrite a function that calculates the Euler equation errors, errors from capital accumulation, andthe law of motion for productivity. Define consumption as control and capital and productivityas states. Compare the first and second order perturbation of c(k, z, σ) to the true solution.

Page 105: Solving and Estimating Heterogeneous Agent Models with

79/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Excursus: Automatic differentiation

I Modern computer languages like Julia offer easy to implement automatic differentiationlibraries.

I Automatic differentiation is neither:I Symbolic differentiation

I Inefficient codeI nor Numerical differentiation (the method of finite differences)

I If you make h too small, then your accuracy gets killed by floating point roundoffI If h is too big, then approximation errors start ballooning

I AD avoids these problems: it calculates exact derivatives, so your accuracy is only limitedby floating point error.

Page 106: Solving and Estimating Heterogeneous Agent Models with

80/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Excursus: Automatic differentiationI AD applies the chain rule to your functionI Any complicated function f can be rewritten as the composition of a sequence of primitive

functionsI Let f (x, y) = cos x sin y + x

y

Page 107: Solving and Estimating Heterogeneous Agent Models with

81/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Excursus: Automatic differentiation

Df = Dw7 = D(w5 + w6) = Dw5 + Dw6

Dw6 = Dw1w2

=w1Dw2 −w2Dw1

w22

Dw5 = Dw3w4 = w3Dw4 + w4Dw3

Dw4 = D sin w2 = cos w2 ·Dw2

Dw3 = D cos w1 = − sin w1 ·Dw1

Dw2 = DyDw1 = Dx

Page 108: Solving and Estimating Heterogeneous Agent Models with

82/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Excursus: Automatic differentiation

I AD is implemented by a nonstandard interpretation of the program in which real numbersare replaced by dual numbers and the numeric primitives are lifted to operate on dualnumbers.

I Dual numbers: Replace every number x with the number x + x′ε, where x′ is a realnumber, but ε is an abstract number with the property ε2 = 0

I Julia does this for you!

I ForwardDiff Package: www.juliadiff.org/

I Examples: www.juliadiff.org/ForwardDiff.jl/stable/user/advanced.html

Page 109: Solving and Estimating Heterogeneous Agent Models with

83/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Excursus: Julia

I Julia combines three key features for highly intensive computing tasks as perhaps no othercontemporary programming language does: it is fast, easy to learn and use, and opensource.

I Introduction by Fernandez-VillaVerde:www.sas.upenn.edu/~jesusfv/Chapter_HPC_8_Julia.pdf

I Introduction by QuantEcon:https://lectures.quantecon.org/jl/

Page 110: Solving and Estimating Heterogeneous Agent Models with

84/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

Back to heterogeneous agent modelThe equilibrium conditions as a non-linear difference equation

I Controls: Yt =[νt Pt ZY

t]

and

I States: Xt =[µt St ZX

t]

where Zt are purely aggregate states/controls

I Define

F (dµt, St, dµt+1, St+1, νt, Pt, νt+1, Pt+1, εt+1) (10)

=

dµt+1 − dµtΠht

νt −(uht + βΠht νt+1

)St+1 −H(St, dµt, εt+1)

Φ(ht, dµt, Pt, St)εt+1

s.t.

ht(s) = arg maxx∈Γ(s,Pt)

u(s, x) + βEνt+1(s′) (11)

Page 111: Solving and Estimating Heterogeneous Agent Models with

85/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Perturbation

So, is all solved?

The dimensionality of the system F is still an issue

I With high dimensional idiosyncratic states, discretized value functions and distributionsbecome large objects

I For example:4 income states (grid points)× 100 illiquid asset states× 100 liquid asset states=⇒ ≥ 40, 000 control variables in F

I Same number of state variables

Page 112: Solving and Estimating Heterogeneous Agent Models with

86/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Our Reduction Method

Page 113: Solving and Estimating Heterogeneous Agent Models with

87/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Reiter (2009): Reduce dimensionality ex ante

Problem:

I Dimensionality of the difference equation is large

Proposal:

I Reduce dimensionality ex ante (before solving the StE)

I e.g. (sparse) splines to represent policy functions

I Then linearize

Winberry (2016) extends this to the distribution functions

Page 114: Solving and Estimating Heterogeneous Agent Models with

88/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

What we do

Proposal:

I Reduce dimensionality after StE, but before linearization

I Extract from the StE the important basis functions to represent individual policies (akin toimage compression)

I Perturb only those basis functions but use the StE as “reference frame” for the policies(akin to video compression)

I Similarly for distributions (details later)

Page 115: Solving and Estimating Heterogeneous Agent Models with

89/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Our idea

1.) Apply compression techniques as in video encoding

I Apply a discrete cosine transformation to all value/policy functions (Chebycheffpolynomials on roots grid)

I Define as reference “frame”: the StE value/policy function

I Write fluctuations as differences from this reference frame

I Assume all coefficients of the DCT from the StE close to zero do not change after shock

Page 116: Solving and Estimating Heterogeneous Agent Models with

90/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Our idea

2.) Transform joint-distribution µ into copula and marginals

I Calculate the Copula, Ξ of µ in the StE

I Perturb the marginal distributions

I Approximate changes in the Copula (via DCT) or use fixed Copula to calculate anapproximate joint distribution from marginals

I Idea follows Krusell and Smith (1998) in that some moments of the distribution do notmatter for aggregate dynamics

Page 117: Solving and Estimating Heterogeneous Agent Models with

91/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Copula

A distribution of probabilities

A Copula is a joint distribution function of univariate marginal probabilities for a multivariatestochastic variable. It maps [0, 1]n → [0, 1]

Sklar’s theorem

Every distribution function F can be represented by the marginal distribution functions Fi and aCopula, Ξ, with F(x1, . . . , xn) = Ξ [F1(x1), . . . , Fn(xn)].

Page 118: Solving and Estimating Heterogeneous Agent Models with

92/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Details

1.) Apply compression techniques as in video encoding

I DCT yields the coefficients of the fitted (multi-dimensional) Chebyshev polynomial, wherethe polynomial is constructed such that the tensor grid for s is mapped to the Chebyshevknots.See Ahmed et al. (1974) for the seminal contribution.

I Importantly, the absolute value of the coefficients has an interpretation in terms of the R2

contribution of the corresponding polynomial in fitting the data.

I This allows us to order and select the polynomial terms based on their importance.

Page 119: Solving and Estimating Heterogeneous Agent Models with

93/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Excursus: Global polynomial

I Express a function by the coefficients ψ of a polynomial

f (x) =n

∑j=1

ψjcj (x)

where ci (x) are known basis functions such as cj (x) = xj.I Better than ordinary polynomials are usually Chebyshev polynomials of which the baseline

functions arecj (x) = cos (j arccos x)

I These are orthogonal on [-1,1], i.e.∫ 1

−1ci(x)cj(x)

1√1− x2

dx = 0∀i 6= j

Page 120: Solving and Estimating Heterogeneous Agent Models with

94/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Excursus: Global polynomial

I Since the evaluation points xi are known (“grid”), we can computeC = [cj(xi)]i=1...M,j=1...n

I The vector of function values f = [f (xi)]i=1...M is then given by

f = Cψ

I Therefore, we can obtain an optimal (minimal MSE) as

ψ∗ = (C′C)−1C′ f

I The big advantage of polynomials is that they can be integrated analytically and thatthey are differentiable of any order.

Page 121: Solving and Estimating Heterogeneous Agent Models with

95/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Excursus: Global polynomial: issues

I Runge’s Phenomenon: Since polynomials tend to infinity as x→ ∞ it is not true thatthe overall fit of a global polynomial gets better, if more grid points and higher orderpolynomials are used (oscillating behavior).

I Choosing Chebyshev polynomials as basis functions and

I grid points as the roots xi = cos( 2i−12N ) for i = 1 . . . N of these polynomials minimizes

approximation error.

Page 122: Solving and Estimating Heterogeneous Agent Models with

96/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Excursus: Discrete Cosine Transforms

A first observation

I Suppose Chebychev root grid-points are not suitable for our problem.

I Then, we can write f (x) = f (g(y)) and

I generate the grid xi by applying g to the Chebyshev nodes yi,

I with basis functions cj (x) = cos(j arccos g−1(x)

)Discrete Cosine Transform (DCT) and lossy compression

I In particular, if we do not intend to evaluate off-grid, we do not need to know g but just

the nodes yi = cos(

2i−12N π

)and grid values xi

I and obtain an equivalent representation of fi in terms of coefficients.

I Shrinking ≈ 0-coefficients to 0 leaves fi close to unchanged.

I In addition C′C = I.

Page 123: Solving and Estimating Heterogeneous Agent Models with

97/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Details

1.) Apply compression techniques as in video encoding

I Let Θ = dct(ν) be the coefficients obtained from the DCT of the value function in StE

I A DCT expresses a finite sequence of data points in terms of sum of cosine functions atdifferent frequencies

I Linear, invertible function f = <N− > <N (equivalently: an invertible NxN matrix)

I xn is transformed to Xn according to:

Xk =N−1

∑n=0

xn cos [π/N(n + 1/2)k], k = 0, ..., N− 1

Page 124: Solving and Estimating Heterogeneous Agent Models with

98/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Details

1.) Apply compression techniques as in video encoding

I Define an index set I that contains the x percent largest (i.e. most important) elementsfrom Θ

I Let θ be a sparse vector with non-zero entries only for elements i ∈ I

I Define Θ(θt) =

{Θ(i) + θt(i) i ∈ IΘ(i) else

Page 125: Solving and Estimating Heterogeneous Agent Models with

99/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Details

Decoding

I Now we reconstruct νt = ν(θt) = idct(Θ(θt))

I This means that in the StE the reduction step adds no additional approximation error asν(0) = ν by construction

I Yet, it allows to reduce the number of derivatives that need to be calculated from theoutset

Page 126: Solving and Estimating Heterogeneous Agent Models with

100/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Details

2) Analogously for the distribution function

I Define µt as Ξt(µ1t , . . . , µn

t ) for n being the dimensionality of the idiosyncratic states

I The StE distribution is obtained when µ = Ξ(µ1, . . . , µn)

I We can treat the copula as an interpolant defined on the grid of steady-state marginaldistributions, and also approximate Ξt as a sparse expansion around the steady-statecopula Ξ.

I The most extreme variant of this is to treat the copula as time fixed.

Page 127: Solving and Estimating Heterogeneous Agent Models with

101/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Details

2) Analogously for the distribution function

I Typically prices are only influenced through the marginal distributions

I The approach ensures that changes in the mass of one dimension, say wealth, aredistributed in a sensible way across the other dimensions

I The implied distributions look “similar” to the StE one

Page 128: Solving and Estimating Heterogeneous Agent Models with

102/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Obtaining the copula function of the StE

To obtain an estimate of the Copula of the StE:

1. Accumulate the histogram along every dimension to obtain CDF estimate, M.

2. Add a leading zero to the CDF matrix, M, along every dimension.

3. Calculate marginal distributions, mi, from the CDF (summing out other dims)

4. Obtain the Copula estimate as an interpolant of M on {m1, . . . , mn}

Ξ = griddedInterpolant({m1, . . . , mn}, M)

.

Page 129: Solving and Estimating Heterogeneous Agent Models with

103/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Details

Too many equations

I The system

F({dµ1

t , . . . , dµnt }, St, {dµ1

t+1, . . . , dµnt+1}, St+1, (12)

θt, Pt, θt+1, Pt+1) =dΞ(µ1

t , . . . , µnt )− dΞ(µ1

t , . . . , µnt )Πht

dct[idct(Θ(θt))−

(uht + βΠht idct(Θ(θt+1))

)]St+1 −H(St, dµt)Φ(ht, dµt, Pt, St)

has too many equations

I Use only difference in marginals and the differences on I

Page 130: Solving and Estimating Heterogeneous Agent Models with

104/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Our reduction method

Quality of approximation

I David Childers (2018), ”Automated Solution of Heterogeneous Agent Models”:

I Under some regularity conditions the solution algorithm is guaranteed to converge to thefirst derivative of the true infinite dimensional solution as the discretization is refined.

I Convergence rates for the approximation are provided as well, depending on the choices ofinterpolation method including polynomials, splines, histograms, and wavelets.

Page 131: Solving and Estimating Heterogeneous Agent Models with

105/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Application: Krusell-Smith model

Page 132: Solving and Estimating Heterogeneous Agent Models with

106/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

A simple KS economy

Incomplete Markets and TFP

I Household productivity can be high or low

I No contingent claims

I Households save in capital goods (which they rent out)

I Households supply labor (disutility) and consume (utility)

I Aggregate productivity (TFP) follows a log AR-1 process

I Cobb-Douglas production function

Page 133: Solving and Estimating Heterogeneous Agent Models with

107/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

A simple KS economy

Numerical setup

I Asset grid has 100 points ( =⇒ a total grid size of 200)

I Policies solved by EGM (instead of VFI)

Page 134: Solving and Estimating Heterogeneous Agent Models with

108/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Different levels of “compression”Individual consumption policies

0 5 10 15 20 25 30 35Capital

0

0.5

1

1.5

Con

sum

ptio

n

Full grid, low incomeFull grid, high incomeApproximation, low incomeApproximation, high income

Figure: Policy and 10 most important basis functions

Page 135: Solving and Estimating Heterogeneous Agent Models with

108/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Different levels of “compression”Individual consumption policies

0 5 10 15 20 25 30 35Capital

0

0.5

1

1.5

Con

sum

ptio

n

Full grid, low incomeFull grid, high incomeApproximation, low incomeApproximation, high income

Figure: Policy and 50 most important basis functions

Page 136: Solving and Estimating Heterogeneous Agent Models with

109/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Different levels of “compression”Individual policy response to a 20%TFP shock

0 5 10 15 20 25 30 35Capital

0

0.5

1

1.5

Con

sum

ptio

n

Full grid, low incomeFull grid, high incomelow income, +20% TFP-Shockhigh income, +20% TFP-Shock

Figure: Perturbing 10 most important basis functions

Page 137: Solving and Estimating Heterogeneous Agent Models with

109/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Different levels of “compression”Individual policy response to a 20%TFP shock

0 5 10 15 20 25 30 35Capital

0

0.5

1

1.5

Con

sum

ptio

n

Full grid, low incomeFull grid, high incomelow income, +20% TFP-Shockhigh income, +20% TFP-Shock

Figure: Perturbing all 200 basis functions

Page 138: Solving and Estimating Heterogeneous Agent Models with

110/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Different levels of “compression”Aggregate response to a 20%TFP shock

0 10 20 30 40Quarter

-10

0

10

20

30

40

50

60

Per

cent

InvestmentCapitalOutputConsumption

Figure: Perturbing 10 most important basis functions

Page 139: Solving and Estimating Heterogeneous Agent Models with

110/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Different levels of “compression”Aggregate response to a 20%TFP shock

0 10 20 30 40Quarter

-10

0

10

20

30

40

50

60

Per

cent

InvestmentCapitalOutputConsumption

Figure: Perturbing all 200 basis functions

Page 140: Solving and Estimating Heterogeneous Agent Models with

111/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Taking stock

I When looking only at the StE policy function one concludes that roughly 50% of theinformation is needed to reconstruct the policies well

I This is roughly level of state reduction Reiter (2009) approach would achieve

I Using the StE as reference one can achieve much higher reduction

I For the aggregate dynamics maintaining only 3-6% of the basis functions suffices

Page 141: Solving and Estimating Heterogeneous Agent Models with

112/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Simulation performance

Figure: Simulations of Krusell & Smith model

(a) Simulation (b) Simulation close-up

0 200 400 600 800 1000Quarter

34.2

34.4

34.6

34.8

35

35.2

35.4

Cap

ital

Reiter-ReductionReiter-FullKrusell-Smith

0 20 40 60 80 100Quarter

0.985

0.99

0.995

1

1.005

1.01

Per

cent

dev

iatio

ns

Reiter-ReductionReiter-FullKrusell-Smith

Notes: Both panels show simulations of the Krusell & Smith (1998) model with TFP shockssolved with (1) the Reiter method with our proposed state-space reduction, (2) the originalReiter method without state-space reduction, (3) the original Krusell & Smith algorithm

Page 142: Solving and Estimating Heterogeneous Agent Models with

113/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Error Statistics

Table: Den Haan errors

Absolute error (in %) for capital Kt

Reiter-Reduction Reiter-Full K-S

Mean 0.0119 0.0119 0.1237Max 0.0152 0.0152 0.3491

Notes: Differences in percent between the simulation of the linearized solutionsof the model and simulations in which we solve for the intratemporal equilibriumprices in every period and track the full histogram over time for t = {1, ..., 1000};see Den Haan (2010)

Page 143: Solving and Estimating Heterogeneous Agent Models with

114/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Computing time

Table: Run time for Krusell & Smith model

StE K & S Reiter-Reduction Reiter-Full

in seconds 6.28 49.85 0.43 0.91

Notes: Run time in seconds on a Dell laptop with an Intel i7-7500U CPU @ 2.70GHz x 4. Model calibration and numberof grid points as in Den Haan et al. (2010). Code in Matlab.

Page 144: Solving and Estimating Heterogeneous Agent Models with

115/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Comparison to MIT

MIT shock solution

I See Kurt Mitman’s slides.

Page 145: Solving and Estimating Heterogeneous Agent Models with

116/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Comparison to MIT

Computer Exercise 3

ExerciseSolve the Krusell-Smith model using first order perturbation. For this purpose, first solve thesteady state by either EGM or VFI. Then write a function that calculates the Euler equationerrors, errors from capital accumulation, and the law of motion for productivity.

Page 146: Solving and Estimating Heterogeneous Agent Models with

117/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Comparison to MIT

Computer Exercise 4

ExerciseSolve the Krusell-Smith model using MIT shock solution approach.

Page 147: Solving and Estimating Heterogeneous Agent Models with

118/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Krusell-Smith model

Comparison to MIT

Computer Exercise 5

ExerciseSolve the Krusell-Smith model using first order perturbation and dimensionality reductionproposed by Bayer and Luetticke (2018). For this purpose, split the joint-distribution intoCopula and marginals and define the marginals as state. Apply the DCT transformation to thepolicy function and keep only the most important basis functions as controls. Write thecorresponding non-linear difference equations as a function Fsys.

Page 148: Solving and Estimating Heterogeneous Agent Models with

119/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Application: Estimating HANK models

Page 149: Solving and Estimating Heterogeneous Agent Models with

120/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Bayer, Born, Luetticke (2020): Shocks, Frictions, and Inequality in USBusiness Cycles

What we do

I Fuse two-asset HANK model with a Smets-Wouters-type medium scale DSGE model

I Estimate the model using (Bayesian) full-information approach

I IRF analysis and variance decompositions

I Research Question:What shocks and frictions drive the US business cycle and US inequality?

Page 150: Solving and Estimating Heterogeneous Agent Models with

121/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Overview of the model

Workers Production Sector Government

Trade Assets Obtain IncomeProduce and Differentiate Consumption Goods

Monetary Authority,Fiscal Authority

Bonds, b>B;

and

Illiquid Assets (trading friction)

Wages set by unions s.t. Rotemberg wage adjustment costs (Idiosyncratic Income Risk)

Interest

Dividends

Profits

Intermediate goods producersRent capital & labor

Policy Rules:

• Monetary authority sets nominal interest rate-> Taylor rule

• Fiscal authority supplies government debt, consumes goods, taxes labor income and profits-> Spending rule

Competitive Market for Intermediate Goods

EntrepreneursMonopolistic resellers s.t. Rotembergprice adjustment costs

Page 151: Solving and Estimating Heterogeneous Agent Models with

122/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Introducing more macro structure

Linearization techniques easily allow for more structure

I Say, we want to add price stickiness, monetary, and fiscal policy.

I This requires additional extra state variables.

I This is numerical cheap when linearizing.

Page 152: Solving and Estimating Heterogeneous Agent Models with

123/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Recap: Reiter’s method(s)

The starting point is the following observation:

I For the household, current prices and a sequence of value functions suffices to describe thedecision problem. In discretized form this is

νt = uht + βΓht νt+1 (13)

I ht is the optimal policy given prices (or other aggregate controls) Pt and continuationvalues νt

I This induces payoffs uht and a transition matrix Γht

I and this transition matrix also induces the law of motion

µt+1 = µtΓht (14)

I We can view (13) and (14) as the equation describing the idiosyncratic part of asequential equilibrium with recursive individual planning.

Page 153: Solving and Estimating Heterogeneous Agent Models with

124/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Recap: Compact notation (Schmitt-Grohe and Uribe, 2004)Allows to write equilibrium as non-linear difference equation

I Add Pt and St, purely aggregate controls and states, respectively.

I Define “market-clearing” conditions Φ(ht, µt, Pt, St)I and a mapping Ξ(St, Pt, σΣεt+1) of controls to t + 1 states

I Define

F (µt, St, µt+1, St+1, νt, Pt, νt+1, Pt+1, εt+1) (15)

=

µt+1 − µtΓht

St+1 − Ξ(St, Pt, σΣεt+1)νt −

(uht + βΓht νt+1

)Φ(ht, µt, Pt, St)

εt+1

s.t.

ht(s) = arg maxx∈Γ(s,Pt)

u(s, x) + βEνt+1(s′) (16)

Page 154: Solving and Estimating Heterogeneous Agent Models with

125/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Observations

Changing the aggregate macro structure is easy

I As long as a change in the model does not affect what income is composed of and whichchoices households can make given prices and incomes, but only how prices are formed, wecan change the aggregate part of the model without touching the micro part.

I Modular: Micro and Macro block: F (. . . ) = [F1, F2]′

F1 =

[dΞ(µ1

t , . . . , µnt )− dΞ(µ1

t , . . . , µnt )Γt

dct[idct(Θ(θt))−

(uht + βΓtidct(Θ(θt+1))

)]]F2 =

[St+1 − Ξ(St, Pt)Φ(ht, µt, Pt, St)

]

Page 155: Solving and Estimating Heterogeneous Agent Models with

126/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Fusing incomplete markets and price stickiness

A HANK model

I Introduce price stickiness (NKPC),

I introduce a central bank (Taylor rule),

I introduce a fiscal authority (Expenditure rule),

I introduce capital goods producers (quadratic adjustment costs).

Issues:

I We need to deal with assigning monopoly rents.

I We need to deal with the portfolio problem (Bonds vs. Capital).

I We need to make labor supply endogenous

Page 156: Solving and Estimating Heterogeneous Agent Models with

127/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

A HANK modelSee Bayer et al., 2019

Extending the household sector

1. Assume GHH preferences (for business cycles reasonable)

u(c, n) =

(c− h n1+γ

1+γ

)1−ξ

1− ξ

Scaling with productivity h allows for easy aggregation w.l.o.g. if taxes are linear.

2. Assign profits to either to (a) a group of households, (b) the government, or (c) aprofit-asset.

Page 157: Solving and Estimating Heterogeneous Agent Models with

128/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

A HANK model

Modeling portfolio choice: easy version

I All households hold the same bonds-to-capital ratio.

I All assets can be traded without any friction.

I Choice is over total wealth.

I For first order approximation: Returns must equal in expectations, i.e. define a safe returnon bonds Rt, prices of capital goods qt and rental rates of capital rt, then

Etrt+1 + qt+1

qt= Rt+1

Page 158: Solving and Estimating Heterogeneous Agent Models with

129/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Equilibrium conditions (idiosyncratic part)

This leaves us with the following equilibrium conditions:(A) idiosyncratic part, using linear interpolations in micro problem:

1. Recursive planning. For the vectors of marginal utilities uc,t :

uc,t = βRt+1Γt(uc,t+1 + λt+1)︸ ︷︷ ︸one EGM backwards step

with Γt induced by optimal policies,I given future marginal utils uc,t+1, and expected returns Rt+1I and current incomes determined through wages wt, dividends rt, profits πt, and capital

prices qt.

2. Law of motion for distribution of capital

µt+1 = µtΓt

Page 159: Solving and Estimating Heterogeneous Agent Models with

130/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Equilibrium conditions (summary variables)

(B) summary variables, model free:

1. It is useful to introduce an aggregate control that summarize µt: Kt := ∑j kjµjt where kj is

the capital grid.

2. Let φt := BtKt

be the bonds-to-capital ratio entering period t.

3. For any unit of capital households hold, they have rt + qt + φtRt resources forconsumption.

4. Every unit of capital for next period sells at qt + φt+1

Page 160: Solving and Estimating Heterogeneous Agent Models with

131/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Equilibrium conditions (macro model)(C) prices:

1. Factor prices as controls from FOCs of firms

wt = (1− α)mctZt

(Kt

Nt

, rt = αmctZt

(Nt

Kt

)1−α

− δ,

prices of undifferentiated goods, mct, and total profits accordingly

πt = βEtπt+1 + κ(

mc−1t − µ

)Πt = (1−mct)Yt − adjustment costs/profits

2. Returns on government bonds from Taylor rule (state variable)

Rt+1 = RρRt π

(1−ρR)θπt Y(1−ρR)θY

t

Observe that adjustment costs are zero up to first order around stationary equilibrium.

Page 161: Solving and Estimating Heterogeneous Agent Models with

132/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Equilibrium conditions (macro model)(D) aggregate quantities:

1. Labor supply(1− τ)wt = Nγ

t

2. Production of capital goods (ignore externality)

qt = 1 + φKt+1 − Kt

Kt

3. Total output and components

Yt = ZtKαt N1−α

t , Ct = Yt −Gt − Kt+1 + (1− δ)Kt

4. A fiscal rule (spending adjusts, Bt is a state, Gt a control)

Gt = (BtRt/πt)ρB π

γπt YγY

t , Bt+1 = Gt + BtRt/πt − τwtNt

5. Goods market clearing is residual.

Page 162: Solving and Estimating Heterogeneous Agent Models with

133/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

2 asset models

HANK models have more action with more assets

I The literature has highlighted the role of wealthy hand-to-mouth consumers (Kaplanet al., 2014).

I HANK models with more assets feature asset substitution as in the older Keynesianliterature (see e.g. Tobin, 1969), which is supported by the data (see Bayer et al., 2019;Luetticke, 2020).

A tractable structure

I For many applications it suffices to assume that capital can only be traded from time totime randomly (Calvo shock).

Page 163: Solving and Estimating Heterogeneous Agent Models with

134/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

2 asset models2 marginal values of assets

I Marginal value of liquid assets results from usual envelop condition

Vb(h, b, k) = Ruc

I Marginal value of illiquid assets results from usual envelop condition

Vk(h, b, k|adjust) = (q + r)uac

when trade is possible and from the marginal value of the dividend payment plusdiscounted marginal value if no trade is possible

Vk(h, b, k|not) = runc + βEV′k(h

′, b′, k)

I Thus, Vk(h, b, k) = λ(q + r)uac + (1− λ)(run

c + βEV′k(h′, b′, k))

I Optimal asset choices require qEVb(h′, b′, k′) = EVk(h′, b′, k′) which allows us to traceout potentially optimal (b′, k′)(h) pairs

Page 164: Solving and Estimating Heterogeneous Agent Models with

135/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Computational aspects of HANK-2

I requires both assets (100 points each)

I 22 income states

I uses both value functions and consumption policies as controls

I Full set would have > 600, 000 variables

I Reduction to 219 distribution states and ca 700 controls for value functions and policies

Page 165: Solving and Estimating Heterogeneous Agent Models with

136/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Exercise 6: Krusell-Smith-model with nominal rigidity

ExerciseTake the setup from last exercise: and add a government that runs a central bank, a fiscalauthority and owns all profit incomes. Households have GHH preferences over labor andconsumption, but still unemployment shocks.

1. Solve for the steady state without aggregate risk.

2. Solve using Bayer and Luetticke’s refinement.

Assume the central bank only reacts to inflation and past interest rates ρR = 0.95 andθπ = 1.25. The fiscal side only reacts to the level of debt ρB = −0.1. Assume steady stateprofits are 10% and the Phillips Curve reflects price adjustment of roughly once a year if it wasfrom Calvo. Assume steady state labor taxes are 25%.

Page 166: Solving and Estimating Heterogeneous Agent Models with

137/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Sources of Fluctuations

Standard in complete markets model

I total factor productivity

I gov. bond spread (a.k.a. “risk premium”)

I price markup

I wage markup

I monetary policy

I government spending

New in the incomplete markets model

I idiosyncratic income risk

I tax progressivity

Page 167: Solving and Estimating Heterogeneous Agent Models with

137/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Estimating HANK models

Sources of Fluctuations

Standard in complete markets model

I total factor productivity

I gov. bond spread (a.k.a. “risk premium”)

I price markup

I wage markup

I monetary policy

I government spending

New in the incomplete markets model

I idiosyncratic income risk

I tax progressivity

Page 168: Solving and Estimating Heterogeneous Agent Models with

138/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Solution and Estimation

Page 169: Solving and Estimating Heterogeneous Agent Models with

139/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Solution method

I The distribution Θ over b, k, h is a state variable

I First-order perturbation of the non-linear difference equation EF(xt, xt+1, εt) = 0 aroundthe stationary equilibrium to obtain a local approximation to the solution

I We approximate the policy functions as sparse polynomials around their stationaryequilibrium values and approximate the distribution functions by histograms of theirmarginals and a time-varying Copula as in Bayer and Luetticke (2020).

Page 170: Solving and Estimating Heterogeneous Agent Models with

140/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Estimation: Overview

I i.e., method linearizes the resulting non-linear difference equation

I Write as Axt = Bxt+1 and solve using standard methods

I State-space representation of the model solution

I Use Kalman filter to evaluate likelihood

I Maximize posterior likelihood

I Draw from posterior

Page 171: Solving and Estimating Heterogeneous Agent Models with

141/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Estimation: Numerical details

For each new draw of the parameter vector:

1 Update of Jacobian of F[.] (less then 1sec )

2 Solve linear state space modelI State&Control vector has roughly 1000 entriesI Klein’s method via schur decomposition (ca. 5sec)

3 Run Kalman Filter to obtain log-likelihood (ca. 1sec)

Page 172: Solving and Estimating Heterogeneous Agent Models with

142/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Estimation: Update of JacobianChanging parameters does not mean we have to update everythingI Since estimated parameters do not directly show up in household problem, they change

only small parts of A, B during estimation.I This means that writing F (. . . ) = [F1, F2]

′,

F1 =

[dΞ(µ1

t , . . . , µnt )− dΞ(µ1

t , . . . , µnt )Γt

dct[idct(Θ(θt))−

(uht + βΓtidct(Θ(θt+1))

)]]F2 =

[St+1 − Ξ(St, Pt)Φ(ht, µt, Pt, St)

]implies we only need to update the Jacobian of F2 when changing model parameters andΦ(ht, dµt, Pt, St) = Φ(Pt, St) except for summary equation.

I Number of derivatives to be calculated same as in RANKI Convenient also in terms of coding: Only dynare-like macro model block needs to be

edited to change the macro model.

Page 173: Solving and Estimating Heterogeneous Agent Models with

143/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Estimation: Solve linear state space model

I Write as Axt = Bxt+1 and solve using Klein’s method to obtain G and H.

I Uses generalized Schur decomposition (computational efficiency)

I Algorithm cost O(n3) floating point operations

I We also experimented with the Anderson and Moore (1985) algorithm. While it is morethan twice as fast as Klein’s method for the HANK model with two assets in many cases,it appears to produce less numerically stable results in a setting such as ours, where theJacobians are not very sparse.

Page 174: Solving and Estimating Heterogeneous Agent Models with

144/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Estimation: Solve linear state space model

Alternative: Speed up Linear Time Iteration (Papp&Reiter, 2020)

I Fn+1 = −(B + CFn)−1AI F need not be initialized to zero if an estimate of F is available from an earlier calculation

with similar parameter values.

I The linear equation system can be solved making use of a variant of theSherman-Morrison-Woodbury formula (blockwise matrix inversion).

I Computational complexity only depends on number of states (and not controls)!

Page 175: Solving and Estimating Heterogeneous Agent Models with

145/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Estimation: Kalman filter

Similar to An and Schorfheide (2007) and Fernandez-Villaverde (2010)

1. Kalman filter to obtain the likelihood from the state-space representation of the modelsolution.

2. Advantage of State-Space: Deal with mixed frequency and missing observations.

3. Roughly one evaluation of the Kalman filter every other second.

4. Maximize posterior likelihood

Page 176: Solving and Estimating Heterogeneous Agent Models with

146/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Estimation: Kalman filter

I For a one-frequency data set without missing values, one can speed up the estimation byemploying so-called “Chandrasekhar recursions” for evaluating the likelihood.

I These recursions replace the costly updating of the state variance matrix bymultiplications involving matrices of much lower dimension (see Herbst, 2014, for details).

I This is especially relevant for the two-asset HANK model as the speed of evaluating thelikelihood is dominated by the updating of the state variance matrix, which involves themultiplication of matrices that are quadratic in the number of states.

Page 177: Solving and Estimating Heterogeneous Agent Models with

147/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Estimation

Estimation: Posterior

I Random Walk Metropolis Hastings algorithm to draw from posterior

I Standard to draw 200k times to recover the posterior distribution

Speed up:

I Run multiple chains

I Go sequential Monte Carlo (NY Fed has implemented this for our perturbation approach)

Page 178: Solving and Estimating Heterogeneous Agent Models with

148/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Excursus: Kalman Filter

Gaussian State SpaceI Solution to linearized model takes state space form, which can be written as

xt+1 = Gxt + wt+1, wt+1iid∼N (0, Q) (17)

yt = Hxt + νt, νtiid∼N (0, R) (18)

I G, H, Q, R are functions of the model parameters θI xt is an nx × 1 vector of states

I yt is an ny × 1 vector of observables

I wt is a p× 1 vector of structural errors

I νt a vector of measurement errors

I Assumption: wt and νt are orthogonal

Et (wt+1νs) = 0 ∀ t + 1 and s ≥ 0

Page 179: Solving and Estimating Heterogeneous Agent Models with

149/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Excursus: Kalman Filter

Fundamental Problem: Unobserved States

I This implies thatyt = H (Gxt−1 + wt) + νt (19)

I Thus, yt is normally distributed:

yt ∼ N (HGxt−1, HQH + R) (20)

I If all states were observed, we could directly construct the likelihood f (yT, . . . , y1|θ)

I We could then run optimizer over our estimated parameter set θ ⊆ θ to get ML estimateof θ

I Problem: we have unobserved states and cannot use equation (20)

I Solution: turn to Kalman filter to back out states from the observed data → Filteringproblem

Page 180: Solving and Estimating Heterogeneous Agent Models with

150/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Excursus: Kalman Filter

Kalman Filter: SummaryAt time t, given xt|t−1, Σt|t−1 and observing yt

1. Compute the forecast error in the observations using

at = yt −Hxt|t−1 (21)

2. Compute the Kalman Gain Kt using

Kt = GΣt|t−1H′(

HΣt|t−1H′ + R)−1

(22)

3. Compute the state forecast for next period given today’s information

xt+1|t = Gxt|t−1 + Kt

(yt −Hxt|t−1

)= Gxt|t−1 + Ktat (23)

4. Update the covariance matrix

Σt+1|t = (G− KtH)Σt|t−1 (G− KtH)′ + Q + KtRKt′ (24)

Page 181: Solving and Estimating Heterogeneous Agent Models with

151/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Excursus: Kalman Filter

Kalman Filter: InitializationI How to initialize filter at t = 0 where no observations are available?

→ start with unconditional mean E(x) and Variance Σ

I Given covariance stationarity, the unconditional mean is

E(x) = Ext+1 = E(Gxt + wt+1) = GE(x)⇒ (I−G)E(x) = 0

hence, E(x) = 0

I For the covariance matrix, we have

Σ = E[(Gxt + wt) (Gxt + wt)

′]

= E[Gxtxt

′G′ + wtwt′]

= GΣG′ + Q (25)

→ so-called Lyapunov-equation

Page 182: Solving and Estimating Heterogeneous Agent Models with

152/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Excursus: Kalman Filter

Metropolis Hastings-Algorithm

I Start with a vector θ0

I Repeat for j = 1, . . . , N

I Generate θ from q(θj−1, ·) and u from U (0, 1)I If θ is valid parameter draw (steady state exists, Blanchard-Kahn conditions satisfied etc.)

and u < α(θj−1, θj) set θj = θI Otherwise, set θj = θj−1 (implies setting π(θ) = 0 if draw invalid )

I Return the values {θ0, . . . , θN}

I After the chain has passed the transient stage and the effect of the starting values hassubsided, the subsequent draws can be considered draws from the posterior

⇒ burnin required that assures remaining chain has converged

Page 183: Solving and Estimating Heterogeneous Agent Models with

153/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Excursus: Kalman Filter

The Random-Walk Metropolis Hastings Algorithm

I As long as the regularity conditions are satisfied, any proposal density will ultimately leadto convergence to the invariant distribution

I However: speed of convergence may differ significantly

I In practice, people often use the Random-Walk Metropolis Hastings algorithm where

q(θ, θ)= qRW

(θ − θ

)(26)

and qRW is a multivariate density

I The candidate θ is thus given by the old value θ plus a random variable increment

θ = θ + z, z ∼ qRW (27)

Page 184: Solving and Estimating Heterogeneous Agent Models with

154/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Bayer, Born, Luetticke (2020)

Estimation: Two-step procedure

I First, we calibrate or fix all parameters that affect the steady state of the model.

I Second, we estimate by full-information methods all parameters that only matter for thedynamics of the model, i.e., the aggregate shocks, frictions, and policy rules.

I We set the priors for shocks, frictions, and policy rules to standard values from therepresentative agent literature

Page 185: Solving and Estimating Heterogeneous Agent Models with

155/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Bayer, Born, Luetticke (2020)

Observables

Quarterly US data from 1954Q1 – 2019Q4

In first-differences

I GDP, Consumption, Investment

I the real wage

In log-levels

I GDP deflator based inflation rates

I Hours worked per capita

I the (shadow) federal funds rate

All demeaned and without measurement error.

Page 186: Solving and Estimating Heterogeneous Agent Models with

156/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Application: Bayer, Born, Luetticke (2020)

Observables

Further data non-quarterly availability

I Measures of inequality:I Wealth share of the top 10% (Piketty-Saez WID) (1954 – 2019)I Income share of the top 10% (Piketty-Saez WID) (1954 – 2019)

All in log-levels, demeaned and with measurement error.

Page 187: Solving and Estimating Heterogeneous Agent Models with

157/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Estimated model variants

Data

ShocksAggregate Data + Cross-sectional Data

Aggregate Shocks HANK (vs RANK) HANKX

+ Cross-sectional Shocks HANKX+

Page 188: Solving and Estimating Heterogeneous Agent Models with

158/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Wealth Inequality in the US

(a) Top 10% income share (b) Top 10% wealth share

Page 189: Solving and Estimating Heterogeneous Agent Models with

159/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Shocks and Frictions inUS Business Cycles

Page 190: Solving and Estimating Heterogeneous Agent Models with

160/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Variance decomposition: GDP and components

RANK

HANK

HANKX

0 20 40 60 80 100

RANK

HANK

HANKX

0 20 40 60 80 100

Growth of output Yt Growth of consumption Ct

Page 191: Solving and Estimating Heterogeneous Agent Models with

161/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

US business cycles: Summary

HANK and RANK models give only a somewhat different view

Estimation results

I Key is the estimation that makes the dynamics of both models more similar

I Estimated HANK model features less nominal and real frictions than RANK

Decomposition results

I Investment-specific technology becomes less important because it induces wealth effectson consumption via asset prices

I Risk premium, monetary, and wage markup shocks become more important

I Income risk shocks can partly replace risk premium shocks

Page 192: Solving and Estimating Heterogeneous Agent Models with

162/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Shocks and Frictions inUS Inequality

Page 193: Solving and Estimating Heterogeneous Agent Models with

163/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Shock decomposition: Income share of top 10%

Page 194: Solving and Estimating Heterogeneous Agent Models with

164/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Shock decomposition: Wealth share of top 10%

Page 195: Solving and Estimating Heterogeneous Agent Models with

165/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Contribution of shocks to US inequality 1985-2019

Shock Top 10% Income Top 10% Wealth

TFP, εZ -0.38 2.63Inv.-spec. tech., εΨ -0.17 3.26

Price markup, εµY 11.69 4.3Wage markup, εµW 5.82 0.87

Risk premium, εA -0.62 2.07Income risk, εσ 2.57 -0.14

Monetary policy, εR 1.30 1.98

Structural deficit, εG -0.05 1.60

Tax progressivity, τP 1.54 0.67

Sum of shocks 21.55 16.79

Page 196: Solving and Estimating Heterogeneous Agent Models with

166/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

US inequality: Summary

Business cycle shocks are important drivers of inequality dynamics

Income inequality

I Price and wage markups explain two-third of the increase since 1985

I Rising income risk and falling tax progressivity explain the remaining one-third

Wealth inequality

I Technology shocks via their effect on asset prices explain most of the increase since 1985

I The two markup shocks explain only one-third of this increase

I Monetary policy and fiscal deficit shocks are important as well

Page 197: Solving and Estimating Heterogeneous Agent Models with

167/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Policy Counterfactuals

Page 198: Solving and Estimating Heterogeneous Agent Models with

168/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Policy counterfactual: Inequality

I How important are the estimated policy coefficients for the evolution of inequality?

I Run estimated shock sequence with counterfactually set policy parametersI Hawkish monetary policy (double inflation response, θπ)I Dovish monetary policy (double output response, θY)

Page 199: Solving and Estimating Heterogeneous Agent Models with

169/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Counterfactual evolution of inequality: Monetary policy

Top 10% income share Top 10% wealth share Output

Log point deviations from baseline. Black: Hawkish; Red: Dovish

Page 200: Solving and Estimating Heterogeneous Agent Models with

170/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Policy counterfactual: Summary

Effect of monetary policy depends on supply vs demand shocks

Hawkish monetary policy (triple θπ)

I Higher inequality in the 70s as markup (cost-push) shocks are important

Dovish monetary policy (triple θY)

I Lower inequality in the 70s and aftermath of the Great Recession

Very persistent effect on wealth inequality.

Page 201: Solving and Estimating Heterogeneous Agent Models with

171/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Results

Summary: Bayer et al. (2020)

Our HANK model can jointly explain the US business cycle and inequality

US business cycle

I Not a radically different view on the US business cycle

I HANK models stress the importance of portfolio choice for the transmission of aggregateshocks

US inequality

I Business cycles are important to understand the evolution of US inequality.

I Business cycle shocks and policy responses can account for most of the increase in USinequality since the 1980s.

Page 202: Solving and Estimating Heterogeneous Agent Models with

172/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Conclusion

Conclusion

No excuse!

I Even when heterogeneity is high dimensional,

I our algorithm is an easy approach to these models

I It is a fast and simple to code

Page 203: Solving and Estimating Heterogeneous Agent Models with

173/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Conclusion

Conclusion

No excuse!I It requires knowledge of only two standard tools of macro:

1. Solving a recursive het. agent model for a StE2. Linearizing a rep. agent model3. (and a little twist in between)

I The fixed design for dimensionality reduction allows to employ the method to estimatemodels with standard techniques

Page 204: Solving and Estimating Heterogeneous Agent Models with

174/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Conclusion

Bibliography I

Ahmed, N., T. Natarajan, and K. R. Rao (1974). “Discrete cosine transform”. IEEETransactions on Computers C-23 (1), 90–93.

Ahn, SeHyoun, Greg Kaplan, Benjamin Moll, Thomas Winberry, and Christian Wolf (2018).“When inequality matters for macro and macro matters for inequality”. NBERMacroeconomics Annual 32 (1), 1–75.

An, Sungbae and Frank Schorfheide (2007). “Bayesian analysis of DSGE models”. EconometricReviews 26 (2-4), 113–172.

Anderson, Gary and George Moore (1985). “A linear algebraic procedure for solving linearperfect foresight models”. Economics Letters 17 (3), 247–252.

Auclert, Adrien, Bence Bardoczy, Matthew Rognlie, and Ludwig Straub (2019). “Using thesequence-space Jacobian to solve and estimate heterogeneous-agent models”. NBERWorking Paper 26123.

Bayer, Christian, Benjamin Born, and Ralph Luetticke (2020). “Shocks, Frictions, andInequality in US Business Cycles”. CEPR Discussion Paper 14364.

Page 205: Solving and Estimating Heterogeneous Agent Models with

175/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Conclusion

Bibliography II

Bayer, Christian and Ralph Luetticke (2020). “Solving heterogeneous agent models in discretetime with many idiosyncratic states by perturbation methods”. Quantitative Economicsforthcoming.

Bayer, Christian, Ralph Luetticke, Lien Pham-Dao, and Volker Tjaden (2019). “Precautionarysavings, illiquid assets, and the aggregate consequences of shocks to household income risk”.Econometrica 87 (1), 255–290.

Boppart, Timo, Per Krusell, and Kurt Mitman (2018). “Exploiting mit shocks inheterogeneous-agent economies: the impulse response as a numerical derivative”. Journal ofEconomic Dynamics and Control 89, 68–92.

Carroll, C.D. (2006). “The method of endogenous gridpoints for solving dynamic stochasticoptimization problems”. Economics Letters 91 (3), 312–320.

Den Haan, Wouter J (2010). “Assessing the accuracy of the aggregate law of motion in modelswith heterogeneous agents”. Journal of Economic Dynamics and Control 34 (1), 79–99.

Page 206: Solving and Estimating Heterogeneous Agent Models with

176/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Conclusion

Bibliography III

Den Haan, Wouter J, Kenneth L Judd, and Michel Juillard (2010). “Computational suite ofmodels with heterogeneous agents: incomplete markets and aggregate uncertainty”. Journalof Economic Dynamics and Control 34 (1), 1–3.

Fernandez-Villaverde, Jesus (2010). “The econometrics of DSGE models”. SERIEs 1 (1), 3–49.

Herbst, Edward (2014). “Using the “Chandrasekhar Recursions” for likelihood evaluation ofDSGE models”. Computational Economics 45 (4), 693–705.

Hintermaier, T. and W. Koeniger (2010). “The method of endogenous gridpoints withoccasionally binding constraints among endogenous variables”. Journal of EconomicDynamics and Control 34 (10), 2074–2088.

Kaplan, Greg, Giovanni L Violante, and Justin Weidner (2014). “The wealthy hand-to-mouth”.NBER Working Paper No. 20073.

Krusell, Per and Anthony A. Smith (1998). “Income and wealth heterogeneity in themacroeconomy”. Journal of Political Economy 106 (5), 867–896.

Page 207: Solving and Estimating Heterogeneous Agent Models with

177/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Conclusion

Bibliography IV

Krusell, Per and Anthony A. Smith (1997). “Income and wealth heterogeneity, portfolio choice,and equilibrium asset returns”. Macroeconomic Dynamics 1 (02), 387–422.

Luetticke, Ralph (2020). “Transmission of monetary policy with heterogeneity in householdportfolios”. American Economic Journal: Macroeconomics forthcoming.

Reiter, Michael (2002). “Recursive computation of heterogeneous agent models”. mimeo,Universitat Pompeu Fabra.

(2009). “Solving heterogeneous-agent models by projection and perturbation”. Journalof Economic Dynamics and Control 33 (3), 649–665.

Schmitt-Grohe, Stephanie and Martın Uribe (2004). “Solving dynamic general equilibriummodels using a second-order approximation to the policy function”. Journal of EconomicDynamics and Control 28 (4), 755–775.

Tobin, James (1969). “A general equilibrium approach to monetary theory”. Journal of Money,Credit and Banking 1 (1), 15–29.

Page 208: Solving and Estimating Heterogeneous Agent Models with

178/178

Solving and Estimating Heterogeneous Agent Models with Aggregate Uncertainty by Perturbation Methods

Conclusion

Bibliography V

Winberry, Thomas (2016). “A toolbox for solving and estimating heterogeneous agent macromodels”. mimeo, Chicago Booth.