Error : Residuals of the static equations contains all NaN

Hi there, I have been trying to implement Tesar (1992) International Risk-Sharing and Non-tradable goods (Paper here) as a Dynare model (Tesar.mod (2.1 KB) ) and I’ve been running in multiple issues.

Now that I’ve passed the pre-processing, my model returns this Residuals of the static equations:

Equation number 1 : NaN : 1
Equation number 2 : NaN : iT
Equation number 3 : NaN : iTstar
Equation number 4 : NaN : iNT
Equation number 5 : NaN : iNTstar
Equation number 6 : NaN : 6
Equation number 7 : NaN : 7
Equation number 8 : NaN : AT
Equation number 9 : NaN : ANT
Equation number 10 : NaN : ATstar
Equation number 11 : NaN : ANTstar
Equation number 12 : NaN : 12
Equation number 13 : NaN : 13
Equation number 14 : NaN : 14
Equation number 15 : NaN : 15
Equation number 16 : NaN : 16

Error using print_info (line 32)
The steady state has NaNs or Inf.

Error in steady (line 102)
print_info(info,options_.noprint, options_);

Error in paper.driver (line 290)
steady;

Error in dynare (line 293)
evalin(‘base’,[fname ‘.driver’]) ;

I’m unsure about the equations on lines 45 and 49 and about how to deal with the shocks as I’m given an autoregression of 0.5 and a Variance-covariance matrix on the shocks but no information on the error terms.

I’ve been reading lots of paper and exemples here, but I feel there is just something I’m missing.

1 Like

Additional point : I’m trying to replicate part 4 of the model

You are using a nonlinear model, so you must provide initial values for all variables that cannot be 0.

How can I set realistic initial values for the model ?

I’ve always been given the initial values when we had to specify them, so I wonder how I could find them.

@jpfeifer Following your advice, I’ve tried to calculate a steady state K and tried to input it and put arbitrary values for the rest of the variables.

I know I’m missing something as the code returns this :

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.950279e-19.

In trust_region>dogleg (line 198)
In trust_region (line 115)
In dynare_solve (line 255)
In evaluate_steady_state (line 221)
In steady_ (line 55)
In steady (line 80)
In paper.driver (line 293)
In dynare (line 293)

STEADY-STATE RESULTS:

c 3.87487
cstar 3.87487
d 12.3996
dstar 12.3996
ktrade 4158.36
ktradeN -123.996
ktradestar -4235.86
ktradestarN -123.996
iT 415.836
iTstar -423.586
iNT -12.3996
iNTstar -12.3996
AT 2.22045e-16
ANT 0
ATstar 2.22045e-16
ANTstar 0
Error using print_info (line 32)
The Jacobian matrix evaluated at the steady state contains elements that are not real or are infinite.

Error in check (line 48)
print_info(info, 0, options);

Error in paper.driver (line 294)
oo_.dr.eigval = check(M_,options_,oo_);

Error in dynare (line 293)
evalin(‘base’,[fname ‘.driver’]) ;

So I’m pretty sure I’m making either a major mistake or there is something I simply don’t understand.

Please provide the updated version.

@jpfeifer

Here is the updated code (Tesar.mod (2.2 KB) )

I had calculated a golden ratio K and Kss but I’m not sure they were actually the right one or useful in this case.

Thanks a million for your help, as a beginner in Dynare, it is often a daunting task to take it on.

Also she specifies in the paper that each economy grows at 3% yty and I haven’t included that in the code as of yet, could that be a reason of the problem, if so, how should I go about to do that ?

Your exogenous processes are mean 0:

AT(1) =  cAT*AT+epsilon;
ANT(1) = cANT*ANT + epsilonNT;
ATstar(1) = cATstar *ATstar + epsilonstar;
ANTstar(1) = cANTstar *ANTstar + epsilonNTstar;

which does not work in the other equations as then output is 0. Also the timing is strange.
It should most probably be e.g.

log(AT) =  cAT*log(AT(-1))+epsilon;

@jpfeifer

Ive fixed the timing of the shocks but it seems that the AR process mean being zero is the main problem. I have no idea how to go about and fix that. Do you have suggestions ?

In the paper they say the disturbances to technology is defined by vector st = (AT, ANT,ATstar, ANTstar)
st(+1) = omegamatrix *st + epsilon

Which is what I used as the AR process equations

I’m given the omega matrix and a variance co-variance matrix such that

omegamatrix = [ 0.23, -0.41, 0.09, -0.06; -0.12, 0.32, -0.08, 0.15; 0.09, -0.06, 0.23, -0.41; -0.08, 0.15,0.12, 0.32]

V(A) = [7.06, 2.37, 2.48, 0.9; 2.37,3.30,0.9,0.34,2.48,0.90,7.06,2.37;0.9,0.34,2.37,3.3]

Later in the paper she talks about the change in productivity is defined as

AThat = YThat-(thetaT)*KThat

where theta is the estimated capital share in each sector and the hats denotes changes in the log.

Maybe the answer is somewhere in there ?

I already gave you the answer: the process must be in logs.

@jpfeifer

You were absolutely right, I had fixed the equations as you suggested by didnt test on the right version. Once I had my coffee and got into it, saw where i made my rookie mistake and fixed it.

Now I’m not getting the previous error messages, but I’m getting this.

Residuals of the static equations:

Equation number 1 : 0.070422 : 1
Equation number 2 : -0.0080257 : iT
Equation number 3 : 0.0044815 : iTstar
Equation number 4 : -0.11755 : iNT
Equation number 5 : -0.17082 : iNTstar
Equation number 6 : -0.076763 : 6
Equation number 7 : -0.14645 : 7
Equation number 8 : 0 : 8
Equation number 9 : 0 : 9
Equation number 10 : 0 : 10
Equation number 11 : 0 : 11
Equation number 12 : -0.058655 : 12
Equation number 13 : 0.1958 : 13
Equation number 14 : 0.041915 : 14
Equation number 15 : 0.082017 : 15
Equation number 16 : 0.11171 : 16

Error using print_info (line 32)
Impossible to find the steady state (the sum of square residuals of the static equations is 0.1381). Either the model doesn’t have a steady state, there are an infinity of
steady states, or the guess values are too far from the solution

So we are back to my initial value problem or is there a more profound problem ?

Please provide the most recent version.

Here’s the updated file : Tesar.mod (2.4 KB)

Please note I have added some covariance between the errors terms but tested and got the same result with or without that added part from the initial model file on this thread.

@jpfeifer Got any pointers ? For the question above, about my residual values ? I’ve been looking at stackoverflow and this forum looking for an answers for a couple days to no avail.

Tesar.mod (2.5 KB) finds a steady state, but it is an obviously wrong one. You should check whether all equations are coded correctly. Try using Dynare’s \LaTeX-capabilities for that.

So declaring my equations in latex or just trying to check if my equation are ok in latex ?

\LaTeX-code is more easily readable and facilitates debugging. You can often better spot mistakes in that output.

I used write_latex_original_model; to output the latex version of the code.

The only weird thing I see in the equations is that they’re all missing the multiplication operator, but I think it just might be automatic for variables.

Having passed through all of them, I do not find what could be the issue.

I have attached the latex output, and will keep trying things out, until this works.
original_content.tex.zip (658 Bytes)

I did just that and I’m getting something weird. I rewrote the euler equations and verified that the latex output was just as I wanted it.

Before changing the euler I got this :

Residuals of the static equations:

Equation number 1 : 0.00016013 : 1
Equation number 2 : -1.6975e-05 : 2
Equation number 3 : -3.2286e-05 : 3
Equation number 4 : 9.8123e-05 : iT
Equation number 5 : 0.00018538 : iTstar
Equation number 6 : -4.0936e-05 : iNT
Equation number 7 : -7.7857e-05 : iNTstar
Equation number 8 : -4.5743e-06 : 8
Equation number 9 : -8.9568e-07 : 9
Equation number 10 : -1.0471e-06 : 10
Equation number 11 : -2.5698e-07 : 11
Equation number 12 : 1.7533e-07 : 12
Equation number 13 : 7.3096e-08 : 13
Equation number 14 : 1.2089e-06 : 14
Equation number 15 : 0 : 15
Equation number 16 : 2.3023e-06 : 16

Error using print_info (line 32)
Impossible to find the steady state (the sum of square residuals of the static equations is 0.0000). Either the model doesn’t have a steady state, there are an infinity of
steady states, or the guess values are too far from the solution

After changing my Euler and looking at latex to ensure I have fitted everything correctly I get this :

Using 64-bit preprocessor
Starting Dynare (version 4.6.2).
Calling Dynare with arguments: none
Starting preprocessing of the model file …
Found 16 equation(s).
Evaluating expressions…done
Computing static model derivatives (order 1).
Computing dynamic model derivatives (order 2).
Processing outputs …
done
Preprocessing completed.

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 6.847971e-17.

In trust_region>dogleg (line 198)
In trust_region (line 115)
In dynare_solve (line 255)
In evaluate_steady_state (line 221)
In steady_ (line 55)
In steady (line 80)
In bleh.driver (line 304)
In dynare (line 293),

(many more lines like that)

Residuals of the static equations:

Equation number 1 : 0.00022042 : 1
Equation number 2 : -0.00053491 : 2
Equation number 3 : 1.405041487924941e+58 : 3
Equation number 4 : -7.4575e-05 : iT
Equation number 5 : -7.1794e-05 : iTstar
Equation number 6 : -0.00097196 : iNT
Equation number 7 : -0.03 : iNTstar
Equation number 8 : -4.5743e-06 : 8
Equation number 9 : -8.9568e-07 : 9
Equation number 10 : -1.0471e-06 : 10
Equation number 11 : -2.5698e-07 : 11
Equation number 12 : 3.975e-05 : 12
Equation number 13 : 3.6093e-06 : 13
Equation number 14 : -0.0089419 : 14
Equation number 15 : 0 : 15
Equation number 16 : 0 : 16

Error using print_info (line 32)
Impossible to find the steady state (the sum of square residuals of the static equations is
197414158279033195373755462748852588238507181033207763651186978144599868534914674246521121639061763199998962945753088.0000). Either the model doesn’t have a steady state,
there are an infinity of steady states, or the guess values are too far from the solution

So obviously here I’ve gone from residual errors of 0.000000 to nearly infinity. Could this be because I have a typo for a exponent somewhere making it going a different path ?

Really looking forward to finding what’s my stupid error.