stoch_simul after estimation with MH algorithm uses mode

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.

stoch_simul after estimation with MH algorithm uses mode

Postby schoderch » Thu Oct 13, 2016 7:59 pm

Hello,

I execute estimation and simulation of my model by
Code: Select all
estimation(datafile=usmodel_data,mode_compute=6,first_obs=68,nobs=176,presample=4,lik_init=2,prefilter=0,mh_replic=100000,mh_nblocks=2,mh_jscale=0.20,mh_drop=0.2,nodisplay,mode_check,bayesian_irf) y labobs pinfobs c robs rk kp k pk inve w mc gamma;

stoch_simul(conditional_variance_decomposition=[1 4 8],nodisplay) y labobs pinfobs c robs rk kp k pk inve w mc gamma dy dc dinve;

I gather from the manual and forum discussions that stoch_simul uses the posterior mean if executed after estimation that involves the Metropolis-Hastings algorithm. However, the policy and transition functions, the IRFs stored in oo_.irfs, the theoretical moments, the variance decompositions, etc. are all based on the mode.

Do I miss something obvious? If not, I'm happy to provide more details including the mod-file.

Thank you very much for your time!

Best, Christian
schoderch
 
Posts: 9
Joined: Tue Feb 17, 2015 1:07 pm

Re: stoch_simul after estimation with MH algorithm uses mode

Postby jpfeifer » Fri Oct 14, 2016 6:25 am

dynare_estimation_1.m contains the code
xparam = get_posterior_parameters('mean');
M_ = set_all_parameters(xparam,estim_params_,M_);

which sets the parameters to the mean. So I don't see how what you describe can happen. Please provide me with the files to replicate the issue.
------------
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: stoch_simul after estimation with MH algorithm uses mode

Postby schoderch » Mon Oct 17, 2016 8:33 am

Please find attached the mod file and the data file as well as the log file of my last run (for which I set the MH replications to only 2000). The problem seems to persist.

Thank you!
Attachments
files.zip
(26.37 KiB) Downloaded 103 times
schoderch
 
Posts: 9
Joined: Tue Feb 17, 2015 1:07 pm

Re: stoch_simul after estimation with MH algorithm uses mode

Postby jpfeifer » Mon Oct 17, 2016 12:44 pm

I ran your code and got the mode

RESULTS FROM POSTERIOR ESTIMATION
parameters
prior mean mode s.d. prior pstdev

crhoa 0.500 0.9604 0.0138 beta 0.2000

and from the MCMC
ESTIMATION RESULTS

Log data density is -1033.335028.

parameters
prior mean post. mean 90% HPD interval prior pstdev

crhoa 0.500 0.9574 0.9390 0.9767 beta 0.2000

When now checking the value of M_.params at the end of your mod-file I get
Code: Select all
M_.params(strmatch('crhoa',M_.param_names,'exact'))

is equal to
ans = 0.9574

which clearly is the posterior mean, not the mode.
------------
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: stoch_simul after estimation with MH algorithm uses mode

Postby schoderch » Mon Oct 17, 2016 11:17 pm

Thank you for your response!

Still, it seems to me that, after estimation, the log-file reports the policy and transition function based on the mode and the IRFs saved in oo_.irfs are based on the mode as well.

If I calibrate my model at the estimated mode and run a simple simulation, I get exactly the same policy and transition functions as well as IRFs that I get after calling stoch_simul after estimation. To verify that claim please find attached a zip-file containing:

- the mod-file of the estimated model
- the log file of running this mod file (which at the end seems to report the policy functions based on the mode)
- the mod-file of the model calibrated at the mode
- the log file of running tis mod file (which at the end reports the same policy functions as before)
- a text file containing one IRF for the simulated model (taken from the workspace) and for the estimated model (taken from oo_.irfs). They are the same.

Thank you!
Best, Chr.
Attachments
files2.zip
(22.07 KiB) Downloaded 96 times
schoderch
 
Posts: 9
Joined: Tue Feb 17, 2015 1:07 pm

Re: stoch_simul after estimation with MH algorithm uses mode

Postby jpfeifer » Tue Oct 18, 2016 12:38 pm

But the IRFs are not identical in the text-file. There are small differences. Given that the posterior mean and the posterior mode are really similar in your case, what makes you think that the mode is erroneously used?
------------
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: stoch_simul after estimation with MH algorithm uses mode

Postby schoderch » Sat Oct 22, 2016 11:11 am

I think the differences might be rounding errors. The IRFs based on the posterior mean are more different. Please find attached files that now also include the simulation for the posterior mean. Comparing the files suggests that Dynare reports, after the estimation, the IRFs and policy functions based on the mode and not the mean.

Best, Christian
Attachments
files3.zip
(28.53 KiB) Downloaded 101 times
schoderch
 
Posts: 9
Joined: Tue Feb 17, 2015 1:07 pm

Re: stoch_simul after estimation with MH algorithm uses mode

Postby jpfeifer » Mon Oct 24, 2016 12:28 pm

Can you please provide your mode-file. I still cannot replicate the issue.
------------
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: stoch_simul after estimation with MH algorithm uses mode

Postby schoderch » Tue Oct 25, 2016 12:39 am

My previous post included the file 'file3.zip'. It includes the file 'ExoG_Estimation.mod' which, after execution, produces the file 'ExoG_Estimation.log' which was also attached.

I am pretty sure that the policy and transition functions of this log-file and the IRFs saved in oo_.irfs are based on the mode and not the mean. I arrive at this conclusion after simulating the model at the mode and at the mean and comparing these to the simulation after estimation.

When you say that you cannot replicate this issue, this, then, has to mean that you get a log-file after running 'ExoG_Estimation.mod' which is different from the one I have posted. Is that the case? If this is the case I will try to run it on a different computer.

Thank you for your time!
schoderch
 
Posts: 9
Joined: Tue Feb 17, 2015 1:07 pm

Re: stoch_simul after estimation with MH algorithm uses mode

Postby jpfeifer » Tue Oct 25, 2016 7:15 am

I already got a different mode than you. Thar's why I asked for the mode-file, not the mod-file.
------------
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: stoch_simul after estimation with MH algorithm uses mode

Postby schoderch » Wed Oct 26, 2016 8:08 am

Ok, sorry I missunderstood. Attached a few files that are generated when I run ExoG_Estimation.mod including the mode file.

Thank you!
Attachments
files4.zip
(28.83 KiB) Downloaded 90 times
schoderch
 
Posts: 9
Joined: Tue Feb 17, 2015 1:07 pm

Re: stoch_simul after estimation with MH algorithm uses mode

Postby Ansgar » Tue Nov 01, 2016 5:53 pm

Hi Johannes,
many thanks for responding to Christian's post so quickly. I would just like to ad one more thing: The point Christian is making can also be seen from the ExoG_Estimation.log file included in files3.zip (which as your probably already noticed is associated with the estimation of a Smets-Wouters model). We know from the measurement equations of the model that the intercept of the Policy and Transition equation has to equal constelab. Line 182 reports approximate estimate of the mode of constelab (i.e. before the MH algorithm is started to generate the full posterior distribution), which equals 0.4142. It is thus identical to the intercept of laobs in the policy and transition function (see line 303, column 45). By contrast, the posterior mean equals 0.8987 (see line 262). The same is true for constepinf. This very much suggests that dynare is uses the (pre-MH algorithm approximation of) the posterior mode to calculate the policy and transition functions.

Let us know what you think!
Best,
Ansgar
Ansgar Rannenberg
IMK
Tel.: +49/211/7778113
Ansgar
 
Posts: 46
Joined: Tue Jun 26, 2007 11:35 am
Location: Düsseldorf

Re: stoch_simul after estimation with MH algorithm uses mode

Postby jpfeifer » Wed Nov 02, 2016 8:41 am

Which Dynare version exactly are you using?
------------
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: stoch_simul after estimation with MH algorithm uses mode

Postby Ansgar » Thu Nov 03, 2016 5:44 pm

Hi Johannes,
4.4.3 (as it says at the top of the .log file).
Best,
Ansgar
Ansgar Rannenberg
IMK
Tel.: +49/211/7778113
Ansgar
 
Posts: 46
Joined: Tue Jun 26, 2007 11:35 am
Location: Düsseldorf

Re: stoch_simul after estimation with MH algorithm uses mode

Postby jpfeifer » Sat Nov 05, 2016 11:40 am

Hi,
sorry, this took a lot longer to sort out than expected. In Dynare 4.4.3 there is indeed a bug:
ESTIMATION: Results from the smoother, which are displayed after Bayesian estimation when not specifying the smoother-option, are based on the parameters at the mode from mode-finding instead of the mean parameters from the posterior draws

It turns out that the smoother also resets the global variable to the posterior model.
If you don't want to use the unstable version, you can alter the lines
Code: Select all
        xparam = get_posterior_parameters('mean');
        M_ = set_all_parameters(xparam,estim_params_,M_);

in dynare_estimation_1.m to
Code: Select all
        xparam1 = get_posterior_parameters('mean');
        M_ = set_all_parameters(xparam1,estim_params_,M_);


I updated the description of the bug. Thanks for pointing this out.
------------
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

Next

Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 8 guests