Hi,
the Dynare framework assumes that all variables have at max only on lead and one lag, so our model framework is (as in Villemot (2011)):
E_t f(y_{t+1}^{+}, y_{t}, y_{t-1}^{-},u_t)
where y_{t} are the n endogenous variables, y_{t-1}^{-} the variables that appear with a lag, and y_{t+1}^{+} the variables that appear with a lead (as in the M_.lead_lag_incidence
matrix). I am wondering whether there is a neat way to represent the third-order approximation ghxxx
without the use of tensors. Here is what I mean:
First-order Approximation
It can be shown that at first-order the perturbation approach for g_y=ghx
satisfies the following equation:
0 = f_{y^+} g_y^{+} g_y^{-} + f_{y^0} g_y + f_{y^-}
where the notation follows Villemot (2011). This can be written more compactly as
0 = f_y \cdot z
where f_y is g1
, i.e the first derivative of the dynamic model, re-ordered to the DR-order, and
z =\begin{pmatrix} I\\g_y\\g_y^+ g_y^{-} \end{pmatrix}
Second-order Approximation
At second order it can be shown, see e.g. the korder documentation by Kamenik and Julliard (or the code in dyn_second_order_solver.m
) that the perturbation approach for g_{yy}=ghxx
satisfies the following equation
0 = f_{y^0} g_{yy} + f_{y^+} g_{yy}^+ (g_y^- \otimes g_y^-) + f_{y^+} g_y^+ g_{yy}^- + f_{y^-y^-} (I \otimes I) + f_{y^-y^0} (g_y \otimes I) + f_{y^-y^+} (g_y^+ g_y^- \otimes I) + f_{y^0y^-}(I \otimes g_y) + f_{y^0y^0}(g_y \otimes g_y) + f_{y^0y^+} (g_y^+ g_y^- \otimes g_y) + f_{y^+y^-} (I \otimes g_y^+ g_y^-) + f_{y^+y^0} (g_y \otimes g_y^+ g_y^-) + f_{y^+y^+} (g_y^+ g_y^- \otimes g_y^+ g_y^-)
or more compactly
0 = f_{yy} \cdot \left(z \otimes z \right) + f_y \cdot zz
where f_{yy} is g2
, i.e the first derivative of the dynamic model, re-ordered to the DR-order, and
zz=\begin{pmatrix} 0\\g_{yy}\\g_{yy}^+ (g_y^{-} \otimes g_y^{-}) + g_y^+ g_{yy}^{-} \end{pmatrix}
Third-order Approximation (HERE IS MY QUESTION)
Is there a similar compact representation? I came up with the following:
0 = f_{yyy} \cdot \left(z \otimes z \otimes z \right) + f_{yy} \cdot \left( zz \otimes z + z \otimes zz \right) + f_y \cdot zzz
where f_{yyy} is g3
, i.e the first derivative of the dynamic model, re-ordered to the DR-order, and
zzz=\begin{pmatrix} 0\\g_{yyy}\\g_{yyy}^+ (g_y^{-} \otimes g_y^{-} \otimes g_y^{-}) + g_{yy}^+ \cdot ( g_{yy}^{-} \otimes g_{y}^{-} + g_{y}^{-} \otimes g_{yy}^{-} ) + g_{y}^{+}g_{yyy}^{-} \end{pmatrix}
But when testing this with a small script file (see below) this was not correct. In the script I also have the long expression with the individual terms, but this is also not working. What (or which terms or permutations) am I missing?
Illustration CodePerturbationScript.m (9.1 KB)
I have written a small script that illustrates the above equations for any mod file after running stoch_simul(order=3)
. But unfortunately for the third-order I am doing something wrong either conceptually or in the script…
Any help would be appreciated!
Willi