Loop and dynasave

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.

Loop and dynasave

Postby aless » Wed Oct 14, 2009 12:01 pm

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
aless
 
Posts: 6
Joined: Tue Sep 08, 2009 12:26 pm

Re: Loop and dynasave

Postby SébastienVillemot » Mon Oct 19, 2009 9:28 am

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,
Sébastien Villemot
Economist at OFCE – Sciences Po
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France

Re: Loop and dynasave

Postby aless » Wed Oct 21, 2009 9:56 am

Many thanks for the suggestion!

Best

Alessandro
aless
 
Posts: 6
Joined: Tue Sep 08, 2009 12:26 pm


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 15 guests