How to use dynasave within Stochastic Simulations?

Hello everyone,

I was wondering if anyone knows how to use dynasave or any other method to save the results from stochastic simulations.

What I want is to run several simulations (let’s say 100 simulations for a sample size of 1055, dropping the first 1000) and compute averaged moments for these simulations (as it is done in the business cycles literature).

I have tried to put dynasave within the following loop, but it doesn’t work.

@#for i in 1:100
stoch_simul(periods=1055, drop=1000, nograph) gdp;
dynasave mydata;
@#endfor

Any help would be appreciated. Thanks.

Hi,

Since you save your data in the same file at each iteration, you will only have the last iteration remaining in the file at the end of the loop.

You could try to save your data in several files, using something like “dynasave mydata@{i}”. Or you can save the results of each iteration (found under the “oo_” structure), and build your own data structure.

Sébastien

Hi Sébastien,

Thanks for your answer.

Regarding my problem what I did was to write a loop as in Matlab and then save the variables at each iteration. It works well.

Thanks again,