Page 1 of 2
stoch_simul after estimation with MH algorithm uses mode
Posted:
Thu Oct 13, 2016 7:59 pm
by schoderch
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
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Fri Oct 14, 2016 6:25 am
by jpfeifer
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.
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Mon Oct 17, 2016 8:33 am
by schoderch
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!
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Mon Oct 17, 2016 12:44 pm
by jpfeifer
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.
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Mon Oct 17, 2016 11:17 pm
by schoderch
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.
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Tue Oct 18, 2016 12:38 pm
by jpfeifer
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?
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Sat Oct 22, 2016 11:11 am
by schoderch
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
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Mon Oct 24, 2016 12:28 pm
by jpfeifer
Can you please provide your mode-file. I still cannot replicate the issue.
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Tue Oct 25, 2016 12:39 am
by schoderch
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!
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Tue Oct 25, 2016 7:15 am
by jpfeifer
I already got a different mode than you. Thar's why I asked for the mode-file, not the mod-file.
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Wed Oct 26, 2016 8:08 am
by schoderch
Ok, sorry I missunderstood. Attached a few files that are generated when I run ExoG_Estimation.mod including the mode file.
Thank you!
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Tue Nov 01, 2016 5:53 pm
by Ansgar
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
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Wed Nov 02, 2016 8:41 am
by jpfeifer
Which Dynare version exactly are you using?
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Thu Nov 03, 2016 5:44 pm
by Ansgar
Hi Johannes,
4.4.3 (as it says at the top of the .log file).
Best,
Ansgar
Re: stoch_simul after estimation with MH algorithm uses mode
Posted:
Sat Nov 05, 2016 11:40 am
by jpfeifer
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.