Le lundi 05 août 2019 à 10:46 +0000, Willi Mutschler a écrit :

I was wondering how I can evaluate the dynamic g4 files? That is, after running a mod file with stoch_simul(order=4) the preprocessor creates
- dynamic.m
- dynamic_g1.m; dynamic_g1_nz.m; dynamic_g1_tt.m;
- dynamic_g2.m; dynamic_g2_nz.m; dynamic_g2_tt.m;
- dynamic_g3.m; dynamic_g3_nz.m; dynamic_g3_tt.m;
- dynamic_g4.m; dynamic_g4_tt.m;

Now I can evaluate the dynamic files up to third order using:
[~, g1, g2, g3] = feval([M_.fname,'.dynamic'], oo_.dr.ys(I), oo_.exo_steady_state', M_.params, oo_.dr.ys, 1);
g3 = unfold_g3(g3, length(oo_.dr.ys(I))+length(oo_.exo_steady_state')); %add symmetric elements

What is the correct command to get g4?
[~, g1, g2, g3, g4] = feval([M_.fname,'.dynamic'], oo_.dr.ys(I), oo_.exo_steady_state', M_.params, oo_.dr.ys, 1);
is not working. Also, is g4 without symmetric elements, i.e. will I need to write something like unfold_g4.m as well?

I think the following should work:

T = NaN(sum(M_.dynamic_tmp_nbr(1:5)));
g4 = feval([M_.fname, '.dynamic_g4'], T, oo_.dr.ys(l), oo_.exo_steady_state', M_.params, oo_.dr.ys, true);

The reason why you can't use the same interface as the lower order is because simply calling the "dynamic" file to get all orders is considered deprecated (but it still works up to order 3); we did not however integrated higher order to this old interface, so you have to use the new one. Temporary terms are passed separately (in vector T) in order to save computation times.

The solution that I gave you above is not optimized in terms of temporary terms computation. If you compute g4 just after computing g1…g3, then your code could be improved by using the new interface and sharing the temporary terms (tell me if you need more details on that).

Best,

-- 
Sébastien Villemot
Economist at CEPREMAP
Dynare developer
http://sebastien.villemot.name