We guessed that unloading the shocks from oo_.SmoothedShocks and simulating the response of the system using Dynare’s simult_.m would reproduce the time series observations used in the estimation (there are no measurement errors). Should it?

This is the first step in a particular shock-decomposition exercise. We want to simulate the response of the system to one estimated shock at a time, to see how history would have evolved with only that shock. Is there an easy way to get Dynare to do this exercise?

Here is an example, which illustrates what’s going on. Suppose you have a scalar ar: y(t) = rhoy(t-1) + eps(t), and observations on y(1), y(2). Dynare gives you the smoothed estimate of eps(1) and eps(2). The second one is obvious: epshat(2) = y(2) - rhoy(1). The first one is less obvious, but it’s based on the fact that the smoothed estimate of y(0) is rhoy(1) (you can verify this by computing the coefficients in the linear projection of y(0) onto y(1) and y(2)). Thus, epshat(1)=y(1)-rhoy(0)=y(1)-rho^2*y(1)=(1-rho^2)*y(1). When you take the smoothed estimates, epshat(1) and epshat(2), and simulate them, it’s a mistake to do this (this is what I was doing!):

yhat(1)=rho*(unconditional mean of y(0)) + epshat(1)
yhat(2)=rho*yhat(1) + epshat(2).

This will give the wrong answer, as simple substitution will verify. You get the right answer by replacing unconditional mean of y(0) with its smoothed estimate.

Another way to get the right answer is much simpler. Make the initial condition equal to the smoothed estimate of the initial condition and simulate forward using the smoothed shocks. In the example, you start with yhat(2) = rho*y(1) + epshat(2), which is obviously y(2).

In an practical model, y(t) is a vector with a subset of variables observed. But, the basic idea is the same. You find the smoothed shocks in oo_.SmoothedShocks. The smoothed y(t)'s are in oo_.SmoothedVariables (though they are re-ordered…use the indeces in dr_.inv_order_var to map to the alphabetically ordered representation of y(t)).

You can verify that by doing this simulation with all estimated shocks (use the Dynare .m file, simult_ for this simulation), you reproduce the actual data. Then, simply redo the simulation with only one shock at a time, and that’s how you get the shock decomposition. I’ve included my code for doing this, as an example

It would be neat to have a confidence tunnel around each historical shock decomposition, arising from measurement error (if included) and parameter uncertainty. My guess is that parameter uncertainty will make the confidence tunnel on individual shocks quite large, however.