by larry » Wed Jun 27, 2007 12:01 am
I figured it out!
Here is an example, which illustrates what's going on. Suppose you have a scalar ar: y(t) = rho*y(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) - rho*y(1). The first one is less obvious, but it's based on the fact that the smoothed estimate of y(0) is rho*y(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)-rho*y(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
Larry
- Attachments
-
- simtest.m
- (3.24 KiB) Downloaded 995 times
Larry Christiano