Page 1 of 1

Loop and dynasave

PostPosted: Wed Oct 14, 2009 12:01 pm
by aless
Hi,
I loop over some parameters (following the procedure described at http://www.dynare.org/DynareWiki/HowtoLoops) and I would like to save the results for the endogenous variables at each iteration. Is there a way to do it? (dynasave only keeps the results for the last iteration).

Otherwise, is it possible to achieve this using the macrolanguage?

Many thanks!

Alessandro

Re: Loop and dynasave

PostPosted: Mon Oct 19, 2009 9:28 am
by SébastienVillemot
Hi,

I don't know what you want to save, but it should be possible anyways.

The problem with "dynasave" is that you must give it a different filename at each iteration. This is not possible using the standard "for" loop as described on the wiki page you mention.

So you must indeed use the macro-processor in that case.

Your code could look like:

Code: Select all
rhos = 0.8:0.05:1.05;
@#for i in 1:3
 rho = rhos(@{i});
 stoch_simul(order=1);
 if info;
   disp(['Computation fails for rho = ' num2str(rho)]);
 end;
 dynasave savedresults@{i};
@#endfor;


Best,

Re: Loop and dynasave

PostPosted: Wed Oct 21, 2009 9:56 am
by aless
Many thanks for the suggestion!

Best

Alessandro