Fifth Order Perturbation Solution to DSGE Models Oren Levintal Bar-Ilan University [email protected] November 20, 2013 Abstract This paper derives a fifth-order perturbation solution to DSGE models. To do so, the paper develops a new notation that is simpler than the standard notation of Schmitt-Grohé and Uribe (2004). Specifically, the perturbation parameter is treated as a state variable and the model is presented as a function of a single vector variable. Consequently, the system is differentiated with respect to one vector only. This yields a notational gain that rises exponentially with the perturbation order. The paper derives high order multivariate chain rules up to a fifth order, which are required for high order solutions. Symmetry of mixed derivatives is exploited to reduce memory consumption. Keywords: Perturbation, Fifth order, High order multivariate chain rules, Sylvester equation, DSGE, Symmetric tensors. JEL classification: C63, C68, E0. 1 1 Introduction Perturbation methods have become highly popular for solving DSGE models. These solutions are very accurate around the deterministic steady state, provided that volatility is not too strong (Aruoba, Fernández-Villaverde and Rubio-Ramı́rez 2006). To increase accuracy to more distant points and to more volatile models, the literature has developed high order perturbation solutions. Schmitt-Grohé and Uribe (2004), Kim, Kim, Schaumburg and Sims (2008) and Gomme and Klein (2011) provide methods for obtaining a second order perturbation solution. Andreasen (2012) and Ruge-Murcia (2012) extend Schmitt-Grohé and Uribe (2004) to a third order perturbation solution. Binning (2013) extend Gomme and Klein (2011) to a third order solution. To my knowledge, perturbations higher than third order are not available in the existing literature.1 Obtaining high order perturbation solutions, such as fourth and fifth order, is not trivial. The system of equations that needs to be solved becomes extremely complicated and difficult to manage. This is seen most clearly in the third order solution derived by Andreasen (2012) and Ruge-Murcia (2012). For instance, the third order system in Andreasen (2012) requires almost three pages of equations, with expressions that contain dozens of terms. One can only imagine how complicated the system would be for fourth and fifth order solutions. 1 Collard and Juillard (2001) propose a different approach, which is based on a k order Taylor expansion of the model conditions. The present paper follows the perturbation method of Schmitt-Grohé and Uribe (2004), where the Taylor expansion is applied to the policy functions. In this regard, perturbation solutions higher than third order are currently not available, except for particular cases that are solved with symbolic math, e.g. Aruoba, Fernández-Villaverde and Rubio-Ramı́rez (2006). 2 This paper proposes a different notation, which is much simpler than the existing literature. In the proposed notation, the perturbation parameter is treated as an exogenous state variable and included in the vector of state variables x. This enables to present the model as a composition of two functions, f (v) and v (x), so that the model conditions are given by Ef (v (x)) = 0. As a result, all the necessary derivatives are obtained by applying high order chain rules on f (v (x)). This yields a notational gain that rises exponentially with the order of perturbation. Using this notation, the paper derives a fifth-order perturbation solution, which is implemented by a Matlab package that is available online. The solution is based on high order multivariate chain rules, which are derived up to a fifth order. To minimize memory consumption, the solution algorithm exploits the symmetry of mixed derivatives and solves only the unique derivatives. The paper proceeds as follows. Section 2 presents the DSGE model with the new notation. To solve the model, the paper uses tensor and matrix notation interchangeably. Hence, section 3 presents the tensor-matrix mapping used to switch from tensor to matrix notation and vice versa. Section 4 derives the first and second order solutions and demonstrates the notational gain compared to Schmitt-Grohé and Uribe (2004). To extend the solution to higher orders, section 5 derives high order multivariate chain rules, which are necessary for high order solutions. Section 6 develops tools to calculate expectations of Kronecker products, which appear repeatedly in high order solutions. The third, fourth and fifth order solutions are derived in sections 7-9. Section 10 describes the solution algorithm, which solves the unique derivatives. Section 11 performs accuracy tests on the algorithm, and section 3 12 concludes. The appendix discusses some technical issues in more detail. 2 The Model The basic notation builds on Schmitt-Grohé and Uribe (2004). The main differ- ence is that the perturbation parameter is treated as a ”state” variable. Specifically, the vector of state variables is: x1t 2 xt = xt , σt (1) where x1t is a vector of n1x pre-determined variables, x2t is a vector of n2x exogenous variables, and σt is an exogenous state variable that plays the role of the perturbation parameter. The size of xt is nx = n1x + n2x + 1. The evolution law of the exogenous state variables is defined by: x2t+1 σt+1 Φ (xt ) + σt η̃ǫt+1 , = σt (2) where Φ is a known function, η̃ is a known n2x × nǫ matrix, and ǫ is a nǫ × 1 vector of shocks with zero mean. The cross moments of ǫ are denoted M 2 , M 3 , . . .. For instance, M 2 is the variance-covariance matrix of ǫ, M 3 is a 3-dimensional tensor 4 whose ijk element is Eǫi ǫj ǫk , and so on. It follows from (2) that the perturbation variable is static (σt+1 = σt ). The model is deterministic at σt = 0 and stochastic for σt > 0. The treatment of σ as a ”state variable” maximizes the symmetric property of the system and simplifies notation considerably. As a by product, expressions such as gxσ do not appear in this notation, because σ is included in x. This bears some cost, because we cannot exploit known results on these mixed derivatives, such as Theorems 1 in Schmitt-Grohé and Uribe (2004). However, the cost is small compared to the notational gain obtained by the symmetric structure of the problem. The model is defined by a set of nf expectational conditions: Ef (yt+1 , yt, xt+1 , xt ) = 0, (3) where yt is a vector of ny control variables. These conditions include the n2x + 1 conditions from (2) and additional n1x +ny conditions. The total number of conditions is nf = nx + ny . Let the functions g and h̃ denote the optimal response of yt and x1t+1 , given state xt : yt = g (xt ) , x1t+1 = h̃ (xt ) . 5 (4) Define the function h (xt ) and the matrix η by: h̃ (xt ) h (xt ) = Φ (xt ) σt 0n1x ×nǫ , η = η̃ 01×nǫ . (5) It follows that: xt+1 = h (xt ) + σt ηǫt+1 . (6) In this notation, xt+1 depends on xt and on σt . Since σt is already included in xt , it would be more efficient to represent the RHS of (6) as a function of xt only. To do so, define a new nx × nx matrix ζt as follows: ζt = 0nx ×(nx −1) , ηǫt+1 . (7) All the columns of ζt are zero except the last column, which is ηǫt+1 . With this matrix, (6) can be stated as a function of xt only: xt+1 = h (xt ) + ζt xt . 6 (8) The model is completely defined by (3) and (8). The solution is the functions g (xt ) and h (xt ) for which (3) and (8) hold. To reduce notation further, time subscripts are dropped and next period variables are denoted by ′ . In addition, let v = (y ′ , y, x′, x) denote the vector of the model variables, and write (3) and (8) as follows: Ef (v) = 0, v (x) = g (h (x) + ζx) , g (x) , h (x) + ζx , x . (9) (10) By this notation the model is represented as a composition of the functions f (v) and v (x). Hence, f will be differentiated with respect to x only, by applying high order multivariate chain rules on the composite function f (v (x)). This is the source of the notational gain. The deterministic steady state is derived by setting σ = 0 and solving the steady state. Let x̄1 , x̄2 and ȳ denote the steady state solution, and define x̄ = (x̄1 , x̄2 , 0). Note that (7) implies that ζ x̄ = 0. The steady state solution x̄, ȳ satisfies: f (ȳ, ȳ , x̄ , x̄) = 0. A k’th order perturbation solution is the k’th order Taylor series of g (x) and h (x) centered at x̄. The unknowns are the k derivatives of g (x) and h (x) evaluated at x̄. To solve these derivatives, (9) is differentiated k times with respect to x and 7 evaluated at x̄. This yields the system: ∂ 2 fi (v (x)) ∂ k fi (v (x)) ∂fi (v (x)) =E = ... = E 0=E ∂xj1 x=x̄ ∂xj1 ∂xj2 x=x̄ ∂xj1 · · · ∂xjk x=x̄ (11) ∀i ∈ {1, . . . , nf }, j1 , . . . , jk ∈ {1, . . . , nx }. Throughout, I use the following notation for derivatives: k i ∂ k fi (v (x)) ∂ f , ≡ ∂xj1 · · · ∂xjk ∂xk j1 j2 ...jk where h ∂k f ∂xk i denotes a tensor of the k’th derivatives of f with respect to x. The solution of (11) provides the unknown derivatives of the policy functions. As shown by Judd (1998) and Judd and Guu (1997), the solution is obtained recursively. The first equation defines the first derivatives as a solution of a quadratic system. The higher order conditions are linear in the unknown derivatives, given the solution of lower derivatives. Throughout, I assume that a first order solution is available (e.g. Klein 2000), and focus on the higher order solutions. 3 Tensor-Matrix Mapping The paper uses tensor notation and matrix notation interchangeably, depending on the task at hand. Tensor notation is more convenient for differentiation and for tensor permutation, which appears frequently in perturbations higher than second order. Matrix notation is required to form and manipulate the linear system. This 8 section explains the tensor-matrix mapping used to switch from one notation to the other. The section is technical and can be skipped, but the reader should be aware of the simultaneous use of tensor and matrix notation in the following sections. As an example, consider a fifth order Taylor series of the i’th row of g. Applying the tensor notation used by Schmitt-Grohé and Uribe (2004), the Taylor series is represented by: [g (x)]i = [g (x̄)]i + [gx ]iα [x − x̄]α + 1 [gxx ]iαβ [x − x̄]β [x − x̄]α 2 (12) 1 [gxxx ]iαβγ [x − x̄]γ [x − x̄]β [x − x̄]α 3! 1 + [gxxxx ]iαβγδ [x − x̄]δ [x − x̄]γ [x − x̄]β [x − x̄]α 4! 1 + [gxxxxx]iαβγδǫ [x − x̄]ǫ [x − x̄]δ [x − x̄]γ [x − x̄]β [x − x̄]α , 5! + where gx , gxx , . . . denote the derivatives of g with respect to x, evaluated at the steady state x̄. Note that g (x̄) = ȳ. An alternative way to present a Taylor series is by matrix notation, e.g. Gomme and Klein (2011) and Benigno, Benigno and Nisticò (2013). Here, I adopt matrix notation that is slightly different from Gomme and Klein (2011). Specifically, a tensor of the k’th derivatives of f (x) is mapped into a matrix of dimensions nf × (nx )k , where nf is the size of f and nx is the size of x. For instance, the Hesian of g (x) is a 3-dimensional tensor with dimensions ny × nx × nx . In matrix notation, this tensor is mapped into a matrix of dimensions ny × (nx )2 . By comparison, Gomme and Klein (2011) represent the Hessian as a matrix of dimensions ny nx × nx , which 9 is a different matrix. The tensor-matrix mapping used in this paper is such that the i’th row of the Hessian matrix contains the following elements of the Hessian tensor: (i, 1, 1), (i, 2, 1), (i, 3, 1), . . . , (i, 1, 2), (i, 2, 2), (i, 3, 2), . . . , (i, 1, 3), (i, 2, 3), (i, 3, 3), . . . A similar mapping applies to tensors of higher dimensions. This mapping is performed by the Matlab function reshape.m. With this mapping, the fifth order Taylor series can be stated as: 1 1 g (x) =g (x̄) + gx (x − x̄) + gxx (x − x̄)⊗2 + gxxx (x − x̄)⊗3 2 3! 1 1 + gxxxx (x − x̄)⊗4 + gxxxxx (x − x̄)⊗5 , 4! 5! where ⊗k (13) denotes a ”Kronecker power”, e.g. B ⊗3 = B ⊗ B ⊗ B. Note that the Kronecker power is performed before the inner product, hence AB ⊗3 ≡ A (B ⊗3 ). The appendix describes how expressions such as AB ⊗k can be calculated in Matlab without creating the big matrix B ⊗k , by using reshape and transpose. Another expression that will be represented interchangeably in tensor and matrix notation is a Kronecker product of several matrices, such as A ⊗ B ⊗ C. The tensor representation of this matrix is a 6-dimensional tensor, whose i1 , i2 , i3 , j1 , j2 , j3 element is C (i1 , j1 ) B (i2 , j2 ) A (i3 , j3 ). Note that the order of A, B and C is reversed by the transition from matrix to tensor notation. The tensor representation is obtained by reshaping A ⊗ B ⊗ C into a tensor whose first three dimensions are the rows of C, B and A (in this order), and the last three dimensions are the columns of these 10 matrices. To distinguish between tensor notation and matrix notation, tensors are enclosed by square brackets and their dimensions are indexed (e.g. [gxx ]ijk ). Matrices are denoted naturally (e.g. gxx ). 4 First and Second Order Solutions This section derives the first and second order perturbation solutions. I start by differentiating (9) with respect to x. Recall that x contains the perturbation variable, so this is the only differentiation that is required: E [fv ]iα [vx ]αj = 0, ∀i = 1, . . . , nf j = 1, . . . , nx . (14) The notation [fv ]iα denotes the derivative of the i’th row of f with respect to the α’th row of v. Similarly, [vx ]αj denotes the derivative of the α’th row of v with respect to the j’th row of x. Greek letters denote summation indices, so [fv ]iα [vx ]αj implies P [fv ]iα [vx ]αj . This notation will be more useful in higher order chain rules, which α are derived in section 5. To get vx , differentiate (10) with respect to x. Here, vx is presented in matrix notation: 11 vx = ∂g(h(x)+ζx) ∂x gx hx + ζ Inx ×nx . (15) The first element is a first order chain rule applied to the composite function g (h (x) + ζx): ∂g (h (x) + ζx) = gx (hx + ζ) . ∂x (16) The derivatives gx and hx are evaluated at the steady state x̄. Hence, h (x̄) + ζ x̄ = x̄ and gx (h (x̄) + ζ x̄) = gx (x̄). Similarly, gxx (h (x̄) + ζ x̄) = gxx (x̄) and so on. These derivatives are denoted simply gx , gxx , . . .. The matrix vx is stochastic, because it depends on the stochastic matrix ζ. It will be convenient for later stages to present it as a polynomial function of ζ. To do so, substitute (16) in (15) and write vx as follows: vx = Vx0 + Vx1 ζ, where the coefficients Vx0 and Vx1 are defined by: 12 (17) g h x x gx 0 Vx = hx I g x 0 , Vx1 = . I 0 (18) To complete the first order system, note that fv is deterministic, because it is evaluated at the steady state. This applies also to higher derivatives of f with respect to v. Taking the expected value of (17) and substituting in (14) yields the condition for the first order solution, presented in matrix notation as: fv Vx0 = 0. (19) It follows from (18) that this is a quadratic system in gx and hx . To get the second order solution, differentiate (14) with respect to x: E [fvv ]iαβ [vx ]βk [vx ]αj + E [fv ]iα [vxx ]αjk = 0 ∀i = 1, . . . , nf j, k = 1, . . . , nx . The tensor notation [fvv ]iαβ denotes the second derivative of the i’th row of f with respect to the α’th and β’th rows of v. Using the tensor-matrix mapping described in section 3, this system can be represented in matrix notation as: 13 Efvv vx⊗2 + Efv vxx = 0. (20) Excluding the expectation operator, the left hand side is a general form of a second order multivariate chain rule. The term vxx is obtained by differentiating (15) with respect to x: vxx = ∂ 2 g(h(x)+ζx) ∂x2 gxx hxx 0nx ×n2x . (21) Here we apply a second order chain rule on the composite function g (h (x) + ζx), which has a similar form to the left hand side of (20): ∂ 2 g (h (x) + ζx) = gxx (hx + ζ)⊗2 + gx hxx . ∂x2 Substituting in (21) yields a quadratic function of ζ: 0 1 1 ⊗2 vxx = Vxx + Vxx (hx ⊗ ζ + ζ ⊗ hx ) + Vxx ζ , where the coefficients are: 14 (22) 0 Vxx = gxx h⊗2 x + gx hxx gxx hxx 0 g xx 0 1 = , Vxx . 0 0 (23) 0 Note that the first term in Vxx is the second order chain rule applied to h (x), namely ∂ 2 g(h(x)) . ∂x2 ∂g(h(x)) . ∂x Similarly, the first term in Vx0 , given in (18), was the first order chain rule This pattern will show up again in higher order solutions. To calculate (20), we need the expected values of vx⊗2 and vxx , which follow from (15) and (21): Evx⊗2 = Vx0 ⊗2 + Vx1 ⊗2 Eζ ⊗2 , 0 1 Evxx = Vxx + Vxx Eζ ⊗2 . (24) (25) The term Eζ ⊗2 can be derived from (7), as follows: Eζ ⊗2 ⊗2 = 0(nx )2 ×((nx )2 −1) , E (ηǫ) = 0(nx )2 ×((nx )2 −1) , η ⊗2 vec M 2 , where vec (M 2 ) is a vectorization of the variance-covariance matrix M 2 . 15 (26) Having (24)-(25), we can represent the second order system (20) as a linear system in gxx and hxx : A + fy′ gxx B + fy gxx + (fx′ + fy′ gx ) hxx = 0, (27) A ≡ fvv Evx⊗2 , ⊗2 B ≡ h⊗2 . x + Eζ fy′ , fy , fx′ are the derivatives of f with respect to y ′ , y, x′, respectively. Higher order systems will have a similar structure, only with different matrices A and B. The solution algorithm of this system is discussed in section 10. The notational gain of the proposed notation can be illustrated by comparing (27) with the equivalent system in Schmitt-Grohé and Uribe (2004, pp. 762-763). The inclusion of the perturbation parameter in x eliminates expressions such as gσσ , which are already included in gxx . Moreover, since f is represented as a composite function f (v (x)), all the second derivatives of f are included in fvv . This yields a significant notational gain, which rises exponentially with the order of perturbation. For instance, the derivative fvv replaces 16 derivatives of f with respect to y ′ , y, x′, x that appear in the notation of Schmitt-Grohé and Uribe (2004). In a fifth order system, fvvvvv replaces 1,024 derivatives of f with respect to y ′ , y, x′, x. The next sections extend this method to higher order solutions. This requires to derive high order chain rules, which were used in the second order system in (20), (21) and (23). Higher order systems will use higher order chain rules at the 16 equivalent points. In addition, we need to derive expectations of Kronecker products of vx , vxx , . . . such as (24)-(25). The stochastic variable in these expressions is the matrix ζ. This matrix will appear as a Kronecker power in various forms. Methods for calculating the expected value of these expressions are developed in section 6. 5 High Order Multivariate Chain Rules This section derives multivariate chain rules up to a fifth order. The preferred no- tation is tensor notation, because differentiation and permutations are involved. The chain rules are implemented by the Matlab functions chain2.m, chain3.m, chain4.m and chain5.m, which are available online together with all the other codes of this paper. These codes were tested by comparison with Matlab symbolic differentiation. The test file is also available online. For a given composite function f (v (x)), a k’th order multivariate chain rule generates a tensor with k + 1 dimensions. The first dimension indexes the rows of f . The second to last dimensions index the rows of x. Note that these dimensions are symmetric. In what follows, fv , fvv , . . . denote tensors of the first, second and higher derivatives of f with respect to v. Similarly, vx , vxx , . . . denote the derivative tensors of v with respect to x. A particular element of these tensors is denoted by its indices. For instance, [fvvv ]ijkl denotes the third derivative of the i’th row of f with respect to the j’th, k’th and l’th rows of v. The second order chain rule was introduced in the previous section. It is presented again for convenience: 17 ∂ 2 f (v (x)) ∂x2 i = [fvv ]iαβ [vx ]βk [vx ]αj + [fv ]iα [vxx ]αjk . (28) jk This rule appears also in Judd (1998, p. 490). To get the third order chain rule, differentiate (28) with respect to x: ∂ 3 f (v (x)) ∂x3 i = [fvvv ]iαβγ [vx ]γl [vx ]βk [vx ]αj + [fvv ]iαβ [vxx ]βkl [vx ]αj (29) jkl + [fvv ]iαβ [vx ]βk [vxx ]αjl + [fvv ]iαβ [vx ]βl [vxx ]αjk + [fv ]iα [vxxx ]αjkl . This expression contains five terms, where each term is a tensor of dimensions nf × nx × nx × nx . However, the three middle terms are three different permutations of the same tensor. Hence, the third order multivariate chain rule can be stated more compactly as: ∂ 3 f (v (x)) ∂x3 i = [fvvv ]iαβγ [vx ]γl [vx ]βk [vx ]αj jkl X α β q [fvv ]αβ [vxx ]rs [vx ]t + qrst∈Ω1 + [fv ]iα [vxxx ]αjkl , where Ω1 is a set of three permutations, defined by: 18 (30) Ω1 = {iklj, ijlk, ijkl} . (31) These permutations are performed in Matlab by the function ipermute.m. Proceeding similarly, the fourth order multivariate chain rule is: i ∂ 4 f (v (x)) (32) = [fvvvv ]iαβγδ [vx ]δm [vx ]γl [vx ]βk [vx ]αj 4 ∂x jklm X X [fvv ]qαβ [vxxx ]βrst [vx ]αu [fvvv ]qαβγ [vxx ]γrs [vx ]βt [vx ]αu + + qrstu∈Ω3 qrstu∈Ω2 X [fvv ]qαβ [vxx ]βrs [vxx ]αtu + [fv ]iα [vxxxx ]αjklm + qrstu∈Ω4 where Ω2 = {ilmkj, ikmlj, ijmlk, iklmj, ijlmk, ijkml} Ω3 = {iklmj, ijlmk, ijkml, ijklm} Ω4 = {ikljm, ijlkm, ijklm} The permutation sets Ω2 , Ω3 , Ω4 are obtained by counting the indices of permuted tensors. Take for example the middle term in (30). Differentiating [fvv ]qαβ [vxx ]βrs [vx ]αt with respect to xm (the m’th row of x) requires to apply the derivative of a product. One of the expressions included in this derivative is: 19 [fvv ]qαβ [vxx ]βrs [vxx ]αtm . The permutation set Ω1 implies that qrst ∈ {iklj, ijlk, ijkl}. Summing these permutations together gives: X qrstu∈{ikljm,ijlkm,ijklm} [fvv ]qαβ [vxx ]βrs [vxx ]αtu . These are the permutations in Ω4 . The fifth order multivariate chain rule is: i ∂ 5 f (v (x)) = [fvvvvv ]iαβγδǫ [vx ]ǫn [vx ]δm [vx ]γl [vx ]βk [vx ]αj ∂x5 jklmn X X q δ γ β α [fvvvv ]αβγδ [vxx ]rs [vx ]t [vx ]u [vx ]v + + qrstuv∈Ω6 qrstuv∈Ω5 + X [fvvv ]qαβγ [vxx ]γrs [vxx ]βtv [vx ]αn + X [fvv ]qαβ [vxxx ]βrst [vxx ]αuv + [fv ]iα [vxxxxx ]αjklmn qrstuv∈Ω7 + qrstuv∈Ω9 20 X qrstuv∈Ω8 (33) q γ β α [fvvv ]αβγ [vxxx ]rst [vx ]u [vx ]v [fvv ]qαβ [vxxxx ]βrstu [vx ]αv where: Ω5 = {imnlkj, ilnmkj, iknmlj, ijnmlk, ilmnkj, ikmnlj, ijmnlk, iklnmj, ijlnmk, ijknml} Ω6 = {ilmnkj, ikmnlj, ijmnlk, iklnmj, ijlnmk, ijknml, iklmnj, ijlmnk, ijkmnl, ijklnm} Ω7 = {ilmknj, ikmlnj, ijmlnk, iklmnj, ijlmnk, ijkmnl, ilmjnk, ikmjnl, ijmknl, ikljnm, ijlknm, ijklnm, ikljmn, ijlkmn, ijklmn} Ω8 = {iklmnj, ijlmnk, ijkmnl, ijklnm, ijklmn} Ω9 = {iklmjn, ijlmkn, ijkmln, ijklmn, iklmjn, ijlmkn, ijkmln, ijnmkl, iknmjl, ilnmjk} Matrix notation provides an easier way to present high order chain rules. The third to fifth order chain rules in matrix notation are: ∂ 3 f (v (x)) =fvvv vx⊗3 + fvv (vx ⊗ vxx ) Ω1 + fv vxxx ∂x3 ∂ 4 f (v (x)) =fvvvv vx⊗4 + fvvv vx⊗2 ⊗ vxx Ω2 + fvv (vx ⊗ vxxx ) Ω3 4 ∂x ⊗2 + fvv vxx Ω4 + fv vxxxx (34) (35) ∂ 5 f (v (x)) ⊗2 ⊗3 ⊗5 Ω6 (36) v ⊗ v Ω + f v ⊗ v =f v + f xxx 5 vvv xx vvvvv vvvv x x x ∂x5 ⊗2 + fvvv vx ⊗ vxx Ω7 + fvv (vx ⊗ vxxxx ) Ω8 + fvv (vxx ⊗ vxxx ) Ω9 + fv vxxxxx In this notation, Ω1 , . . . , Ω9 denote matrices that perform the sum of permutations specified in the tensor notation.2 For example, Ω1 is a sum of three matrices Ω11 , Ω21 , Ω31 that perform the permutations in (31). Ω11 is the identify matrix because 2 The transition from tensor to matrix notation requires to reverse the order of the tensors. For instance, a 5-dimensional tensor whose β, α, r, s, t element is given by [vxx ]βrs [vx ]α t is mapped into vx ⊗ vxx (and not vxx ⊗ vx ), as explained in section 3. 21 vx ⊗ vxx is already in a form that is consistent with the first permutation in (31). Ω21 is a permutation matrix that when premultiplied by the matrix vx ⊗ vxx reorders the columns of this matrix in a way that is equivalent to the second permutation in (31). Similarly, Ω31 performs the third permutation in (31). Hence, Ω1 = Ω11 + Ω21 + Ω31 performs the sum of all permutations in (31). In the Matlab code the permutations are performed in tensor notation by the function ipermute.m, except for few cases that require to create the Ω matrices. The derivatives of v with respect to x are obtained by differentiating (10). The second derivative is given in (21). The third, fourth and fifth derivatives have a similar form: vxxx = ∂ 3 g(h(x)+ζx) ∂x3 gxxx hxxx 0nx ×n3x v = xxxx ∂ 4 g(h(x)+ζx) ∂x4 gxxxx hxxxx 0nx ×n4x v = xxxxx ∂ 5 g(h(x)+ζx) ∂x5 gxxxxx hxxxxx 0nx ×n5x (37) These terms require to apply the multivariate chain rules (34)-(36) on the composite function g (h (x) + ζx). 6 Expectation of Kronecker Products High order Kronecker products of the matrices vx , vxx , . . . appear in each system. These expressions depend on the stochastic matrix ζ, so their expected value should 22 be calculated. For instance, the second order system included vx⊗2 and vxx . The expectations of these expressions were calculated through (24)-(25). In third and higher order systems, the Kronecker products get more complicated. This section provides general tools for calculating the expected value of all types of Kronecker products that appear up to a fifth order system. The first tool is notational. Expressions such as A⊗2 ⊗ B + A ⊗ B ⊗ A + B ⊗ A⊗2 are composed of all the possible permutations (without repetitions) of the Kronecker product A⊗2 ⊗B. To denote this sum more compactly I use the notation P (A⊗2 ⊗ B), which implies the sum of all permutations (excluding repetitions) of the Kronecker product A⊗2 ⊗ B. For instance, (22) can be written as: 0 1 1 ⊗2 vxx = Vxx + Vxx P (hx ⊗ ζ) + Vxx ζ . The permutation of the expression inside P (·) is not important, because all permutations are eventually included. Hence, P (A⊗2 ⊗ B) = P (B ⊗ A⊗2 ) = P (A ⊗ B ⊗ A). This notation will be particularly useful for high order derivatives of v, where the number of permutations is large. Note that the permutation operator P implies reordering of the matrices in a Kronecker product, e.g. A ⊗ B is permuted to B ⊗ A. This is different from the permutations discussed in the previous section, which applied to the columns of a matrix (or the second to last dimensions of the equivalent tensor). The second tool provides the expected value of expressions such as (Aζ)⊗k , where A is a nA × nx matrix. Using the sparse structure of ζ defined in (7) we get: 23 ⊗k E (Aζ) ⊗k = 0(nA )k ×((nx )k −1) , E (Aηǫ) ⊗k ⊗k = 0(nA )k ×((nx )k −1) , (Aη) Eǫ = 0(nA )k ×((nx )k −1) , (Aη)⊗k vec M k (38) where vec M k denotes vectorization of the k’th cross moment of ǫ. The following is a more general form: E (Aζ) ⊗ (Bζ) ⊗ (Cζ) = 0nA nB nC ×((nx )3 −1) , ((Aη) ⊗ (Bη) ⊗ (Cη)) vec M 3 . Another expression that needs to be derived is the expected value of expressions such as ζ ⊗ A ⊗ ζ. To do so, we reshape ζ ⊗ A ⊗ ζ into a 6-dimensional tensor T , where the i1 , i2 , i3 , j1 , j2 , j3 element of T is: T (i1 , i2 , i3 , j1 , j2 , j3 ) = ζ (i1 , j1 ) A (i2 , j2 ) ζ(i3 , j3 ). This tensor is a permutation of another tensor S, defined by: S (i1 , i3 , i2 , j1 , j3 , j2 ) = ζ (i1 , j1 ) ζ(i3, j3 )A (i2 , j2 ) . Tensor S can be reshaped into the matrix A ⊗ ζ ⊗2 by the mapping described in section 3. Hence, we calculate E (A ⊗ ζ ⊗2) through (38), reshape it to get ES, and permute the result to get ET . Once we have ET , it can be reshaped again to get 24 E (ζ ⊗ A ⊗ ζ). Finally, to calculate expressions such as E (Aζ) ⊗ (B (C ⊗ ζ)) use the Kronecker property (AB) ⊗ (CD) = (A ⊗ C) (B ⊗ D) to get: E (A ⊗ B) (ζ ⊗ C ⊗ ζ) , which can be calculated by the previous tool. 7 Third Order Solution A third order system is defined by: fvvv Evx⊗3 + fvv E (vx ⊗ vxx ) Ω1 + fv Evxxx = 0, (39) where (34) provides the matrix notation of the third order chain rule. The stochastic matrices are vx , vxx , vxxx . To derive Evx⊗3 and Evx ⊗ vxx , use (17) and (22): Evx⊗3 = Vx0 ⊗3 ⊗3 ⊗2 + E Vx1 ζ , + EP Vx0 ⊗ Vx1 ζ 0 1 1 ⊗2 Evx ⊗ vxx = Vx0 ⊗ Vxx + E Vx1 ζ ⊗ Vxx P (ζ ⊗ hx ) + EVx0 ⊗ Vxx ζ (40) (41) 1 ⊗2 + E Vx1 ζ ⊗ Vxx ζ . Note that the notation P Vx0 ⊗ ⊗2 (Vx1 ζ) ⊗2 implies the sum of all the permutations of the Kronecker product Vx0 ⊗ (Vx1 ζ) , as explained in section 6, namely: 25 EP Vx0 ⊗ ⊗2 Vx1 ζ = EVx0 ⊗ Vx1 ζ ⊗2 ⊗2 + E Vx1 ζ ⊗ Vx0 ⊗ Vx1 ζ + E Vx1 ζ ⊗ Vx0 . All the expectation terms can be calculated by the tools developed in section 6. To calculate Evxxx , apply a third order chain rule on the composite function g (h (x) + ζx) in order to get the first element of vxxx , which is defined in (37): ∂ 3 g (h (x) + ζx) =gxxx (hx + ζ)⊗3 + gxx ((hx + ζ) ⊗ hxx ) Ω1 + gx hxxx 3 ∂x ⊗2 ⊗2 =gxxx h⊗3 + ζ ⊗3 x + P hx ⊗ ζ + P hx ⊗ ζ (42) + gxx (hx ⊗ hxx + ζ ⊗ hxx ) Ω1 + gx hxxx . Substituting in (37) yields a third order polynomial in ζ: 0 1 1 ⊗2 1 vxxx =Vxxx + Vxxx P h⊗2 + Vxxx ζ ⊗3 x ⊗ ζ + Vxxx P hx ⊗ ζ 1 + Vxx (ζ ⊗ hxx ) Ω1 , where the new coefficients are: 26 (43) 0 Vxxx = ∂ 3 g(h(x)) ∂x3 gxxx hxxx 0 , 1 Vxxx = gxxx 0 0 0 . (44) Taking expectation yields: 0 1 1 Evxxx = Vxxx + Vxxx EP hx ⊗ ζ ⊗2 + Vxxx E ζ ⊗3 . (45) Having (40), (41) and (45), we can substitute in (39) and form a linear system in gxxx , hxxx , with the same structure as the second order system (27): (46) A + fy′ gxxx B + fy gxxx + (fx′ + fy′ gx ) hxxx = 0 3 ∂ g (h (x)) − gxxx h⊗3 A ≡ fvvv Evx⊗3 + fvv E (vx ⊗ vxx ) Ω1 + fy′ x − gx hxxx ∂x3 ⊗2 B ≡ h⊗3 + E ζ ⊗3 . x + EP hx ⊗ ζ The term ∂ 3 g(h(x)) ∂x3 − gxxx h⊗3 x − gx hxxx is the third order chain rule of g (h (x)), excluding the first and last terms which contain the unknown third order derivatives. Since a third order chain rule contains only three terms, the middle term is the only term that does not contain third order derivatives. For this particular order, the 27 notation ∂ 3 g(h(x)) ∂x3 − gxxx h⊗3 − g h x xxx is too complicated. It will be more useful for x high order solutions. Here it serves mainly to emphasize the structure of the system, which repeats also in high order solutions. 8 Fourth Order Solution A fourth order system follows from (35): fvvvv Evx⊗4 + fvvv E vx⊗2 ⊗ vxx Ω2 + fvv E (vx ⊗ vxxx ) Ω3 ⊗2 Ω4 + fv Evxxxx = 0. + fvv E vxx (47) The new expression is vxxxx . As before, apply a fourth order chain rule on g (h (x) + ζx): ∂ 4 g (h (x) + ζx) ⊗3 ⊗2 ⊗2 =gxxxx h⊗4 + P hx ⊗ ζ ⊗3 + ζ ⊗4 x + P hx ⊗ ζ + P hx ⊗ ζ 4 ∂x ⊗2 + gxxx h⊗2 ⊗ hxx Ω2 + gxx ((hx + ζ) ⊗ hxxx ) Ω3 x + P (hx ⊗ ζ) + ζ + gxx h⊗2 xx Ω4 + gx hxxxx . Substitute in (37) to express vxxxx as a fourth order Polynomial in ζ: 28 0 1 ⊗2 ⊗2 vxxxx =Vxxxx + Vxxxx P h⊗3 + P hx ⊗ ζ ⊗3 + ζ ⊗4 x ⊗ ζ + P hx ⊗ ζ 1 1 + Vxxx P (hx ⊗ ζ) + ζ ⊗2 ⊗ hxx Ω2 + Vxx (ζ ⊗ hxxx ) Ω3 , (48) where the new coefficients are: 0 Vxxxx ∂ 4 g(h(x)) ∂x4 gxxxx = h xxxx 0 , 1 Vxxxx = gxxxx 0 0 0 . (49) Substitute in (47) to get a linear system in gxxxx , hxxxx : (50) A + fy′ gxxxx B + fy gxxxx + (fx′ + fy′ gx ) hxxxx = 0 ⊗2 A ≡ fvvvv Evx⊗4 + fvvv E vx⊗2 ⊗ vxx Ω2 + fvv E (vx ⊗ vxxx ) Ω3 + fvv E vxx Ω4 4 ∂ g (h (x)) 1 + fv Vxxx E ζ ⊗2 ⊗ hxx Ω2 + fy′ − gxxxx h⊗4 x − gx hxxxx 4 ∂x ⊗2 ⊗2 B ≡ h⊗4 + EP hx ⊗ ζ ⊗3 + Eζ ⊗4 , x + EP hx ⊗ ζ ⊗2 where the expectations Evx⊗4 , Evx⊗2 ⊗ vxx , Evx ⊗ vxxx and Evxx are provided in the appendix. 29 9 Fifth Order Solution Using the fifth order chain rule, a fifth order system is given by: fvvvvv Evx⊗5 + fvvvv E vx⊗3 ⊗ vxx Ω5 + fvvv E vx⊗2 ⊗ vxxx Ω6 (51) ⊗2 + fvvv E vx ⊗ vxx Ω7 + fvv E (vx ⊗ vxxxx ) Ω8 + fvv (vxx ⊗ vxxx ) Ω9 + fv Evxxxxx = 0. The expression vxxxxx is derived from (37) by applying a fifth-order chain rule on the composite function g (h (x) + ζx): ∂ 5 g (h (x) + ζx) ⊗4 ⊗3 ⊗2 ⊗3 = gxxxxx h⊗5 + P h⊗2 + P hx ⊗ ζ ⊗4 + ζ ⊗5 x + P hx ⊗ ζ + P hx ⊗ ζ x ⊗ζ 5 ∂x ⊗2 ⊗2 ⊗2 ⊗ hxxx Ω6 + ζ ⊗3 ⊗ hxx Ω5 + gxxx h⊗2 + gxxxx h⊗3 x + P (hx ⊗ ζ) + ζ x + P hx ⊗ ζ + P hx ⊗ ζ + gxxx (hx + ζ) ⊗ h⊗2 xx Ω7 + gxx ((hx + ζ) ⊗ hxxxx ) Ω8 + gxx (hxx ⊗ hxxx ) Ω9 + gx hxxxxx . Substituting in (37) yields a fifth-order Polynomial in ζ: ⊗3 ⊗3 ⊗2 1 0 + P hx ⊗ ζ ⊗4 + ζ ⊗5 + P h⊗2 P h⊗4 vxxxxx = Vxxxxx + Vxxxxx x ⊗ζ x ⊗ ζ + P hx ⊗ ζ 1 ⊗2 1 P (hx ⊗ ζ) + ζ ⊗2 ⊗ hxxx Ω6 + ζ ⊗3 ⊗ hxx Ω5 + Vxxx P h⊗2 + Vxxxx x ⊗ ζ + P hx ⊗ ζ 1 1 ζ ⊗ h⊗2 + Vxxx xx Ω7 + Vxx (ζ ⊗ hxxxx ) Ω8 , 30 where the new coefficients are: 0 Vxxxxx ∂ 5 g(h(x)) ∂x5 gxxxxx = hxxxxx 0 , 1 Vxxxxx = gxxxxx 0 0 0 . (52) The linear system in gxxxxx , hxxxxx follows from (51): A + fy′ gxxxxx B + fy gxxxxx + fx′ + fy′ gx hxxxxx = 0 (53) ⊗2 A ≡ fvvvvv Evx⊗5 + fvvvv E vx⊗3 ⊗ vxx Ω5 + fvvv E vx⊗2 ⊗ vxxx Ω6 + fvvv E vx ⊗ vxx Ω7 1 + fvv E (vx ⊗ vxxxx ) Ω8 + fvv E (vxx ⊗ vxxx ) Ω9 + fv Vxxxx E P hx ⊗ ζ ⊗2 + ζ ⊗3 ⊗ hxx Ω5 5 ∂ g (h (x)) ⊗5 1 ⊗2 − gxxxxx hx − gx hxxxxx + fv Vxxx Eζ ⊗ hxxx Ω6 + fy′ ∂x5 ⊗3 ⊗2 ⊗3 B ≡ h⊗5 + EP h⊗2 + EP hx ⊗ ζ ⊗4 + Eζ ⊗5 . x + EP hx ⊗ ζ x ⊗ζ ⊗2 , Evx ⊗ vxxxx , Evxx ⊗ vxxx are derived where Evx⊗5 , Evx⊗3 ⊗ vxx , Evx⊗2 ⊗ vxxx , Evx ⊗ vxx in the appendix. 10 Solution Algorithm This section discusses the solution algorithm. The discussion concentrates on the second order system (27), but the same principles apply to higher order solutions, which share the same structure. The second order system can be presented as a Sylvester equation: 31 gxx gxx A+D =0 B + G hxx hxx D ≡ fy′ , 0nf ×nx G ≡ (fy , fx′ + fy′ gx ) (54) (55) (56) where D and G are nf × nf , and A and B are defined by (27). The number of conditions in this system is nf (nx )2 . In general, a k order system has nf (nx )k conditions and variables. In higher order systems this can be a very large number. To reduce the dimensions of the problem, I follow two procedures. First, the derivatives of the evolution law of the exogenous variables are calculated directly from (2) and substituted into (54), and the corresponding conditions are dropped from the system. This reduces the number of unknown derivatives to (ny + n1x ) (nx )2 . The technical details are provided in the appendix. Here I proceed with the original system (54). The second procedure, which is more substantial, is to exploit the symmetry of mixed derivatives by solving only the unique derivatives. The number of unique derivatives in a k order system is nf nx +k−1 . To extract the unique conditions from k the system, let Uk be a (nx )k × nx +k−1 matrix that extracts the unique columns of k a symmetric matrix A with (nx )k columns by the inner product AUk . In addition, define the matrix Wk with dimensions nx +k−1 × (nx )k that performs the reverse k process. It follows that AUk Wk = A. Note that this is true only if A has symmetric 32 columns, hence Uk Wk 6= I. Using these matrices, the second order system can be reduced to: AU2 + DXW2 BU2 + GX = 0 gxx X = U2 hxx (57) (58) The number of conditions in this system is nf nx (n2x +1) , and X is a matrix of the unique second derivatives. The term W2 BU2 deserves some attention. This term equals: W2 h⊗2 U2 + W2 Eζ ⊗2 U2 . x ⊗2 The size of h⊗2 is (nx )4 . In the general k order system, the corresponding x and Eζ matrices will have a size of (nx )2k , which is likely to exceed memory limits. However, these matrices do not need to be stored at full size. The second matrix is a sparse matrix with only one nonzero column. Hence, it can be stored as a sparse matrix. The first matrix is part of the expression W2 h⊗2 x U2 . This expression can be calculated without creating the big inner matrix, as shown in the appendix. The Sylsvester equation (57) can be solved in one of two ways. The first is the Bartels and Stewart algorithm, which is performed by the Matlab function lyap.m. The second is by vectorizing the system and solving a standard linear system. The Matlab codes provided by the paper allows the two options (lyap.m requires the Mat33 lab Control System Toolbox). It should be noted that vectorization consumes more memory, because it creates the matrix (W2 BU2 )T ⊗ D, which is not required in Bartels and Stewart. Nevertheless, D is sparse and the number of its nonzero elements is likely to be small. Hence, vectorization may be feasible in many applications. 11 Accuracy Tests The algorithm is tested on two models. The first model is the asset pricing model of Burnside (1998), which admits a closed form solution. The second model is an artificial model with a closed form solution but no economic meanings. 11.1 Burnside (1998) Burnside (1998) is an asset pricing model with stochastic growth rates of dividends, denoted here zt . The equilibrium condition is: pt = Et βeαzt+1 (pt+1 + 1) , (59) where pt denotes the price-dividend ratio, zt denotes the log growth of dividends and the parameters have the same meaning as in Burnside (1998). zt follows an AR process: 34 zt = (1 − ρ) µ + ρzt−1 + σǫt , (60) where ǫt is normally distributed with zero mean and unit variance. The closed-form solution derived by Burnside (1998) is: pt = ∞ X β i eai +bi (zt −µ) . (61) i=1 2i ρ 1 2 σ2 i 21 − ρ i−2 ai ≡ αiµ + α 1−ρ +ρ 2 (1 − ρ)2 1−ρ 1 − ρ2 ρ 1 − ρi . bi ≡ α 1−ρ The model has one exogenous state variable zt , one control variable pt , one shock ǫt and zero endogenous state variables, hence n1x = 0 and n2x = ny = nǫ = 1. Mapping this model into the notation of the present paper yields: zt x= , y = (pt ) , Φ (x) = (1 − ρ) µ + ρzt , η̃ = 1. σ (62) The steady state is z̄ = µ, σ = 0 and p̄ = βeαµ (1 − βeαµ ). I take the parameter values µ = 0, β = .96, α = −1, ρ = .1. To test the accuracy of the algorithm, (61) is differentiated five times with respect to x, yielding the five derivatives of the policy function of pt , which are evaluated 35 at the deterministic steady state.3 These derivatives are compared with the results produced by the algorithm. The difference across all derivatives does not exceed 1.16e-10 at absolute value. The test file is available online. 11.2 Artificial model A second accuracy test is performed on an artificial model that has no economic meaning. The artificial model is built as follows. The true policy functions are assumed to be fifth order polynomials in x (with zero constant): h (xt ) = 5 X Hi x⊗i t , g (xt ) = 5 X Gi x⊗i t , (63) i=1 i=1 where xt is defined by (1) and H1 , . . . , H5 and G1 , . . . , G5 are coefficient matrices. These matrices can have any value. The only restriction is that the last row of h (x) should be equal to σt . The steady state is x̄ = ȳ = 0, and we can calculate the derivatives of h and g at the steady state by differentiating (63). The model Ef (yt+1 , yt , xt+1 , xt ) = 0 is defined by: 3 The derivatives are sums of infinite series. These sums are approximated numerically. 36 Ext+1 + Qyt − 5 X (Hi + QGi ) x⊗i t = 0, (64) i=1 Eyt+1 − G1 5 X Hi x⊗i t −E i=1 5 X Gi x⊗i t+1 = 0, (65) i=2 where Q is a coefficient matrix of dimensions nx × ny . Its last n2x + 1 rows are zero, so that the last n2x +1 rows of (64) are the evolution law of the exogenous state variables in expected value. To verify that (63) is the solution, substitute xt+1 = h (xt )+σt ηǫt+1 and (63) in (64)-(65). Note that η does not affect the solution. This can be changed by making the matrices H1 , . . . , H5 and G1 , . . . , G5 dependent on η. But this is not necessary because we can choose any value for these matrices anyway. I pick ny = 4, n1x = 3, n2x = 2, nǫ = 5. This model has 4 control variables, 5 state variables (not including the perturbation variable) and 5 shocks. The matrices H1 , . . . , H5 , G1 , . . . , G5 , η and Q are drawn randomly. The true first derivatives are used as input for the algorithm and the results for the second to fifth derivatives are compared with their true values. The maximum absolute differences of the second, third, fourth and fifth order solutions are 7.5e-14, 1.4e-11, 4.1e-9, 1.7e-6, respectively. The decline in accuracy stems from the accumulation of rounding errors. If we use the true k − 1 derivatives to calculate a k order solution, the differences from the true derivatives for second, third, fourth and fifth order solutions are 7.5e-14, 2.9e-12, 1.3e-11, 1.7e-10. This confirms the accuracy of the algorithm. 37 12 conclusion This paper provides fourth and fifth order perturbation solutions to DSGE models, by developing a new notation. The advantage of the proposed notation is that the model is represented as a composition of two functions. Hence, all the necessary derivative conditions are obtained by applying high order multivariate chain rules with respect to a single vector variable. The solutions are implemented by a Matlab package that is available online from the Author’s website. The methods developed in this paper can be used to derive higher order solutions. Appendix A. Calculating AB ⊗k and A (B ⊗ C ⊗ D) Expressions such as AB ⊗k and and A (B ⊗ C ⊗ D) can be calculated without creating the Kronecker products, which can be very big. Details and references are given by Moravitz Martin and Van Loan (2007). As an example, take AB ⊗k , where the dimensions of B are m × n and the dimensions of A are l × mk . Reshape A into a matrix of dimensions lmk−1 × m, postmultiply by B and transpose the result. This gives a matrix of dimensions n × lmk−1 . Now, reshape the result again so that the number of columns is m and postmultiply by B and transpose. Repeat this procedure k times. The final result is a matrix of dimensions n × nk−1 l. The last step is to reshape this matrix to dimensions nk × l and transpose. This gives AB ⊗k . A similar procedure can be used to calculate A (B ⊗ C ⊗ D). 38 B. Fourth and fifth order expectation The fourth order system contains the following expectation terms: n ⊗3 ⊗4 o ⊗2 ⊗2 + P Vx0 + E P Vx0 ⊗ Vx1 ζ + Vx1 ζ ⊗ Vx1 ζ n h ⊗2 ⊗2 ⊗2 i 1 0 0 Evx⊗2 ⊗ vxx = Vx0 ⊗ Vxx + E Vx1 ζ ⊗ Vxx P (ζ ⊗ hx ) ⊗ Vxx + P Vx0 ⊗ Vx1 ζ + Vx1 ζ h o ⊗2 i ⊗2 1 ⊗2 + Vx0 ⊗ Vxx ζ + P Vx0 ⊗ Vx1 ζ + Vx1 ζ 1 0 0 1 P ζ ⊗2 ⊗ hx + Vxxx Evx ⊗ vxxx = Vx ⊗ Vxxx + E Vx0 ⊗ Vxxx ζ ⊗3 1 1 1 ⊗2 ⊗3 1 1 ⊗2 + Vx ζ ⊗ Vxxx P ζ ⊗ hx + Vxxx P ζ ⊗ hx + Vxxx ζ + Vxx (ζ ⊗ hxx ) Ω1 ⊗2 0 ⊗2 ⊗2 0 1 ⊗2 1 1 ⊗2 1 Evxx = Vxx ζ + E P Vxx ⊗ Vxx ζ P (hx ⊗ ζ) + P Vxx P (hx ⊗ ζ) ⊗ Vxx + Vxx 1 ⊗2 1 ⊗2 + Vxx ζ ⊗ Vxx ζ Evx⊗4 = Vx0 ⊗4 The fifth order system contains the following expectation terms: 39 n ⊗4 ⊗2 ⊗3 ⊗5 o ⊗3 ⊗2 + P Vx0 + E P Vx0 ⊗ Vx1 ζ + P Vx0 ⊗ Vx1 ζ + Vx1 ζ ⊗ Vx1 ζ ⊗3 ⊗3 ⊗2 1 1 ⊗2 0 1 ⊗2 P (ζ ⊗ hx ) + Vxx ζ ⊗ Vxx + E Vx0 ⊗ Vxx ζ + P Vx0 ⊗ Vx1 ζ ⊗ Vxx Evx⊗3 ⊗ vxx = Vx0 ⊗3 ⊗2 0 1 1 ⊗2 ⊗ Vxx + Vxx P (ζ ⊗ hx ) + Vxx ζ + Vx1 ζ + P Vx0 ⊗ Vx1 ζ Evx⊗5 = Vx0 ⊗5 ⊗2 1 1 0 ζ ⊗3 ⊗ Vxxx P ζ ⊗2 ⊗ hx + Vxxx ⊗ Vxxx + Vx0 1 1 1 1 (ζ ⊗ hxx ) Ω1 ζ ⊗3 + Vxx + Vxxx P ζ ⊗2 ⊗ hx + Vxxx + P Vx0 ⊗ Vx1 ζ ⊗ Vxxx P ζ ⊗ h⊗2 x ⊗2 0 1 1 1 1 (ζ ⊗ hxx ) Ω1 ζ ⊗3 + Vxx + Vxxx P ζ ⊗2 ⊗ hx + Vxxx + Vx1 ζ ⊗ Vxxx + Vxxx P ζ ⊗ h⊗2 x 1 1 ⊗2 0 1 ⊗2 0 ⊗2 ⊗2 ζ P (hx ⊗ ζ) ⊗ Vxx + P Vxx ⊗ Vxx ζ + E Vx0 ⊗ P Vxx = Vx0 ⊗ Vxx Evx ⊗ vxx 1 1 1 ⊗2 1 ⊗2 1 0 + Vxx P (hx ⊗ ζ) ⊗ Vxx P (ζ ⊗ hx ) + Vxx ζ ⊗ Vxx ζ + Vx1 ζ ⊗ P Vxx P (ζ ⊗ hx ) ⊗ Vxx ⊗2 1 ⊗2 ⊗2 1 1 1 ⊗2 0 1 ⊗2 P (ζ ⊗ hx ) + Vxx P (ζ ⊗ hx ) + Vxx ζ ⊗ Vxx + P Vxx ζ ⊗ Vxx ζ + P Vxx ⊗2 1 ⊗4 ⊗3 ⊗2 0 1 Ω ζ ⊗ h + V + ζ + P h ⊗ ζ P h⊗2 ⊗ ζ Evx ⊗ vxxxx = Vx0 ⊗ Vxxxx + E Vx0 ⊗ Vxxxx 2 xx x xxx x 1 + Vx1 ζ ⊗ Vxxxx P ζ ⊗ h⊗3 + P ζ ⊗2 ⊗ h⊗2 + P ζ ⊗3 ⊗ hx + ζ ⊗4 x x 1 1 (ζ ⊗ hxxx ) Ω3 P (hx ⊗ ζ) + ζ ⊗2 ⊗ hxx Ω2 + Vxx + Vxxx 1 0 0 0 1 Evxx ⊗ vxxx = Vxx ⊗ Vxxx + E Vxx ⊗ Vxxx P ζ ⊗2 ⊗ hx + Vxxx ζ ⊗3 1 ⊗3 1 1 ⊗2 1 1 + V (ζ ⊗ h ) Ω ζ + V + V P ζ ⊗ h + Vxx P (hx ⊗ ζ) ⊗ Vxxx P ζ ⊗ h⊗2 xx 1 x xx xxx xxx x 1 ⊗2 0 1 1 1 ⊗2 ⊗3 1 + Vxx ζ ⊗ Vxxx + Vxxx P ζ ⊗ h⊗2 + V + V P ζ ⊗ h ζ + V (ζ ⊗ h ) Ω x xx 1 x xxx xxx xx Evx⊗2 ⊗ vxxx = Vx0 ⊗2 The tools developed in section 6 enable to calculate these terms. Most expressions 1 follow a certain pattern. As an example, take the expression (Vxx P (hx ⊗ ζ)) ⊗ 1 (Vxxx P (ζ ⊗2 ⊗ hx )), which is part of Evxx ⊗ vxxx in the fifth order system. For the 1 moment, ignore the P operator (explained in section 6) and focus on (Vxx (hx ⊗ ζ)) ⊗ 40 1 (Vxxx (ζ ⊗2 ⊗ hx )). This expression can be written also as: 1 1 Vxx ⊗ Vxxx Ix ⊗ ζ ⊗3 ⊗ Ix hx ⊗ Ix⊗3 ⊗ hx , where Ix is a nx × nx identity matrix. When this expression enters the fifth order system it is premultiplied by fvv . Hence, we are ultimately interested in: 1 1 fvv Vxx ⊗ Vxxx Ix ⊗ ζ ⊗3 ⊗ Ix hx ⊗ Ix⊗3 ⊗ hx . The Matlab package contains the function permuteKron.m which calculates the expected value of terms with this structure. The stochastic part is the middle matrix, so the tools in section 6 are used to calculate the expectation. The products are performed as described in the previous section, so that large Kronecker products are not created, except for the middle matrix. But the middle matrix is highly sparse, so its memory consumption is low. The function permuteKron.m can also calculate a sum of permutations of this expression, which is required when the P operator is taken into account. These permutations reorder the three Kronecker products, but the last two Kronecker products are reordered similarly. Hence, the user has to 1 1 provide only the orders of Vxx ⊗ Vxxx and Ix ⊗ ζ ⊗3 ⊗ Ix . There are few cases that have a different structure, which are calculated separately. These include expressions that are multiplied by the Ω matrices, for instance 1 (ζ ⊗2 ⊗ hxx ) Ω2 ), which is part of Evx ⊗ vxxxx from the fifth order system. Vx ⊗ (Vxxx This expression can be written as: 41 1 Vx ⊗ Vxxx Ix ⊗ ζ ⊗2 ⊗ hxx (Ix ⊗ Ω2 ) . From here we proceed with the previous tools. C. Reducing the size of the system To reduce the size of the system, the Matlab code enables to exclude (2) from (3) so that the number of conditions reduces to nf = ny + n1x , and the unknowns are the derivatives of g and h̃ (and not h). In this case, the system (54) is replaced with: gxx gxx C +D B + G =0 h̃xx h̃xx C ≡ A + HΦxx D ≡ fyp , 0nf ×n1x where G and H are defined such that the matrix (G, H) is the first nf + n2x columns of (fy , fx′ + fy′ gx ). From here we proceed as in the main text. References [1] Andreasen, Martin M., ”On the effects of rare disasters and uncertainty shocks for risk premia in non-linear DSGE models,” Review of Economic Dynamics, 15 (2012), 295316. 42 [2] Aruoba, Borağan S., Jesús Fernández-Villaverde and Juan F. Rubio-Ramı́rez, ”Comparing solution methods for dynamic equilibrium economies,” Journal of Economic Dynamics and Control, 30 (2006), 2477-2508. [3] Benigno, Gianluca, Pierpaolo Benigno and Salvatore Nisticò, ”Second-order approximation of dynamic models with time-varying risk,” Journal of Economic Dynamics and Control, 37 (2013), 1231-1247. [4] Binning, Andrew, ”Third-order approximation of dynamic models without the use of tensors,” Working Paper Monetary Policy, Norges Bank, 2013. [5] Collard, Fabrice, Michel Juillard, ”Accuracy of stochastic perturbation methods: The case of asset pricing models,” Journal of Economic Dynamics and Control, 25 (2001), 979-999. [6] Gommea, Paul and Paul Klein, ”Second-order approximation of dynamic models without the use of tensors,” Journal of Economic Dynamics and Control 35 (2011) ,604615. [7] Judd, Kenneth L., Numerical Methods in Economics, (The MIT Press, Cambridge, Massachusetts, 1998). [8] Judd, Kenneth L. and Sy-Ming Guu, ”Asymptotic methods for aggregate growth models,” Journal of Economic Dynamics and Control, 21 (1997) 1025-1042. [9] Kim, Jinill, Sunghyun Kim, Ernst Schaumburg and Christopher A. Sims, ”Calculating and using second-order accurate solutions of discrete time dynamic equilibrium models,” Journal of Economic Dynamics and Control 32 (2008), 33973414. [10] Klein, Paul, ”Using the generalized Schur form to solve a multivariate linear rational expectations model,” Journal of Economic Dynamics and Control 24 (2000), 1405-1423. [11] Moravitz Martin, Carla D. and Charles F. Van Loan, ”Shifted Kronecker Product Systems,” SIAM Journal on Matrix Analysis and Applications, 29 (2007), 184-198. [12] Schmitt-Grohé, Stephanie and Martı́n Uribe (2004), ”Solving dynamic general equilibrium models using a second-order approximation to the policy function,” Journal of Economic Dynamics and Control, 28 (2004), 755-775. 43 [13] Ruge-Murcia, Francisco, ”Estimating nonlinear DSGE models by the simulated method of moments: With an application to business cycles,” Journal of Economic Dynamics and Control 36 (2012), 914938. 44
© Copyright 2026 Paperzz