Question about forecasts options in estimation


Firstly, I like to know how to get out-of-sample moving window (rolling) forecasts.
Is there any option about it? Or, do I have to forecast one-by-one making 1-period-ahead data set continuously?
(I think dynare only provides recursive(expanding window) forecasts, right?)

Secondly, I just need mean forecast values, but dynare calculates HPD credible interval unnecessarily.
Is there any option to omit taking posterior subdraws? I think this will save a lot of time if there is.

Thank you in advance!


Yes, Dynare only provides expanding window forecasts. The easiest way to achieve your goal is most probably to manually loop over Dynare using a mod-file. You could do something along the lines of:

for ii=1:n_windows
data_current_window=datafull(t_start:t_end,:); % cut data to required window
save('mydata.mat',data_current_window); %save data
dynare mymodel noclearall 
clear M_ oo_ options_


where datafull is the full dataset that is put in the correct dimensions in every iteration, mydata.mat is the datafile loaded in the estimation command, and t_start and t_end need to be set before the loop at the values for the first window.

Regarding your second point: Bayesian estimation provides the mean forecast, not the forecast at the mean. Thus, you need to sample from the posterior to get this mean. It would be different if you just run estimation to get the posterior mean and then use this posterior mean to do forecasting with the forecast command.

Dear Jpfeifer

I got it. Thank you so much!


Dear Jpfeifer


I did rolling forecast manually by making different data set and run estimation one-by-one.

I corrected model slightly, and am going to do the forecast again.

However, I like to do it in a different and more convenient way.

In the last your reply, I saw some code but I didn’t use it since I couldn’t fully understand it.

Can I insert your code in a mod file? or Is there a method to run mod file repeatedly?

I again need your help.

Thank you in advance!


We are working on it. See

The required capacity should be available in tomorrow’s unstable version.

Dear Jpfeifer

Thank you so much.

I will try rolling forecast with the version.



I am knew at Dynare and because of that I am having some problems with the forecast optin on estimation.
I’m trying to make a model that tests the forecasting performance of DSGE-VAR model, using Dynare 4.3.2

In order to make it, here’s what I need:

1- I have 57 observations, and I’d like to test a 4 periods forecasting performance; (the first column of my excel sheet are the periods and the top row is the title of the colunns, so I have 57 observations on which column)
So with the observation interval [2:54) I’d like to predict the next 4 and compare with the truth value;

How should I write the estimation part? That’s what I did:
estimation(datafile=dados2, forecast = 4, nobs = [54:57], plot_priors = 0, first_obs=20,mh_nblocks=2,mh_drop=0.45,mh_jscale=0.3,dsge_var,mode_compute=4,optim=(‘NumgradAlgorithm’,3),mh_replic=2000,bayesian_irf);

I get the following error: Index exceeds matrix dimensions.

So, how can i correct it?

2 - When i write the estimation path without nobs = 54;57}, dynare runs ok. But i can’t find the matrix that saves the values of the forecasting process.
Can’t find oo_forecast anywhere.

Where can i found this values?

Thank you


Codes and datafile please. Also note

as you wish… there goes my .mod file

for some reason i haven’t been able to upload my xls file… can youhelp me with that?


Please put everything in one zip-file.

As you requested… Max (65.8 KB)

I just noticed you used 4.3.2. Please try the unstable version. It should work there.