Hi,

I am in the process of trying to replicate certain dynare outputs, such as Smoothed Variables, and Forecasts from the estimation function for the Smets and Wouters (2007) model.

When dynare estimates a model and then calculates Smoothed Variables and shocks and the forecasts for the observables, how can I see what the constant is in the measurement equation of the state space representation?

Thanks,

Yad

That depends on the mod-file. The unstable version of Dynare (Dynare 4.5) will provide the constant of all smoothed objects. When you run

you should be getting the constant of e.g.

See the manual of the unstable version for details.

So I’m using version 4.4.3, which I don’t think is the unstable version. I use the mod file attached. My procedure is as follows:

- I run the estimation file (solve_SW_estimation.mod) attached. And save the outputs (IRFs, FEVD, Bayesian forecasts, Smoothed Variables etc.)
- I then use the mh1.blck files to save all the parameter draws, from which I calculate mean Parameters values etc - this I can replicate compared to the Dynare output
- I save the parameter means and use this to run the dynare on solve_SW_estim_pars.mod (attached below). I then extract my ABCD matrices to calculate IRFs and FEVDs - this I can also replicate the output IRFs and FEVDs from Dynare estimation.
- I then use the Kalman Filter (using oo_.mean as my constant, and the ABCD matrices) to calculate smoothed estimates of the state variables - I can more-or-less replicate this up to a constant - once I demean, I get very close, but not exact. Why might this be?
- Another issue is that say take the Smoothed Variables and Shocks from the dynare output and arrange them in state-space form so that I can create my own forecasts. I cannot get the same answer as Dynare - note that it is not due to my ABCD matrices as I can calculate IRFs and FEVDs perfectly. How does dynare calculate the forecasts? Which parameter value does it use? or does it run the solver for all the draws and then calculate the mean?

Thanks,

Yad

solve_SW_estim_pars.mod (9.25 KB)

solve_SW_estimation.mod (12.5 KB)

In general the constant parts and therefore the actual smoothed objects will vary with the parameters. oo_.mean will not properly reflect this. It also seems you are neglecting Jensen’s Inequality. The smoothed objects at the mean parameter vector will be different from the mean smoother objects across parameter draws. This should also answer your last question. If you run a Metropolis-Hastings algorithm, the mean of the objects across draws is taken (the Bayesian approach)

Thank you Johannes, I think this makes sense.

When I take the mean of the posterior draws, I still get a different number to the Dynare output. I think this is because there is some filter where Dynare only chooses the draws that are consistent with a solution. Is this correct? Is there a way I can do this manually to ensure I understand what is going on?

Thanks,

Yad

Yes, only valid parameter draws are accepted, but from what you write, you rely on the draws saved by Dynare, which already reflect this restriction. About which exact objects are we now talking and how big are the differences? Because Dynare relies on

draws from the posterior, not all draws.