I have been working on a model (see code attached). The stochastic version seems to be working fine. However, I would like to examine the effects of a temporary and fully anticipated shock. This unfortunately does not seem to work: the code does not converge. Based on the tips I found online, I attempted several ways to fix this: 1) increasing the number of periods, 2) decreasing the step size (options_.slowc), but neither seem to help. Interestingly, even if I set the shock to be always equal to its steady state value, the algorithm still does not find the right solution (which should be to stay in steady state forever).

The name of the variable that is shocked is ‘logkappa’ and its dynamics are set in line 315 of the code.

I tried fixing some variables of the model, and found one thing that does ‘work’. In line 139, there is a first order condition for a variable called ‘LC’. If I fix this variable at its steady state value, the code seems to work. Also, if I change both sides of the equation to current instead of next-period variables (wC and wS), the algorithm works, but only if I don’t set the number of time periods to be too high.

Would you have any ideas as to what is going on, and any tips on how I might fix this?

If you set “wC=wS”, then the Blanchard-Kahn conditions are not verified (see the output of the “check” command), so this case is ruled out.

If you set “wC(+1)=wS(+1)”, then the Blanchard-Kahn conditions are verified, but the Jacobian of your matrix become singular (lots of warning messages related to that). The convergence does not occur, even though there is actually no shock (the value given to logkappa in the shocks block is its steady state level!)

I think something is wrong with your model, but some more work is needed to find the problem.

Thanks for your reply. I have some (dumb) questions. Could you maybe answer them, or point to a good source for reference?

– What is the Jacobian of my matrix? I’m guessing this is used by the Newton algorithm. From what I can tell, this is not a square matrix, so how can it be singular?
– How did you see that it was singular?
– Might the problem be due to variables being perfectly collinear?
– My model seems to work for fine for estimation / stochastic simulation. Does this Jacobian error nevertheless suggest a bug, and should I be worried about my results?
– If there is a problem, what might be a smart way to figure out what is wrong with my model?

Actually I meant the Jacobian of the big nonlinear stacked system made of all equations at all dates of simulations, which is solved in the deterministic case. I think that when you set “wC(+1)=wS(+1)”, the singularity appears because there is no variable appearing at current date in this equation.
With “wC=wS” the Blanchard-Kahn are not satisfied.

In both cases this denotes a misspecification of your model or a wrong parameterization.

A lot of error messages related to that.

It’s hard to tell what’s wrong without a deep investigation of your model. I think there is no “simple” way of finding what’s wrong. You need to go back to your economic framework and identify the possible mistakes in derivation of first order condition or in the way you pose the optimization problem.