Unable to solve the two-country DSGE model by Dynare

I construct a two-country DSGE model according to literatures. code.mod (6.8 KB)
However, I can’t solve the model by dynare, and it shows the follwing results. I don’t know whether it’s a problem of model or dynare code. Could you help me? Thinks very much!

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

Randomize initial guess…

Residuals of the static equations:

Equation number 1 : NaN : 1
Equation number 2 : NaN : k
Equation number 3 : NaN : 3
Equation number 4 : NaN : 4
Equation number 5 : NaN : 5
Equation number 6 : NaN : 6
Equation number 7 : NaN : la_y
Equation number 8 : NaN : m
Equation number 9 : NaN : mc
Equation number 10 : NaN : pi_star
Equation number 11 : NaN : x1
Equation number 12 : NaN : x2
Equation number 13 : NaN : pi
Equation number 14 : NaN : y
Equation number 15 : NaN : s
Equation number 16 : NaN : m_d
Equation number 17 : NaN : m_f
Equation number 18 : NaN : p_m
Equation number 19 : NaN : 19
Equation number 20 : NaN : k_m
Equation number 21 : NaN : la_m
Equation number 22 : NaN : 22
Equation number 23 : NaN : 23
Equation number 24 : NaN : b
Equation number 25 : NaN : re
Equation number 26 : NaN : 26
Equation number 27 : NaN : kf
Equation number 28 : NaN : 28
Equation number 29 : NaN : 29
Equation number 30 : NaN : 30
Equation number 31 : NaN : cf_d
Equation number 32 : NaN : cf_f
Equation number 33 : NaN : 33
Equation number 34 : NaN : 34
Equation number 35 : NaN : laf_y
Equation number 36 : NaN : mf_d
Equation number 37 : NaN : mcf
Equation number 38 : NaN : pf_dstar
Equation number 39 : NaN : x1f
Equation number 40 : NaN : x2f
Equation number 41 : NaN : pf_d
Equation number 42 : NaN : yf
Equation number 43 : NaN : sf
Equation number 44 : NaN : mf
Equation number 45 : NaN : kf_m
Equation number 46 : NaN : laf_m
Equation number 47 : NaN : 47
Equation number 48 : NaN : 48
Equation number 49 : NaN : bf
Equation number 50 : NaN : la
Equation number 51 : NaN : laf
Equation number 52 : NaN : 52
Equation number 53 : NaN : 53
Equation number 54 : NaN : 54
Equation number 55 : NaN : 55
Equation number 56 : NaN : 56
Equation number 57 : NaN : 57
Equation number 58 : NaN : 58
Equation number 59 : NaN : 59
Equation number 60 : NaN : 60
Equation number 61 : NaN : 61
Equation number 62 : NaN : 62
Equation number 63 : NaN : 63
Equation number 64 : NaN : 64
Equation number 65 : NaN : 65
Equation number 66 : NaN : 66
Equation number 67 : NaN : 67

use error print_info (line 32)
The steady state has NaNs or Inf.

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

error code.driver (line 867)
steady;

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

You did not give an initial value for pr, thus it is set to zero, giving you -Inf in the AR(1) process.

Think you very much. I’m a beginner of DSGE and Dynare. I still have two questions. First, “pr” denotes probability of an event, and I think the probability of this event is 0. I try to set the initial value of “pr”, but it still can’t solve the problem. Hence, I wonder how to set the initial value.
Second, what’s the meaning of the “NaNs or Inf” in the tip “The steady state has NaNs or Inf.”

Your exogenous process is

log(pr)=(1-rho_pr)*log(0.01)+rho_pr*log(pr(-1))+e_pr;

So pr=0 as an initial value will result in log(0)= Inf.
You need to set pr=0.01. After that, you will get normal residuals if you put resid before steady. Focus on those.

Thanks very much! I’ll try again.

Sorry to bother you again. I set ‘pr=0.01’ and put resid before steady, but I still solve the problem. Therefore, I have some questions to consult you.

  1. Is your meaning that the initial value should be adjusted according to the “Residuals of the static equations”?
  2. Why are there two “Residuals of the static equations” when I put resid before steady?
  3. How to set the initial value? (I I calculated the steady-state values by parameters and set them as initial value. Is it false?)

It shows following results.

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

Residuals of the static equations:

Equation number 1 : 0 : 1
Equation number 2 : 0 : k
Equation number 3 : -0.0032803 : 3
Equation number 4 : 0 : 4
Equation number 5 : 0 : 5
Equation number 6 : 0 : 6
Equation number 7 : 0 : la_y
Equation number 8 : 0 : m
Equation number 9 : 0 : mc
Equation number 10 : 0 : pi_star
Equation number 11 : 0 : x1
Equation number 12 : 0 : x2
Equation number 13 : 0 : pi
Equation number 14 : 0 : y
Equation number 15 : 0 : s
Equation number 16 : 0 : m_d
Equation number 17 : 0 : m_f
Equation number 18 : 0 : p_m
Equation number 19 : -0.047337 : 19
Equation number 20 : 0 : k_m
Equation number 21 : 0 : la_m
Equation number 22 : 0 : 22
Equation number 23 : -0.01118 : 23
Equation number 24 : 0 : b
Equation number 25 : 0 : re
Equation number 26 : 0 : 26
Equation number 27 : 0 : kf
Equation number 28 : -0.0033788 : 28
Equation number 29 : 0 : 29
Equation number 30 : 0 : 30
Equation number 31 : 0.026304 : cf_d
Equation number 32 : 0.0087681 : cf_f
Equation number 33 : 0 : 33
Equation number 34 : -3.6039 : 34
Equation number 35 : -0.0001304 : laf_y
Equation number 36 : 0 : mf_d
Equation number 37 : 0 : mcf
Equation number 38 : 0 : pf_dstar
Equation number 39 : 0 : x1f
Equation number 40 : -6.664 : x2f
Equation number 41 : 0 : pf_d
Equation number 42 : 0.16454 : yf
Equation number 43 : 0 : sf
Equation number 44 : -0.085084 : mf
Equation number 45 : 0 : kf_m
Equation number 46 : 0 : laf_m
Equation number 47 : 0 : 47
Equation number 48 : 0.078892 : 48
Equation number 49 : 0 : bf
Equation number 50 : 0 : la
Equation number 51 : 0.0001304 : laf
Equation number 52 : -0.26519 : 52
Equation number 53 : 0 : 53
Equation number 54 : -0.26519 : 54
Equation number 55 : 0.21007 : 55
Equation number 56 : 0 : 56
Equation number 57 : 0 : 57
Equation number 58 : 0 : 58
Equation number 59 : 0 : 59
Equation number 60 : 0 : 60
Equation number 61 : 0 : 61
Equation number 62 : 0 : 62
Equation number 63 : 0 : 63
Equation number 64 : 0 : 64
Equation number 65 : 0 : 65
Equation number 66 : 0 : 66
Equation number 67 : -5.9867 : 67






Residuals of the static equations:

Equation number 1 : -0.00013771 : 1
Equation number 2 : 0.0003476 : k
Equation number 3 : -2.5515e-07 : 3
Equation number 4 : 4.9449e-05 : 4
Equation number 5 : -0.0025351 : 5
Equation number 6 : 0.00048155 : 6
Equation number 7 : -1.067e-05 : la_y
Equation number 8 : -0.00010664 : m
Equation number 9 : 0.00012969 : mc
Equation number 10 : -0.00072712 : pi_star
Equation number 11 : -0.00056362 : x1
Equation number 12 : 0.0005415 : x2
Equation number 13 : -9.7606e-05 : pi
Equation number 14 : -0.00014918 : y
Equation number 15 : 0.0005078 : s
Equation number 16 : -0.00018257 : m_d
Equation number 17 : 0.00072628 : m_f
Equation number 18 : -6.0709e-05 : p_m
Equation number 19 : 4.0168e-05 : 19
Equation number 20 : -2.3444e-06 : k_m
Equation number 21 : 0.00052504 : la_m
Equation number 22 : -2.8803e-05 : 22
Equation number 23 : -0.00031566 : 23
Equation number 24 : 0 : b
Equation number 25 : 8.6139e-05 : re
Equation number 26 : 0.0012707 : 26
Equation number 27 : 0.002902 : kf
Equation number 28 : -0.00030064 : 28
Equation number 29 : 0.0013586 : 29
Equation number 30 : 0 : 30
Equation number 31 : 0.75545 : cf_d
Equation number 32 : 1.875e-05 : cf_f
Equation number 33 : -0.00014159 : 33
Equation number 34 : -0.00045556 : 34
Equation number 35 : -0.00068719 : laf_y
Equation number 36 : -0.003026 : mf_d
Equation number 37 : -0.0046906 : mcf
Equation number 38 : -0.057756 : pf_dstar
Equation number 39 : 1.257 : x1f
Equation number 40 : 1.5225 : x2f
Equation number 41 : -0.0003157 : pf_d
Equation number 42 : 0.00029861 : yf
Equation number 43 : -0.0001613 : sf
Equation number 44 : 0.00050809 : mf
Equation number 45 : 0.00039085 : kf_m
Equation number 46 : -0.00038854 : laf_m
Equation number 47 : -0.00013193 : 47
Equation number 48 : -0.0028744 : 48
Equation number 49 : 0 : bf
Equation number 50 : 0.00011809 : la
Equation number 51 : -0.00088204 : laf
Equation number 52 : -0.0034614 : 52
Equation number 53 : -0.0032204 : 53
Equation number 54 : -0.00038762 : 54
Equation number 55 : -0.0027152 : 55
Equation number 56 : 0 : 56
Equation number 57 : 0 : 57
Equation number 58 : 0 : 58
Equation number 59 : 0 : 59
Equation number 60 : 0 : 60
Equation number 61 : 0 : 61
Equation number 62 : 0 : 62
Equation number 63 : 0 : 63
Equation number 64 : 0 : 64
Equation number 65 : 0 : 65
Equation number 66 : 0 : 66
Equation number 67 : 0 : 67


false use print_info (line 32)
Impossible to find the steady state (the sum of square residuals of the static equations is 4.4721). 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

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

error code2.driver (line 869)
steady;

error dynare (line 293)
evalin('base',[fname '.driver']) ;
  1. The first set of residuals is given the initial values before numerically trying to find a steady state. The second one is after finding the steady state failed.
  2. Yes, usually you either try to modify the initial values to yield smaller residuals or the big residuals indicate problematic equations that still contain a mistake. After all, if you computed the steady state analytically and these computations were correct, you would expect the residuals to be 0.
1 Like

Thank you very much!

Dear Professor,I replaced the “initial value” with “steady_state_model” block,

code.mod (8.1 KB)
solve_yf_ss.m (636 Bytes)
but I still can’t get the steady state. I also have some questions to consult you.

  1. Can we judge whether there is a problem with the model according to the results from dynare?

  2. How to revise my model according to the residuals? Can I only modify the equation whose residual is not equal to 0?

  3. I have tagged the equations whose residuals are not 0 with “%” at the end of their code in the code.mod. Could you give me some suggestions about them?

The results are as follows.
Using 64-bit preprocessor
Starting Dynare (version 4.6.4).
Calling Dynare with arguments: none
Starting preprocessing of the model file …
Found 67 equation(s).
Evaluating expressions…done
Computing static model derivatives (order 1).
Computing dynamic model derivatives (order 1).
Processing outputs …
done
Preprocessing completed.

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the selected value of the function tolerance, and
the problem appears regular as measured by the gradient.

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the selected value of the function tolerance, and
the problem appears regular as measured by the gradient.

Residuals of the static equations:

Equation number 1 : -0.027544 : 1
Equation number 2 : 0 : k
Equation number 3 : 0 : 3
Equation number 4 : 0 : 4
Equation number 5 : 0 : 5
Equation number 6 : 0 : 6
Equation number 7 : 0 : la_y
Equation number 8 : 0 : m
Equation number 9 : 0 : mc
Equation number 10 : 0 : pi_star
Equation number 11 : -1.5378 : x1
Equation number 12 : -1.8454 : x2
Equation number 13 : 0 : pi
Equation number 14 : 0 : y
Equation number 15 : 0 : s
Equation number 16 : 0 : m_d
Equation number 17 : 0 : m_f
Equation number 18 : 0 : p_m
Equation number 19 : -0.043989 : 19
Equation number 20 : 0 : k_m
Equation number 21 : 0 : la_m
Equation number 22 : 0 : 22
Equation number 23 : -0.010214 : 23
Equation number 24 : 0 : b
Equation number 25 : 0 : re
Equation number 26 : 0 : 26
Equation number 27 : 0 : kf
Equation number 28 : 0 : 28
Equation number 29 : 0 : 29
Equation number 30 : 0 : 30
Equation number 31 : 0 : cf_d
Equation number 32 : 0 : cf_f
Equation number 33 : 0 : 33
Equation number 34 : 0 : 34
Equation number 35 : 0 : laf_y
Equation number 36 : 0 : mf_d
Equation number 37 : 0 : mcf
Equation number 38 : 0 : pf_dstar
Equation number 39 : 0 : x1f
Equation number 40 : -4.045 : x2f
Equation number 41 : 0 : pf_d
Equation number 42 : -0.034562 : yf
Equation number 43 : 0 : sf
Equation number 44 : -0.079604 : mf
Equation number 45 : 0 : kf_m
Equation number 46 : 0 : laf_m
Equation number 47 : 0 : 47
Equation number 48 : 0 : 48
Equation number 49 : 0 : bf
Equation number 50 : 0 : la
Equation number 51 : 0 : laf
Equation number 52 : -0.24724 : 52
Equation number 53 : 0 : 53
Equation number 54 : -0.24724 : 54
Equation number 55 : 0.14196 : 55
Equation number 56 : 0.071389 : 56
Equation number 57 : 0.040822 : 57
Equation number 58 : 0.051293 : 58
Equation number 59 : 0.071389 : 59
Equation number 60 : 0.040822 : 60
Equation number 61 : 0.071389 : 61
Equation number 62 : 0.040822 : 62
Equation number 63 : 0.051293 : 63
Equation number 64 : 0.071389 : 64
Equation number 65 : 0.040822 : 65
Equation number 66 : 0 : 66
Equation number 67 : 0 : 67

Error using print_info (line 32)
The steadystate file did not compute the steady state

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

Error code4.driver (line 791)
steady;

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

If you computed the steady state analytically, but the values do not go through, it means either the computed steady state values or the model equations are wrong. The problem is not necessarily in the equations with residuals, but very often. So it makes sense to focus on them. Given the size of your model, you may want to start with a simpler version that works.

Thank you very much!