loop in a mod file

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 in a mod file

Postby Aqua » Wed Sep 10, 2008 9:21 am

Dear all,

I want to estimate a bvar, using the bvar a la sims toolkit over a given sample and i want to reestimate it every quarter, as Smets and Wouters do in their aer (2007) paper. As an example in my do file, i try something like :

for i = 1:100
bvar_density(datafile = mydata, first_obs = myfirstobs, bvar_prior*, presample, nobs = 44 + i-1 (for instance))
end

I get an error message since dynare does not expect the "+" and the "-" in the options. Is there any way to solve the problem?

I would greatly appreciate your help.

Aqua!
Aqua
 
Posts: 7
Joined: Sun Sep 23, 2007 8:50 am

Postby SébastienVillemot » Mon Sep 15, 2008 1:14 pm

For only 100 iterations, you can use the new macro-language which was introduced recently in Dynare.

Install Dynare 4.0.0, and replace your code by the following:

@#for i in 1:100
bvar_density(datafile = mydata, first_obs = myfirstobs, ..., presample, nobs = @{44+i-1})
@#end

For more information on the macro-language, have a look at the file "macroprocessor.pdf" distributed in the archive for Dynare 4.0.0, or go to:

http://www.dynare.org/manual/ch04s14.html

Best

SV


NB: * new url
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France

Postby Aqua » Tue Sep 16, 2008 3:54 pm

Thanks Sebastien for the reply and for this new macroprocessor. But I woul like to add just a little correction : "@#end" does'nt work but "@endfor" does.

I have appreciated your help.

Aqua
Aqua
 
Posts: 7
Joined: Sun Sep 23, 2007 8:50 am


Return to Dynare help

Who is online

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