Error: Jacobian Contains Inf or NAN

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Error: Jacobian Contains Inf or NAN

Postby rpaul » Sun Dec 27, 2015 8:24 pm

Hi all,

My code is for 2 small open economies model with intermediate goods.

Running the model leads to the error posted at the end. I have repeatedly checked my model for issues and specified exp() for variables that have zero initial values wherever relevant. However, I continue to get this error. Any help would be greatly appreciated. My .mod file is attached.

STEADY: The Jacobian contains Inf or NaN. The problem arises from:

STEADY: Derivative of Equation 9 with respect to Variable Lambda1 (initial value of Lambda1: 20.6122)
STEADY: Derivative of Equation 10 with respect to Variable Lambda2 (initial value of Lambda2: 20.6122)
STEADY: Derivative of Equation 7 with respect to Variable Lambda3 (initial value of Lambda3: 1.1546)
STEADY: Derivative of Equation 8 with respect to Variable Lambda3 (initial value of Lambda3: 1.1546)
STEADY: Derivative of Equation 9 with respect to Variable A1 (initial value of A1: 0)
STEADY: Derivative of Equation 10 with respect to Variable A2 (initial value of A2: 0)
STEADY: Derivative of Equation 19 with respect to Variable c1 (initial value of c1: 0.2865)
STEADY: Derivative of Equation 19 with respect to Variable c2 (initial value of c2: 0.2865)
STEADY: Derivative of Equation 9 with respect to Variable n1 (initial value of n1: 0.3072)
STEADY: Derivative of Equation 10 with respect to Variable n2 (initial value of n2: 0.3072)
STEADY: Derivative of Equation 9 with respect to Variable k1 (initial value of k1: 0.39509)
STEADY: Derivative of Equation 10 with respect to Variable k2 (initial value of k2: 0.39509)
STEADY: Derivative of Equation 19 with respect to Variable y1 (initial value of y1: 0.2964)
STEADY: Derivative of Equation 19 with respect to Variable y2 (initial value of y2: 0.2964)
STEADY: Derivative of Equation 17 with respect to Variable x11 (initial value of x11: 0.3852)
STEADY: Derivative of Equation 17 with respect to Variable x12 (initial value of x12: 0.3852)
STEADY: Derivative of Equation 18 with respect to Variable x21 (initial value of x21: 0.3852)
STEADY: Derivative of Equation 18 with respect to Variable x22 (initial value of x22: 0.3852)
STEADY: Derivative of Equation 19 with respect to Variable I1 (initial value of I1: 0.0988)
STEADY: Derivative of Equation 19 with respect to Variable I2 (initial value of I2: 0.0988)
STEADY: Derivative of Equation 17 with respect to Variable y11 (initial value of y11: 0.7705)
STEADY: Derivative of Equation 18 with respect to Variable y22 (initial value of y22: 0.7705)

STEADY: The problem most often occurs, because a variable with
STEADY: exponent smaller than 1 has been initialized to 0. Taking the derivative
STEADY: and evaluating it at the steady state then results in a division by 0.
Error using dynare_solve (line 60)
An element of the Jacobian is not finite or NaN
Error in evaluate_steady_state (line 66)
[ys,check] = dynare_solve([M.fname '_static'],...
Error in steady_ (line 54)
[steady_state,params,info] =
evaluate_steady_state(oo_.steady_state,M_,options_,oo_,~options_.steadystate.nocheck);
Error in steady (line 81)
[steady_state,M_.params,info] = steady_(M_,options_,oo_);
Error in IMG2 (line 232)
steady;
Error in dynare (line 180)
evalin('base',fname) ;
Attachments
IMG2.mod
(3.14 KiB) Downloaded 183 times
rpaul
 
Posts: 1
Joined: Sun Dec 27, 2015 8:09 pm

Re: Error: Jacobian Contains Inf or NAN

Postby jpfeifer » Mon Dec 28, 2015 9:41 am

Warning: Some of the parameters have no value (a) when using steady. If these parameters are not initialized in a steadystate file or a
steady_state_model-block, Dynare may not be able to solve the model...

Please set the parameter a.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Error: Jacobian Contains Inf or NAN

Postby basilou » Wed Mar 09, 2016 11:02 pm

Dear All,

I am trying to solve a RBC model with capital, intermediate goods (even if it is not the case in the current calibration) and adjustment cost with 4 sectors. I encounter the following error:

'The Jacobian contains Inf or NaN. The problem arises from: '

I got the following output:
"
Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[no] Markov Switching SBVAR.

Starting Dynare (version 4.4.1).
Starting preprocessing of the model file ...
Found 57 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
- order 2
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.





Residuals of the static equations:

Equation number 1 : NaN
Equation number 2 : 0.84324
Equation number 3 : Inf
Equation number 4 : NaN
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0
Equation number 14 : 0
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0
Equation number 18 : 0
Equation number 19 : 0
Equation number 20 : 0
Equation number 21 : 0
Equation number 22 : -0.00047905
Equation number 23 : -0.00047905
Equation number 24 : -0.00047905
Equation number 25 : -0.00047905
Equation number 26 : -0.03163
Equation number 27 : -0.03163
Equation number 28 : -0.03163
Equation number 29 : -0.03163
Equation number 30 : 0
Equation number 31 : 0
Equation number 32 : 0
Equation number 33 : 0
Equation number 34 : 0
Equation number 35 : 0
Equation number 36 : 0
Equation number 37 : 0
Equation number 38 : 0
Equation number 39 : 0
Equation number 40 : 0
Equation number 41 : 0
Equation number 42 : 0
Equation number 43 : 0
Equation number 44 : 0
Equation number 45 : 0
Equation number 46 : 0
Equation number 47 : 0
Equation number 48 : 0
Equation number 49 : 0
Equation number 50 : 0
Equation number 51 : 0
Equation number 52 : 0
Equation number 53 : 0
Equation number 54 : 0
Equation number 55 : 0
Equation number 56 : 0
Equation number 57 : 0



STEADY: The Jacobian contains Inf or NaN. The problem arises from:

STEADY: Derivative of Equation 1 with respect to Variable i (initial value of i: 0.006425)
STEADY: Derivative of Equation 3 with respect to Variable i (initial value of i: 0.006425)
STEADY: Derivative of Equation 4 with respect to Variable i (initial value of i: 0.006425)
STEADY: Derivative of Equation 2 with respect to Variable l (initial value of l: 0)
STEADY: Derivative of Equation 1 with respect to Variable k (initial value of k: 0)
STEADY: Derivative of Equation 3 with respect to Variable k (initial value of k: 0)
STEADY: Derivative of Equation 4 with respect to Variable k (initial value of k: 0)
STEADY: Derivative of Equation 4 with respect to Variable q (initial value of q: 1)
STEADY: Derivative of Equation 3 with respect to Variable p_i (initial value of p_i: 1)

STEADY: The problem most often occurs, because a variable with
STEADY: exponent smaller than 1 has been initialized to 0. Taking the derivative
STEADY: and evaluating it at the steady state then results in a division by 0.
Error using dynare_solve (line 60)
An element of the Jacobian is not finite or NaN
"

While I am specifying initial value for the steady state, the initial value mention above are k=0 and l=0 which are different from the one I specified. This seems to be the reason why the Jacobian get NaN value.

Thanks
Attachments
foursectorsRBC.mod
(6.74 KiB) Downloaded 179 times
basilou
 
Posts: 4
Joined: Fri Sep 10, 2010 4:03 pm

Re: Error: Jacobian Contains Inf or NAN

Postby jpfeifer » Thu Mar 10, 2016 10:47 am

Use the
Code: Select all
savemacro=name nolinemacro

option to get the proprocessed file and take a hard look at it. Your initval block uses various variables that have not been specified by before and are therefore taken to be 0 at this point of the computations. For example, the z_A are set to 1 at the end of the block, but are used before. Similarly for y_A.
Make sure you can sequentially execute the initval block using F9 in Matlab after executing all parameter definitions.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Error: Jacobian Contains Inf or NAN

Postby basilou » Thu Mar 10, 2016 7:46 pm

Thanks for the response.

I found the mistake. And it was something along these lines I defined the initial value of k twice.

Best
basilou
 
Posts: 4
Joined: Fri Sep 10, 2010 4:03 pm


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 12 guests