Stochastic simulation following estimation command

Hi all,
I have a question about how stoch simul works if I put this command after doing Bayesian estimation. Ideally I would like stochastic simulation to use all the estimated parameters and perform the simulation to print theoretical moments and correlations. But I suspect, it does not do it. It basically takes the parameter values declared at the start of the mod file and ignores all the estimated parameters to do the stoch simul. Am I right?

I am attaching the mod file for your perusal.

adj_cost4_est.mod (3.2 KB)


No after the estimation command the parameter values are updated according to the inference. If you do not run a MCMC, the estimated parameters are updated to the posterior mode estimate. If you run a MCMC (mh_replic>0) the estimated parameters are updated to the posterior mean. If you find an example where this is not the case, it may be a bug on our side.


@pb2415 Note that this default behavior of setting the parameters to the estimated ones is also documented in the manual.

Hi Stephane,
Thank you for your email response to my query.
I attach a code and the datafile where stochastic simulation follows the Bayesian estimation and I see a major difference in variance decomposition results.

There is one more strange thing happening in this code which I can’t resolve. I have brought a variable iR which is fixed at irbar always. However, in variance decomposition, its variance is explained by two shocks. Since iR is a constant, its variance is zero by default. How come its variance is explained some shocks? This is very puzzling to me. I am using dynare 4.5.4…

PBboj_project_June21_Oct28_est.mod (11.5 KB)
. BoJ_Data_ready11v9inv2gov2IDclosed.xlsx (39.5 KB)

This seems to be numerical imprecision. You can see that iR is constant:

iR 0.0000 0.0000 0.0000

A general remark: your estimation results are wrong as you are not handling parameter dependence correctly. You can see that if you change

biglamda  = 1.02;     // balanced growth rate (new)

Then your steady state file will not work. See e.g.

Thank you for this comment. I am aware of this issue. However, I don’t quite see why parameter dependence is an issue here. In fact the model has a steady state at biglamda=1.02. No obvious problem is detected in model diagnostics.

The problem only occurs at the estimation level. I am setting the prior in such a way that biglamda is plausible. This is based on Japanese data and biglanda=1.02 may be too high. Thus I don’t see what is really the issue here.


m 0.951557
iL 0.0509091
k 20.635
h 1.75179
y 4.22659
c 2.31622
i 0.910368
d 1.04818
mR 0.994868
mT 0.760232
mRprop 0.566844
mm 1.03037
S 15.1376
pii 0.02
Q 1
realW 1.15811
Adj 0
Adjprime 0
P_Pw 1.33333
A 1
div 0.10784
Debt 9.82259
ytd 1.05091
Rytd 1.0303
hpr 1.05091
rhpr 1.0303
rk 0.030303
bg 0.648886
G 1
T 0.991378
lamda 0.4
Zx 1
ip 0.001
ytm2 0.0296556
Sr 22
tp 0.0198026
nytm 0.0496556
mR_d 0.949142
log_y 1.44139
log_c 0.839936
log_i -0.0939066
log_G 0
log_mR -0.0051453
log_mT -0.274131
log_d 0.0470518
log_h 0.560637
log_Q 0
log_S 2.71718
log_k 3.02699
mbgrate 1.02
y_obs 0
i_obs 0
G_obs 0
c_obs 0
mR_obs 0
mT_obs 0
d_obs 0
h_obs 0
k_obs 0
Q_obs 0
S_obs 0
MODEL_DIAGNOSTICS: No obvious problems with this mod-file were detected.

I will be grateful if you please elaborate a bit on this.

You define as independent parameters

bettastar = betta/biglamda;    // new
Omega   = (((1-bettastar*(1-deltak))/(alpha*bettastar*Abar*biglamda^-alpha ))* (eps_Y/(eps_Y-1) ) ) ^ (1/(alpha-1));

which both depend on biglamda. For the first run with biglamda=1.02, everything works fine. But in estimation, the prior mean is biglamda=1.01. As the two composite parameters above are not updated to reflect the new value for biglamda, you get an error message.

Many many thanks. You are absolutely right! I am now keeping biglamda outside the estimation loop. It is a growth rate. I am setting this beforehand.

No, you should move the two composite objects into the model block as model-local variables, because you will have the same issue with eps_Y.

You are brilliant! I see your point. Thank you.

@pb2415 Note that a bug has been found in Dynare 4.5 that can explain your variance decomposition findings:

Thanks for this. I don’t know how to merge this. I am using dynare 4.5.2.

I think I will bypass the MCMC by setting mh_replic to zero and only use mode compute and then put stochastic simulation right below it. I believe that I will then get VD based on stochastic simulation using the posterior mode estimates. This should be bug free. Am I right?



Yes, that should work. But I hope we can get a fixed version 4.5.7 out this or next week.