Page 1 of 1

Multiple Stochastic Simulations

PostPosted: Fri May 03, 2013 4:43 am
by dynare_m
Hi,

I'm relatively new to dynare and was wondering whether there is a way to get multiple stochastic simulations.
I first thought that the option stoch_simul would do the trick but am not so sure anymore.

Any help is greatly appreciated!

Many thanks in advance!

Best

Re: Multiple Stochastic Simulations

PostPosted: Fri May 03, 2013 3:14 pm
by kyri82
Hi,
the stoch_simul(periods=T,....) simulates T observations from the model. However, it does that only once. What you can do is to create a loop that simulates many times, T periods. The simulated model-generated data is saved in a matrix called "oo_.endo_simul" which is a J-by-T matrix, where J is the number of endogenous variables in your model (in declaration order if I am not mistaken). What I do when I simulate a model many times, I save this matrix into matrices simulation1, simulation2, ...simulationI where I (capitl i) is the total number of simulations. Then, I save all these matrices in a .mat file and then I use matlab programms (not dynare anymore) to analyse them - e.g. correlations, variances etc. Here is how I do it:

Code: Select all
I = 1000 ; % insert the number of desired simulations
for i = 1:I ; % that simulates the model I times

var
....
varexo
...
parametres
model
...
... etc etc

stoch_simul(periods=200, irf=0, nocorr, nofunctions, nomoments)  ; % Iuse all these options to run the loop faster

eval(['simulation',num2str(i), '=oo_.endo_simul(:,:);']) ; % saves all simulated data in a matrix simulation(i), for simulation attempt i

% these commands save the matrices into a .mat file called filename. Check matlab help for "eval" and "save" and "save ... -append" if you don't know them
if i==1 ;
    eval(['save filename simulation', num2str(i), ';']);
else ;
    eval(['save filename simulation', num2str(i), ' -append;']);
end;

end; % the loop ends, goes back to "for" and re-runs the model.


Hope that helps.

Kyriacos

Re: Multiple Stochastic Simulations

PostPosted: Fri May 03, 2013 3:48 pm
by dynare_m
Hi Kyriacos,

thank you so much.
Your post is exactly what I was looking for!

Do you also know by any chance how I can simulate with starting values differing from the steady state values?

Many thanks in advance!