Simult_ results different with loop

Dear all, I compared two simulations both computed with simult_ using the same shocks. In one computation I use simult_ to compute the whole series directly, in the other I loop over time, and call simult_ in every period. The results for the two methods are different, but only for order 3 (not order 1 or 2), and I don’t understand why.

Ex_ = randn(5,1);

% METHOD 1: standard
y0 = oo_.dr.ys;
[Y3] = simult_(M_,options_,y0,oo_.dr,Ex_,3);

% METHOD 2: loop over time
Y3_iter = NaN(5,size(Ex_,1)+1);
Y3_iter(:,1) = oo_.dr.ys;
for it = 1:size(Ex_,1)
[Y3_n] = simult_(M_,options_,Y3_iter(:,it),oo_.dr,Ex_(it),3);
Y3_iter(:,it+1) = Y3_n(:,2);

The results of Y3 and Y3_iter are different (but only for order 3).

First: what could theoretically cause this difference? I mean, I assumed simult_ would internally do something similar to METHOD 2.

Second: what is the actual cause in my case? There is a difference in the stochastic variable (third row), after the second period (from third column in Y3), so I assume all differences are related to this. This difference does not occur when I do the same for an order 1 or 2 approximation.

I have included all files to replicate these results. Any help will be greatly appreciated! (2.8 KB)

Unfortunately, this looks like a bug. It will take a few days to properly investigate. Thanks for reporting this.

Thank you very much!

Here is the related ticket: Fix bug in mex k-order-simulations (i.e. without pruning) (#1819) · Issues · Dynare / dynare · GitLab