Hi, I’m currently working on the model by Kirchner & Van Wijnbergen (2016), and I intend to adapt it to the context of epidemics/Covid-19 for which I have included an external process from Acurio-Vasconez (2021) that exogenously determines the labor supply. Hence, the model is deterministic and is solved w/ perfect foresight. I’ve solved the steady-state analytically and followed the original code closely, yet somehow this problem keeps occurring. I’ve double-checked the equations and can’t seem to find anything wrong.
MODEL SIMULATION:
Warning: Matrix is singular to working precision.
In sim1_linear (line 199)
In perfect_foresight_solver_core (line 97)
In perfect_foresight_solver (line 63)
In Dynare_forum.driver (line 873)
In dynare (line 293)
Simulation terminated with NaN or Inf in the residuals or endogenous variables.
There is most likely something wrong with your model. Try model_diagnostics or another simulation method.
Update: after debugging I seem to find the culprit, apparently Om (variable for measuring portfolio allocation between government bonds & loans among banks) has a derivative of 0. However, I do not understand why this is the case, and why this worked in a stochastic simulation but not a deterministic one
Simulation terminated with NaN or Inf in the residuals or endogenous variables.
There is most likely something wrong with your model. Try model_diagnostics or another simulation method.
Simulation of the perfect foresight model failed!Switching to a homotopy method…
Iter. | Lambda | status | Max. residual
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The dynamic Jacobian is singular. The problem derives from:
The derivative with respect to the lag of Om being 0 for all equations.
@jpfeifer Thank you Prof. I thought that was the problem as well. Although I am at a loss as to how to modify it, that equation determines the return on portfolio for banks and at steady state Rk must equal Rb
It seems the fundamental problem is the same one as at
Have a look at the attached file where I reduced the crazy tolerance you set, increased periods and substituted in for the Lagrange multiplier. Dynare_forum.mod (11.9 KB)
I know this is a very old post, but the problem I encountered in my mod file is very similar to the one that you solved here. My understanding is that you adjusted the mod file by replacing (U_c(+1)/U_c) with the Lagrangian multiplier Lambda(+1). Can you help me understand the intuition in how this resolves the numerical issue? The equation (Rp) = (Rk)(Om(-1))+(Rb)(1-(Om(-1))) is still the same, wouldn’t that lead to Om(-1) drop out just as before?
The problem derives from the internal representation of the model. The inclusion of an auxiliary variable and corresponding equation can cause numerical problems as it may introduce spurious terminal conditions.