burn_in       = 1000;
total_periods = 10000;

% 1. Run the .mod: order = 3 into the mod. file
xx = char(' ');
nfile = char('RBC_baseline.mod');  
eval(['dynare ',nfile,'  ',xx]);
% ----------
disp('Simulated values of variable c when we run the .mod')
c_idx = strmatch('c', M_.endo_names, 'exact');
c_sim(:,:) = oo_.endo_simul(c_idx, burn_in+1:total_periods);
(c_sim(:,1:5)')        
% ----------


% 2. Re-run the .mod: call option_.order and stoch_simul function outside the  mod. 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_);
% ----------
disp('Simulated values of variable c when stoch_simul is outside')
c_idx = strmatch('c', M_.endo_names, 'exact');
c_sim(:,:) = oo_.endo_simul(c_idx, burn_in+1:total_periods);
(c_sim(:,1:5)')
% ----------



disp('Re-do the same exercise with order=2 into .mod: stoch_simul(order=2,irf=40, pruning,nofunctions,nograph,noprint,periods=11000);')
disp('then, we get the same simulated path')
