Writing a loop within the .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.

Writing a loop within the .mod file

Postby ACL » Tue Feb 28, 2017 11:37 pm

Hello all,

I am afraid this may be a trivial question, but I am nonetheless curious; one of the options in the "estimation" function is the starting value for the data set one is using in order to estimate the model. Another option is the length of the "window" of data. So, for example, if one has a data set of 500 observations and uses a starting value of 25 and a length of 100, only the observations #25 through 125 will be used.

I am wondering if anyone has ever written a loop within the matlab environment or even within the .mod file in order to run a routine where the "window" stays the same size, but the beginning value is incrementally increased so that a "rolling window" type of estimation is performed and after each iteration, the posterior means of specified parameters to be estimated are stored in a vector of sorts?

Has anyone ever done anything remotely similar to this, and if so, do you mind posting your code?
ACL
 
Posts: 8
Joined: Sat Nov 28, 2015 4:00 am

Re: Writing a loop within the .mod file

Postby jpfeifer » Tue Mar 07, 2017 12:32 pm

You would need to call
Code: Select all
estimation

once and then in the mod-file start looping. Code would work along the lines of
Code: Select all
verbatim;
for obs_iter=1:10
options_.first_obs = 10+obs_iter;
options_.nobs = 192;
dname=[M_.fname,'_',num2str(obs_iter)];
oo_recursive_=dynare_estimation(var_list_,dname);
end
end;

I tried this code with the unstable version of Dynare and the fs2000.mod. It increases the first observation used, starting from observation 11 and saves the results in a separate folder with the constructed
Code: Select all
dname

However, for the latter to work, one needs to fix https://github.com/DynareTeam/dynare/pull/1399
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 7 guests