Fan Chart (Predictive Density) - Forecast from a State-Space

Hello dear all,
I want to use the state space representation from a DSGE model to get fan charts (predictives densities) using dynare.
In order to do this, I need one state space, like this:

y_t = Z*alpha_t + eps_t,                 eps_ t ~ N(0,H)                     observation equation
apha_t+1 = T*alpha_t + R*eta_t,              eta_t ~ N(0,Q)             state equation

I am using notation from Koopman and Durbin: “Filtering and smoothing of state vector for difuse state space models”.
With this representation I will get several paths of forecasts by simulation, and after that I will compute percentiles of simulations to plot fan charts.

Also I am needing alpha_0 which must be the smoothed estimate in end of the sample.

My questions are:

  1. How could I retrieve Z, H, T, R and Q?, and How could I check order of variables in y_t and alpha_t? I hope to get in y_t (alpha_t) variables in the same order of declared observed variables (declared endogenous variables) in .mod.

I saw github.com/JohannesPfeifer/DSGE_mod/tree/master/FV_et_al_2007. I guess it works when it is needed decomposition in states and shocks, but I need work with observed variables too.

  1. How could I retrieve alpha_0 (smoothed estimate of alpha_t in end of the sample)?

  2. Is there another ideas to get predictive densities in dynare?

Thanks

Aldo

  1. Isn’t the forecast option of the estimation command already what you are looking for?
  2. For building the transition matrix, you are on the right track. See [How to build transition and measurement equations)
  3. For retrieving the smoothed states: they are stored in oo_.SmoothedVariables. Alternatively, you may be able to use smoother2histval (see the manual).

Thanks dear jpfeifer,
I saw the manual, and I after run my .mod I see output oo_.PointForecast.deciles. In order to plot my fan chart I would like to have output of complete simulation and not only deciles, for example I would like to compute percentiles.

I have another question, what is the dynare function which compute deciles of forecast?

And finally, I am running a DSGE-VAR, and I include forecast option in estimation command.
I would like to know if oo_.PointForecast.deciles is output of DSGE or DSGE-VAR? I ask this because I am not sure if dynare computes forecast for DSGE-VAR?

Thanks

Aldo

This is tricky.

prior_posterior_statistics_core.m

creates the forecasts.

pm3.m

computes the deciles. In principle, you can easily access the saved forecasts across draws in the metropolis-subfolder in the FILENAME_forc_point*.mat-files.

At the current stage, forecasts are from the DSGE-model, not the VAR. It is on our to-do list, but we haven’t managed to do it yet. See github.com/DynareTeam/dynare/issues/819. A year ago a user started working on it, but it went nowhere as far as I know. But maybe it is helpful: [Writtng a dsgevar_forecast function)

Thanks a lot dear jpfeifer,
Your help solve my problem.

Cheers!!

Aldo

Dear all,

Im having a hard time trying solve question 1 by Aldo - retrieving Z, H, T, R and Q (Durbin Koopman DK notation) from dynare output

I was reading all the state space representation posts, but Im still confused about the ABCD form and the one of DK notation. In ABCD_test.m, the matrix D is returned, but in my case it would be a just a identity matrix (or just a zero matrix in some cases). How to solve this issue? writing the state space matrix as DK notation using dynare output?

[A,B] = kalman_transition_matrix(oo_.dr,ipred,1:M_.nspred); works for the transition equation. but what about the observation equation

Thanks!

Have a look at

That’s it! thanks jpfeifer