Dynare Model Error - Complex Numbers and Singular Matrix in Perfect Foresight Solver

transition0519.mod (11.0 KB)
Hi Dynare Community,

I’m struggling with a perfect foresight model simulation that fails due to multiple critical issues. Here are the key symptoms from the latest logs:

​​Key Errors​​
​​Blanchard-Kahn Condition Met but Instability​​:
“8 eigenvalue(s) larger than 1 in modulus for 8 forward-looking variable(s)” with rank condition verified.
Despite matching eigenvalues/forward variables, the simulation diverges immediately.
​​Exploding Residuals and Complex Numbers​​:
Iteration 1: Residual = 6.26 → Iteration 2: ​​4.9e6​​ → Iteration 3: ​​1.6e9​​ (with Cg turning complex).
By iteration 8, residuals become Inf, and Cg remains complex in all subsequent steps.
​​Severe Numerical Instability​​:
Repeated warnings: “Matrix is singular/ill-conditioned” with extremely small RCOND values (e.g., 1.1e-23).
Linear system solver fails consistently after iteration 3.
​​Homotopy Method Completely Fails​​:
Even with lambda reduced to ​​0.00002​​, residuals plateau at ~9.5e-05 without convergence.
​​Debugging Steps Taken​​
Verified steady-state values and parameter calibrations (no negative values in logs pre-simulation).
Checked equations for Cg to avoid divisions/roots causing complex numbers.
Tried adjusting maxit, stack_solve_algo, and tolerance levels (solve_tolf), but no improvement.

I am getting a problem with

chi_b = Omega*(Rb(+1)-(1+tau_b)*R) ;
chi_g = Omega*(Rg(+1)-(1+tau_g)*R) ;
chi_b / kappa_b = chi_g / kappa_g;

as it can be simplified to

Rb(+1)=Rg(+1);

i.e. it only pins down future values, not current ones.

Hi professeur, I’ve simplified the three formulas you mentioned by replacing them with Rb(+1)=Rg(+1), removing two variables( chi_b & chi_g ). But the results remain the same (still with singular working precision and complex numbers). Did I misunderstand something? Or could you help check for other possible issues?

transition0520.mod (11.1 KB)
Here is my updated code. Thanks for your help.

is not a correct implementation as it does not determine any time t variable. Usually it should be

Rb=Rg;