Help needed! How to solve non-zero residuals of the static equations?

Hi,
As a beginner of dynare and DSGE model, when I try and run the attached mod file, it shows that 3 of the equations have non-zero residuals and 1 has NaN result. I wonder what should I do to make it right? Also, in the results, after the residuals of the static equations, it shows “randomize initial guess”, and all the residuals below it give a NaN. It shows 4 error information after the guess:
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 my.driver (line 594)
steady;

Error in dynare (line 293)
evalin(‘base’,[fname ‘.driver’]) ;
Could anyone help?
Thanks in advance!
Julius
my.mod (3.2 KB)

Hi Julius,

there are a couple of things I found. First, your parametrization of x1 leads to x1=0 and thus, in eq. 23, you divide by zero, which does not work. Second, it seems that you use log-linearized equations, thus you should use model(linear); and all steady states should be zero by definition. Also eq. 34 and 37 should be adjusted to the form of the other AR(1) processes. Then, there is still some residual in eq. 21 which I cannot find and you should probably investigate. It finally states, using model_diagnostics;, that:

MODEL_DIAGNOSTICS: The Jacobian of the static model is singular
MODEL_DIAGNOSTICS: there is 1 colinear relationships between the variables and the equations
Colinear variables:
b
b_g
tb
Colinear equations
9 11 12 13

MODEL_DIAGNOSTICS: The presence of a singularity problem typically indicates that there is one
MODEL_DIAGNOSTICS: redundant equation entered in the model block, while another non-redundant equation
MODEL_DIAGNOSTICS: is missing. The problem often derives from Walras Law.

Thus, further check all the equations used. Hope it helps :slight_smile:

Thanks a lot!!! I’ll look into it immediately!

Hi, DoubleBass,
Thanks again for the help, I rewrited equation 21 and changed values of some parameters, it worked out. All the residuals now are 0, and all steady states are 0.
Next, I changed equation 13 to avoid colinear equation problem, not quite sure wether it worked or not cause I run the code again, it shows errors as follow:
Error using print_info (line 32)
One of the eigenvalues is close to 0/0 (the absolute value of numerator and denominator is smaller
than 0.0000!
If you believe that the model has a unique solution you can try to reduce the value of
qz_zero_threshold.

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

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

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

Is it because I havn’t solve colinear variable problem? If it is, could you offer some methods for me to try? If it’s not, how can I fix this eigenvalue problem?
Thanks in advance!
Julius
PS: my.mod (3.2 KB) This is the new code.

Hi Julius,

there is still a singularity problem

MODEL_DIAGNOSTICS: The Jacobian of the static model is singular
MODEL_DIAGNOSTICS: there is 1 colinear relationships between the variables and the equations
Colinear variables:
y
k
l
w
c
i
m
h
r_l
r_f
b
b_l
b_g
d
d_f
tb
p
p_h
p_f
mu
mu_f
omega
gama
phi
Colinear equations
11 12 13

MODEL_DIAGNOSTICS: The presence of a singularity problem typically indicates that there is one
MODEL_DIAGNOSTICS: redundant equation entered in the model block, while another non-redundant equation
MODEL_DIAGNOSTICS: is missing. The problem often derives from Walras Law.

Also you do not use correct timing on capital, it should be end of period and so e.g. your production function is supposed to be written as y = a+alpha*k(-1)+(1-alpha)*l;//9
Check all the model equations for problems like that and also try to solve the singularity problem. It is almost impossible to help more in detail as only you know the model well enough to see whether an important equation was left out for example.
If you are extending a model try to start from there and only add additional things one by one to see what works.
Happy Easter :slight_smile:

Hi, DoubleBass,
Happy Easter :smile:
With your suggestion, I changed some parameters’ value and fixed several equations, then checked the mod file with model_diagnostics(M_,options_,oo_). The result is still like a puzzle to me. It doesn’t report problem of close to 0/0, but report as follow:
There are 9 eigenvalue(s) larger than 1 in modulus
for 7 forward-looking variable(s)

The rank condition ISN’T verified!

Error using print_info (line 32)
Blanchard & Kahn conditions are not satisfied: no stable equilibrium.

Error in stoch_simul (line 103)
print_info(info, options_.noprint, options_);

Error in my3.driver (line 607)
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);

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

Also, the result of model diagnostics shows that:
MODEL_DIAGNOSTICS: No obvious problems with this mod-file were detected.

Should I re-check all the equations or change the value of parameters until it work?
Thanks in advance!
Have a nice day!
Julius
PS: This is the new file.my3.mod (3.3 KB)
PS2: By the way, is it necessasy to have forward-looking variables? Cause I made another mod file that eliminate all the forward-looking variables, and eigenvalues that are larger than one reduce to 4. This is the other file.my4.mod (3.3 KB)

Yes, you should definitely recheck all your equations for timing errors. If you look at similar posts in the forum you get the idea where such errors can come from, mostly timing errors and sometimes parametrization. There should be as many eigenvalues larger than 1 as forward looking variables in your model.
It is not strictly necessary to have forward looking variables, it is your choice as the model builder to include them or not. That said, it does not really make sense to not have them in settings that we typically are interested in exploring, which we call rational expectation models. This is the whole strength of these setups, that agents are indeed forward looking and build expectations about the future. Without that you could just do a VAR analysis, which is purely backwards looking.

Thank you very much! I’m rechecking all the timing errors and might find something. It’s always good to learn something new. Thanks again for all the help you offered!

Hi, DoubleBass,
After I rechecked all the equations’ timing errors and fixed several parameters, finally I made the code run and got IRFs :smile:. Thank you very much for the help you offered!
Sincerely,
Julius

Welcome, glad that it works now :slight_smile: