Same code works for stochastic simulation but not for deterministic simulation----Last iteration provided complex number for the following variables: lamb, Iter: 9, err. = Inf, time = 0.053294 Warning: Matrix is singular to working precision

Hi all,

I am trying to run a deterministic model simulating the effect of a permanent shock. I first run the model in a stochastic circumstance. It runs perfectly fine. However, when I changed into a deterministic environment, Dynare failed to solve the perfect foresight model. In the model simulation part, Dynare gives me the following message:

Iter: 3, err. = 2.98602704547348e+16, time = 0.29229
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
3.708341e-20.

In sim1>lin_solve (line 236)
In sim1 (line 165)
In perfect_foresight_solver_core (line 94)
In perfect_foresight_solver (line 61)
In code20 (line 605)
In dynare (line 235)

Last iteration provided complex number for the following variables:
lamb, Iter: 4, err. = 6.264235574022294e+31, time = 0.33963
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
2.601730e-39.

In sim1>lin_solve (line 236)
In sim1 (line 165)
In perfect_foresight_solver_core (line 94)
In perfect_foresight_solver (line 61)
In code20 (line 605)
In dynare (line 235)

I am not sure what is going on. What did Dynare mean by saying “Last iteration provided complex number for the following variables: lamb,”? Anyone has run into the same situation as me?

From stochastic to deterministic, I moved 3 variables from the “parameter” block to the “varexo” block. Because they serve as an exotic change and the values differ from the initial value to the end value. I am not sure if it is the change that caused this problem. I have attached the mod files for your information. The code20 is the deterministic one and the code22 is the stochastic one. Please feel free to comment on this.

Thanks!
Jaxx

code20.mod (7.9 KB) code22_steadystate.m (2.4 KB) code22.mod (7.7 KB)

I also moved the 3 variables into the “varexo” block in the stochastic simulation code, and it worked perfectly… So I am not sure why the same code works in stochastic environment but not in deterministic environment…

Nonlinear models can behave very differently then their linearized version if you get away from the initial point of approximation. Remember that a linearized model will be globally stable when the Blanchard-Kahn conditions are satisfied, even if the nonlinear version is not globally stable.

Have you tried whether the model works for smaller shocks?