Policy Functions in Third Order Approximation


I would like to read out the policy functions in the case of a third order approximation and store the results in matrices like the second order matrices ghxx, ghxu, ghuu as they are created in k_order_pert.m.

That is, I want to create the matrices ghxxx, ghxxu, ghxuu and ghuuu from the matrix g_3 created from the dll-file. For that purpose, I would need to know the variable order in the columns.

Let x=[x_1, x_2,…,x_npred] denote the predetermined states and u=[u_1, u_2,…,u_exo_nbr] the exogenous states. What is the order of variables in g_3?
Is it (for npred=3, exo_nbr=2)

g_3=[gh_x1_x1_x1, gh_x1_x1_x2 , gh_x1_x1_x3, gh_x1_x1_u1,gh_x1_x1_u2, gh_x1_x2_x2,…,gh_x3_x3_x3, gh_x3_x3_u1,…,gh_x3_u2_u2,gh_u1_u1_u1,…,gh_u2_u2_u2]

where all cross-derivatives appearing the second time are folded the way indicated in the above formula? This would be the order I infer from the second order approximation. That is, x and u are stacked in a vector, we take the first entry of the Hessian and then systematically take the derivative with respect to the elements of this stacked vector. We then follow this procedure by going through the elements of the Hessian (row major as in C, along the rows first and then along columns) and take the derivative w.r.t to the stacked vector, while ignoring all derivative already encountered.
Or is it any different, e.g. we go through the Hessian along the columns first (column major as in Matlab)? From having a short look at the C-code I could not find it out by myself. The Dynare++ manual is not very informative either.

I would also like to know what the order of variables in x is? Is there maybe any variable that already contains the ordering? For u I guess the ordering is the same as in M.exo_names?
Any help would be greatly appreciated.


I just wrote additional documentation in the reference manual, which should answer your question.

Until a new version of the reference manual is officially released, I attach here a draft version of the updated documentation. The relevant part is around page 30.

manual.pdf (484 KB)

Hi, thanks a lot, this answers my question.