Smoothed variables and shock decomposition

Hi Dynare users

Any help will be greatly appreciated, even if its just to point me in the right direction.

I am struggled to understand why the smoothed observed variables from my bayesian dsge estimation are so different from the actual observed variable data. After using the shock decomposition command I get the results for the smoothed observed variables. How would I get the shock decomposition of the actual time series?

I have searched the forum, dynare manuel and various papers but cannot seem to figure it out.

I have attached the figures of the smoothed variables, smoothed shocks and an example of the shock decomposition for y_t (I get similar looking figures for other estimations using different time series).

Best,
Hylton
yobs2009.pdf (12.6 KB)
HistoricalAndSmoothedVariables2009.pdf (5.45 KB)
SmoothedShocks2009.pdf (5.41 KB)

1 Like

I am not sure I can follow your problem. In yobs2009.pdf you can see a solid black line showing the value of the observed variable, which is identical to the one in HistoricalAndSmoothedVariables2009. Note that there are countervailing shocks, some positive, some negative. If you add all bars, you get exactly the black line.

Hi jpfeifer

Thanks for the reply. I follow exactly what you are saying.

My problem is that the smoothed variable looks nothing at all like the actual data. In fact, the smoothed variables show volatility at points in the sample period that make no sense at all:

When comparing the smoothed variables from different sample periods (i.e. the one attached is a period over the 1990-91 recession and the one from the previous post is over the 2007-09 recession) the pattern of the smoothed variable is strangely similar. At around the 10th period and from the 25th period onwards both show large volatility in the shocks. Strangely, both sample periods have a similar looking pattern when comparing all the smoothed variables and smoothed shocks.

All my results (IRFs, estimated parameters etc.) are good, so I am struggling to understand why the Kalman filter smoothes the variables and shocks in this way. This – I think – is why the historical shock decomposition over the sample period is odd.

Your guidance is greatly appreciated.

Regards,
Hylton
y_obs1990.pdf (12.9 KB)

Could it be that there is an issue with detrending? The observations are strangely increasing over time.

I use the log-difference of the data (interest rates and inflation unchanged). I do the necessary data transformations in the code: e.g. y_obs = y_t - y_t(-1) and pi_obs = pi_t + pi_ss.

Could it be that when I estimate dynare is detrending the data or I am giving an incorrect command option? Here is an example of the commands and options I give when estimating:

estimation(datafile=Estimation2013, mh_nblocks=5, mh_replic=5000, mh_drop=0.2, mh_jscale=0.375, mode_compute=0, load_mh_file, mode_file=Est2009test2_mode, moments_varendo, bayesian_irf, irf=20, conditional_variance_decomposition=[1:20], graph_format=fig) y pi i i_com i_h i_e S_com S_h S_e b l l_h l_e q_psi k_BL;

shock_decomposition y_obs pi_obs i_obs i_h_obs i_e_obs;

I have attached the .m data file I use for estimation. Perhaps you can see an error in the way I transpose the data, but as my results for IRFs and posterior estimations are good, I’m not sure its a problem.

Again, I appreciate your time.
Regards, Hylton
Estimation2013b2009.m (6.12 KB)

I am pretty sure that the reshape part is wrong. How would you get quarterly output growth of 10%?
Moreover, did you also demean your data or did you add a constant to the observation equation?

Could you perhaps indicate where you think the reshape part is wrong and post it back to me?

I agree that the almost 10% quarterly output growth of the smoothed variable is ridiculous, but the data in the .m file is correct and the only value close to 10% would be the interest rates. Again, I get the same sort of pattern across all smoothed variables and smoothed shocks; and also when using a different sample period. This lead me to think that either something is wrong with the data file (as you say) or the calculated smoothed shocks are wrong.

I did not demean the data. I used the measurement equations as shown in the previous post. There is disagreement in papers whether a constant (or trend growth) needs to be added after e.g. y_obs = y_t - y_t(-1) – but I don’t believe it makes a big difference. Surely it shouldn’t affect the smoothed variables and shocks so largely ? For example, when I compare the shock decomposition of pi_obs and pi (i.e. inflation) it is exactly the same even though the data mean is accounted for…

(sorry for the heckling, but this is grinding me that I can’t figure it out)
Hylton

Let’s step back for a second and forget about Dynare’s output. In your data file, y_obs has a 10% growth rate. Just plot it. Thus, your data is most probably wrong. I don’t know why you use reshape at all. If y_obs is in the rows, just use y_obs=data(1,:), if it is in the column, use y_obs=data(:,1).

Your observation equation has to contain a constant if you did not demean your growth rates. Otherwise your shocks must account for the growth rates being positive on average. This might massively affect your results.

Hi jpfeifer

Thank you for your patience and valuable input. I corrected the data file by removing the reshape command, and I added a constant to the measurement equations in the code for the log-differenced variables.

I ran an estimation again to check the results with my previous estimation. GOODNESS!! the problem was with the reshaping of the data! Thanks.

I have attached the data transformation of real GDP in the file below. I don’t understand why there is an issue with y_obs? I take the quarterly real GDP index data from St. Louis FRED database; convert into real GDP per capita and then take the log-difference. Thanks for the help this is the last thing I’ll ask for your help.

Regards,
Hylton
Example.xls (29.5 KB)

I think there is a misunderstanding. I was not implying that the actual data you used was wrong, but that the data in the variable y_obs as put into Dynare was wrong. You found out that the issue is the reshaping and not the data, so everything should be fine. Your new series does not feature the 10% jump.