Perfect foresight simulation always failed

Dear Prof Pfeifer,
I’m trying to simulate a simple model under deterministic case. The model is small. The steady state is easy to solve. And BK condition is satisfied.

However, perfect foresight simulations always fail. And it is driving me crazy.
Any clue how I can solve it? Thank you in advance!

I provide my mod and m files in the attachment.GTmodel.zip (3.6 KB)

The problem is the equation
Lam(1)*(R(1) + 1 - del) = 1;
All variables here are dated t+1. Thus, in the last period, the derivative with respect to all variables will be 0. This is no problem for stochastic simulation. For deterministic ones, do not rely on auxiliary definitions. Use

beta*C/C(+1)/G*(R(1) + 1 - del) = 1;

and the file will work.

1 Like

Thank you so much! There are more to learn in deterministic models!

Does options_.debug=1 always flag this type of issue?

It should.

In a different model I am facing the same problem (Failed to solve perfect foresight model). Basically, the residual does not change at all after a couple of iterations of the solver.

options_.debug=1 does not provide any information. However, I get the Matrix is singular to working precision warning at each iteration as well. Is there a way I can find out where the singularity is coming from?

model_diagnostics finds no obvious problems either.

I have already rewritten the model equations so they don’t rely on auxiliary definitions at all. I have also tried with different shock sizes.

Thanks a lot.

It’shard to tell without access to the codes. Is the model BK stable?

Yes, the model is BK stable. In case it helps, when I try with linear_approximation I obtain the following:

MODEL SIMULATION:

The dynamic Jacobian is singular. The problem derives from:

Largest absolute residual at iteration 1: 0.003

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.011148e-21.

In sim1_linear (line 208)
In perfect_foresight_solver_core (line 97)
In perfect_foresight_solver (line 63)
In model_PF.driver (line 1681)
In dynare (line 281)
In PF_TEST (line 7)

Iter: 1, Initial err. = 0.0025, err. = 386.959, time = 0.083

Perfect foresight solution found.

Thanks.

Then it must be something else.