Historical Shock decomposition in calibrated Dynare Model

Hi everyone

I have the following question: I have calibrated a Monacelli Model as attached. I would like to perform a historical shock decomposition. What is the easiest form to proceed on? Are there any built-in functions I could use?

I tried doing the following: I used the oo_dr.ghx and oo_dr.ghu

Let’s say:
A = oo_dr.ghx
B = oo_dr.ghu
sh = shocks
Y(t) = dependent variables

Y(t) = A * Y(t-1) + B * sh(t)
-> sh(t) = Y(t) - A * Y(t-1)

Then I rebuilt the variable I’m interested in by:
Y(t) = A * Y(t-1) + B * sh(t)
I do this once using all shocks (I get the data again), and then I’m doing this when sh(t) contains only one shock separately.

However, using this way, I get a problem to decompose the shocks because my dependent variables are dependent on 11 variables but I have only 8 shocks, so let’s say A is 8x11 and B is 8x11, but I can’t take any inverse of the not-square-matrix B. In the attached file I have temporary only used the 8x8 matrix for the 8 easiest observed variables, however, I think this is wrong and does not work as an approximation as the results are useless.

So if there is any easier way to do it, e.g. using any built-in function. A friend told me that the reduced form shocks should be stored in Dynare?

I would highly appreciate any help on this,

kind regards

Model_18eq_20120408v2.mod (11.8 KB)