Counterfactual simulations based on smoothed shocks

Dear all,

I have a question regarding the smoother implemented in Bayesian estimation. Does dynare compute the smoothed variables conditional on the posterior mean after estimation? I am asking because I calibrated my model at the posterior mean, simulated it using stoch_simul and computed the smoothed variables using the calib_smoother command. However, the smoothed estimates differ (the differences are small but visible when I plot the two series together (see attached figure).


smoothed estimates.pdf (4.52 KB)

Hi Raoul,

After running MCMC Dynare computes the smoothed estimates of the endogenous variables at the posterior mean.


The estimation command computes the mean estimates, i.e. the average smoother results over the MCMC parameter draws. In contrast, stoch_simul after estimation computes the smoother at the mean of the parameter values. Those are two different things.

Thanks a lot for your answer.

I see your point. However, is this also true if I do not include the smoother option in the estimation command? Because then dynare also computes smoothed shocks (saved under oo_.SmoothedShocks.shockname). I thought, these might be the ones based on the posterior mean and I was reffering to these shocks (oo_.SmoothedShocks.shockname and not oo_.SmoothedShocks.Mean.shockname) when comparing them to the smoothed shocks obtained by the calib_smoother.

oo_.SmoothedShocks should only be set by the estimation command if it is used with the smoother option. Alternatively, the calib_smoother command will set it.

Hello All,
Please can you provide an example of how to use calib_smoother.
Thank you.

P.S. I would prefer if the command set up is for filtered variables please.

One example is here: The fsdat_simul.m dataset is in the Dynare examples folder.

Thank you for your help.

Apologies if this is a stupid question, but I still haven’t understood why “oo_.SmoothedVariables” and doing simult_ with oo_.SmoothedShocks generates slightly different results?

To be more clear,my procedure is as follows:

  1. Estimation/Smoother creates a sequence of oo_.SmoothedVariables, where the smoothed observables match the data perfectly
  2. It also generates oo_.SmoothedShocks. I assumed that doing simult_ with this sequence of smoothed shocks would allow me to retrieve oo_.SmoothedVariables.
  3. I eliminate the first row of oo_.SmoothedShocks, set y0=oo_.SmoothedVariables(1) and do
    simult_(y0, oo_.dr, shocks, 1)
    The output is not exactly the same as oo_.SmoothedVariables. Some of the variables are quite similar, but others are considerably different, it almost seems that one or more shocks are missing!
    I saw in other threads that some people have issues with steady state values, etc, but my model is written in log-linear form (i.e. I am writing the model so that steady states are zero for all variables) and data is detrended/demeaned before estimation.

Am I missing anything?

Try following

1 Like

Hey Johannes,
First of all, thanks a lot for taking the time to read my “complaint” and for suggesting a solution.
It seems to be working now! But I am curious as to what was the issue.

I went carefully over your file, and everything coincides with what I was doing from line 118 onwards.
The only difference (the only change I made to my code) is that I added the “smoother” option to “estimation”. Now, instead of oo_.SmoothedVariables being a structure of the kind oo_.SmoothedVariables.(varnames), it is of the kind oo_.SmoothedVariables.(yyy) where
(yyy) = {Mean, Median, Var, deciles, HPDInf, HPDSup}
and each of these in turn is of the type oo_.SmoothedVariables.(yyy).(varnames). To obtain the results that match exactly, I am using the Mean for both SmoothedVariables and SmoothedShocks.

I am very happy that this got solved, but out of curiosity, would you mind explaining what the difference is with respect to what I was doing?
I guess my question can be reframed as follows: if I do not specify the “smoother” option when estimating the model, Dynare still generates a sequence of oo_.SmoothedVariables and oo_.SmoothedShocks, where the former coincide with the data exactly for the observables. But what are these objects, exactly?

Thanks again!

My guess is that it has to do with the variable ordering of the matrix returned by the non-MCMC smoother.

Hey Johannes,
when I run , there is error in line 122 and line 131 “The cell content is derived from the non cellular array object”. So how to correct it?

The link is the file for the unstable version of Dynare, i.e. Dynare 4.6. You need

I have a question,
the draws used in the estimation, to compute the smoothed_shocks/variables, are the ones in the folder name/metropolis and then name_mh*_blck** ?
Where ** is the chain number of the MCMC.
And only the last draws in that matrix are used, since the first are burn-in sample?

  1. Yes, the draws are saved where you describe.
  2. No, Dynare uses random subdraws from these files after discarding a burn-in sample. So you cannot simply take the last draws.