Multiple Stochastic Simulations

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Multiple Stochastic Simulations

Postby dynare_m » Fri May 03, 2013 4:43 am

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
dynare_m
 
Posts: 2
Joined: Fri May 03, 2013 4:40 am

Re: Multiple Stochastic Simulations

Postby kyri82 » Fri May 03, 2013 3:14 pm

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
kyri82
 
Posts: 141
Joined: Thu Feb 10, 2011 6:14 pm
Location: Toulouse - France

Re: Multiple Stochastic Simulations

Postby dynare_m » Fri May 03, 2013 3:48 pm

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!
dynare_m
 
Posts: 2
Joined: Fri May 03, 2013 4:40 am


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 7 guests