Replicating Dynare Outputs

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.

Replicating Dynare Outputs

Postby yadselvakumar » Thu Jan 05, 2017 2:57 pm

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
yadselvakumar
 
Posts: 3
Joined: Thu Jan 05, 2017 1:46 pm

Re: Replicating Dynare Outputs

Postby jpfeifer » Thu Jan 05, 2017 3:16 pm

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
Code: Select all
https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Smets_Wouters_2007/Smets_Wouters_2007_45.mod

you should be getting the constant of e.g.
Code: Select all
labobs

See the manual of the unstable version for details.
------------
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

Re: Replicating Dynare Outputs

Postby yadselvakumar » Thu Jan 05, 2017 4:38 pm

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:

1) I run the estimation file (solve_SW_estimation.mod) attached. And save the outputs (IRFs, FEVD, Bayesian forecasts, Smoothed Variables etc.)
2) 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
3) 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.
4) 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?
5) 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
Attachments
solve_SW_estim_pars.mod
(9.25 KiB) Downloaded 42 times
solve_SW_estimation.mod
(12.46 KiB) Downloaded 39 times
yadselvakumar
 
Posts: 3
Joined: Thu Jan 05, 2017 1:46 pm

Re: Replicating Dynare Outputs

Postby jpfeifer » Tue Jan 10, 2017 8:06 pm

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)
------------
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

Re: Replicating Dynare Outputs

Postby yadselvakumar » Tue Jan 17, 2017 3:17 pm

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
yadselvakumar
 
Posts: 3
Joined: Thu Jan 05, 2017 1:46 pm

Re: Replicating Dynare Outputs

Postby jpfeifer » Wed Jan 25, 2017 3:28 pm

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
Code: Select all
sub_draws

draws from the posterior, not all draws.
------------
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: Google [Bot] and 7 guests