Error message: The Jacobian contains Inf or NaN

Dear all,

I modified Gali and Monacelli (2005)’ small open economy model to do the policy evaluation. Thus I write the model in levels. However, I got the error message"The Jacobian contains Inf or NaN". The code is attached. Anyone can help?

Thanks in advance.code.mod (2.5 KB)

Dear Grant,

Just remove the check command before the model_diagnostics command and you will obtain more informations:

MODEL_DIAGNOSTICS: The Jacobian of the static model contains Inf or NaN. The problem arises from: 


Derivative of Equation 3 with respect to Variable s  (initial value of s: 1) 
Derivative of Equation 8 with respect to Variable s  (initial value of s: 1) 

MODEL_DIAGNOSTICS:   The problem most often occurs, because a variable with
MODEL_DIAGNOSTICS:   exponent smaller than 1 has been initialized to 0. Taking the derivative
MODEL_DIAGNOSTICS:   and evaluating it at the steady state then results in a division by 0.
MODEL_DIAGNOSTICS:   If you are using model-local variables (# operator), check their values as well.

MODEL_DIAGNOSTICS: The Jacobian of the dynamic model contains Inf or NaN. The problem arises from: 


Derivative of Equation 3 with respect to  Variable s  (initial value of s: 1) 
Derivative of Equation 8 with respect to  Variable s  (initial value of s: 1) 

MODEL_DIAGNOSTICS:   The problem most often occurs, because a variable with
MODEL_DIAGNOSTICS:   exponent smaller than 1 has been initialized to 0. Taking the derivative
MODEL_DIAGNOSTICS:   and evaluating it at the steady state then results in a division by 0.
MODEL_DIAGNOSTICS:   If you are using model-local variables (# operator), check their values as well.

An obvious problem seems to be the value of eta (which should not be equal to one)… But they are other issues after.

Best,
Stéphane.

Dear Stéphane,

Thanks for your reply. It seems that the problem comes from the calibrated values. Am I right?

In a sense yes. You are trying to run the model in a limit case with eta=1. Mathematically, that is not a problem, but numerically, the computer does not know how to handle the limit where you have a variable with (s^0)^\infty

1 Like

At least the first problem… It is not possible to have eta equal to 1 because you have terms like 1/(1-eta). If you change this, you will fix the NaNs issue, but you will see that you have other issues with the model.

Best,
Stéphane.

If you really need to consider the limit case, you’ll have to do it analytically and change the equations accordingly (i.e. change a CES like production function for a Cobb Douglas). Unfortunately Dynare cannot do this for you…

Best,
Stéphane.

Hello everyone

I am having similar problem. In my case dynare is able to solve the model and generate irf, but when I am using model_diagnostics command then it is saying that:

MODEL_DIAGNOSTICS: The Jacobian of the static model contains Inf or NaN. The problem arises from: (%%%%)
MODEL_DIAGNOSTICS: The problem most often occurs, because a variable with
MODEL_DIAGNOSTICS: exponent smaller than 1 has been initialized to 0. Taking the derivative
MODEL_DIAGNOSTICS: and evaluating it at the steady state then results in a division by 0.
MODEL_DIAGNOSTICS: If you are using model-local variables (# operator), check their values as well.

I read that such problem may come due to small bug in dynare ( I am suing 4.5.7).
I am attaching the code. I am not sure if I am doing some mistake or it is due to some small bug.

I will be thankful if someone can help me in this regard.

model2.mod (9.1 KB) model2_ss.m (3.3 KB) model2_steadystate.m (308 Bytes) param.mat (2.8 KB) param2_ss.m (2.8 KB)

Thanks
Ankit

Please upgrade to 4.6.1. There the message is gone. Here is the steady state file you will need.
model2_steadystate.m (318 Bytes)

1 Like

Dear Prof. Johannes

Thank you for your reply. Code runs without any error now.
Ankit