Perfect foresight - homotopy

Hello,

I have a question to the following code (attached). It is a SIR model with perfect foresight. With the Newton method I get the warning “Matrix is close to singular or badly scaled. Results may be inaccurate.” or “Matrix is singular to working precision” and after the maximum of iterations Dynare is switching to a homotopy method. The results that I obtain seem to make sense, though.
I am now wondering if I can trust the results and whether there is a possibility to avoid these warnings and to make the Newton method work.

Would be great if you could help me.
SIR.mod (1.8 KB)

There is nothing to worry here. Homotopy just means that Dynare will approach the problem by iteratively solving problems with a smaller shock size.

Great, thanks for your quick reply!

Hello again,

I am now trying to set up a version of the same SIR model as the one above (with a different utility function though) with a Ramsey planner. Here, the homotopy method is not working and the perfect foresight model cannot be solved. When I run model_diagnostics(M_,options_,oo_), I get the message “MODEL_DIAGNOSTICS: The steady state cannot be computed”.

However, when I use the same model with the same initval and endval block (except for the instrument) without the Ramsey planner (and now having the instrument as part of the parameter block), the model can be solved, so there it seems that there is no issue with the steady state.

Do you know what the problem could be?

Any help would be much appreciated!
SIR_Ramsey.mod (1.9 KB)

Are you sure there is a well-defined solution with the expected transition to a new steady state in the expected time? What if the Ramsey planner sets theta=0? Then the transition will take forever.

Thanks a lot for your answer!
I think with theta=0 there shouldn’t be a problem. In the steady state, theta should be equal to 0.
But it’s true that with theta=1, there would be a problem since then, there would be log(0) in the utility functions.
I tried the same code with a different utility function (quadratic instead of log utility), and it works (see attached). So maybe the problem comes from the log utility and the planner choosing a theta=1 (although this would lead to an extremely low utility (which is part of the planner’s objective) in one period, so I’m not so sure if this is actually the case).
Do you have any idea how to circumvent this problem having a log utility function?
SIR_Ramsey_diffU.mod (1.9 KB)

Did you plot your solution? There is a big jump in the last period, suggesting you did not come close to the steady state. For example, R after 500 periods is just 0.0027.

Yes, with the Ramsey planner it’s pretty extreme. In the baseline model, there’s also a jump, but smaller. But since I’m only interested in the transition dynamics, I thought it doesn’t really matter (and it’s basically what Krueger, Uhlig and Xie do in their Covid paper). And the results seem to make sense, also when I play around with different paramters etc.

You are using a two-boundary problem. Having initial conditions for the backward-looking variables and terminal conditions for the forward-looking ones, you can solve the intermediate values. That approach will generally not be valid if you force the model to be back in steady state in the last period if you are still far away from it in the second to last period.

Thanks a lot for your reply! That makes sense. I will try to find a way so that the model converges to the steady state without the jump from second to last period.
But I think my problem with the Ramsey planner and the log utility is an additional one. Is there a possibility to somehow restrict the instrument, so that in my case theta cannot be 1?