How to fix the problem

I am estimating a DSGE model. The initial value is OK,but during the optimization process, an error message pops up:

??? Error using ==> mjdgges
MJDGGES requires two square real matrices of the same dimension.

What does it mean and how to work around it?

Hi bigbigben,

In short, there’s probably a conceptual problem in your model itself. But you can circumvent the problem in the estimation by editing dr1.m in Dynare’s matlab folder. Before line 360, add these lines:
if(any(any(imag(d))) || any(any(imag(e)))) info(1) = 2; info(2) = 666; return; end
This should allow you to estimate the model, at least to the point where you can tell where the deep problem is. (Don’t forget to use mode_check! :^)

Here is some more detail on what I think is going on. mjdgges is the function that takes your model from this form:
D * y(t+1 | t) = E * y(t) + A * eps(t)
to this form:
y(t) = B * y(t-1) + C * eps(t)
which can then be estimated, etc.

If one of the structural parameters isn’t given a numerical value, or if it’s calculated in a way that involves dividing by zero or taking the square root of a negative number, then the matrices D and E will contain “NaN” and/or “Inf” and/or complex values. Hence the complaint that it wants “real” matrices.

This is usually caused by one of two things. If it happens when you try to do impulse responses or start an estimation, then there’s probably an uninitialised parameter. (That’s easy to miss, because they’re case sensitive.) If it happens halfway through an estimation, as I guess is the case with your model, then it might be that one of the parameters has wandered into a region that doesn’t make sense. Maybe try looking for parameters that are used as powers in steady-state calculations and such, and put explicit boundaries on their priors.

Hope that helps…

Jamie