Stochastic simulation outside Dynare

Dear all,

I have a question regarding the stoch_simul command outside Dynare with order 3 simulation. Here is the command:

[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);

that I can use outside dynare (.mod file). I know this question has been raised here, but I have a similar issue.

1st step: I run a mod file, using the command stoch_simul(order=3, pruning, periods=11000) inside the mod file and then, I extract the simulated series (using oo_.endo_simul).

2nd step: I run a .m (matlab) file
options_.order = 3;
options_.irf = 40;
options_.nograph = true;
options_.periods = 11000;
options_.pruning = true;
options_.k_order_solver = true;
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);

and then, I extract the simulated series (still using oo_.endo_simul).

=> I get different simulated series in steps 1 and 2.

I get this issue if I do a 3rd order approximation of the model, while I’ll get the same simulated series when I do a 2nd order approximation.

Would you mind to explain what I miss and why the simulated series are different at order 3? I attach an example, based on the RBC_baseline.m available on J. Pfeifer’s codes.

Just for information, my plan is to use the outside command of stoch_simul so as to compute welfare considering a loop on parameters. This outside command would make my life easier (and faster computations)

Thanks a lot !

run_dynare.m (1.1 KB)
RBC_baseline.mod (7.0 KB)

You forgot to reset the seed. Put

set_dynare_seed('default')

before the function call to stoch_simul. Otherwise, you will be using different random numbers than when you run Dynare.

great, it works, many thanks for the quick answer!