# IRFs from the ABCD state space representation

Hi everyone,

I was thinking to quickly compare the IRFs produced by dynare with the ones of the state space retrieved from the ABCD test (to make sure everything is correct). For the latter I used the integrated IRF MATLAB function for state spaces. For the IRF comparison I just used an older model of mine. As you will see there’s a big difference between dynare’s and the “my computation”.

If you just run the “compare_irfs.m” file you get the relevant plot. Most probably I can’t just use the ABCD structure to construct the irfs. Do you know where I am going wrong or should this be feasible given dynare’s state space representation? Many thanks for your help.

Rob

compare_irfsABCD.zip (11.0 KB)

Matlab’s state space uses y_t=\tilde Cx_t+\tilde D\varepsilon_t, but Dynare’s ABCD form reports y_t=Cx_{t-1}+D\varepsilon_t. With x_t=Ax_{t-1}+B\varepsilon_t you get
y_t=(\tilde CA) x_{t-1}+(\tilde CB+\tilde D)\varepsilon_t. Comparing coefficients, you should get
\tilde C=CA^{-1}
\tilde D=D-\tilde C B
However, that requires A to be invertible, which it is often not.

Hi Johannes,

Many thanks for the illustration, my hunch was that the two state space representations are slightly different. Also, I checked and as you said for the provided model the matrix A is not invertible. I have two follow up questions below:

1. Given that A is not invertible, this means if I would go ahead with Kalman filtering the ABCD representation myself, the resulting likelihood between dynare and my own computations would be different. Is this correct? Or is it only a necessary condition?
2. I know that you advise against computing the Kalman routine and MCMC ourselves. However, thought I would give it a go, as I am planning to change the resulting state space. Could you guide me where I can find dynare’s state space (A,B,C,D) representation? Correct me if I am wrong, but I remember that in some post I read that this is not easily retrievable.
1. Both representations are equivalent. You just have to correctly account for the state space representation you used in the Kalman filter.
2. What do you mean with

Note that you correctly retrieved that matrices for the Dynare state space. The only issue is that Matlab wants a different one.

change the resulting state space

as I am currently trying to apply the Kalman filter to the ABCD representation. So reading your responses the job will be to somehow match dynare’s state representation to the one from MATLAB, i.e. \tilde{C} = C A^{-1}, correct?

I still don’t what you are trying to do. You don’t want to program the Kalman filter yourself but use Matlab’s implementation?

The former is what I am trying to do, to compute the Kalman filter myself for which I would need dynare’s state space. Sorry Johannes for the cryptic messages.

You could do it brute-force by using a pseudo-inverse:

%From state space
C_tilde=C*pinv(A);
state_space = ssm(A,B,C_tilde,D-C_tilde*B) ;


compare_irfs.m (483 Bytes)
ABCD_test.m (4.6 KB)
parameterfile.mat (3.2 KB)