Dear Community,
Like some others on the forum, I have been running across this error, and I am having trouble diagnosing it:
dynare:k_order_perturbation: Caught Kord exception: NaN or Inf asserted in first order derivatives in FirstOrder::solve
I’ve searched through the previous posts on this issue, but none appear to apply directly. So far, I know the following:

The error only occurs in the 3rd order approximation, not the 1st or 2nd. However, I need the 3rd order approximation as my model involves risk.

The error doesn’t occur for all parameter values. For my key parameter, sigf, the error appears when sigf is smaller than 4.0 or greater than roughly 1.0.

The error seems to be confined to the Jacobian matrix, as the error message suggests. If stop the code midexecution and replace the g_1 matrix with the g_1 matrix from a previous nonerror generating parameter set, the error goes away. (Specifically, I do this during line 64 of k_order_pert.m, which calls the MEX files that evaluate the _dynamic.m file)

Using the same technique as above, I’ve narrowed down the issue to the 3rd row of the Jacobian, which corresponds to my capital supply equation (this equation is rather long). However, none of the values here are ever NaN or Inf, as suggested by the error message. Further, the error persists even when sigf is set slightly greater than one (say, 1.2), at which point the g1 matrix takes on only reasonably sized values.
I am attaching my .mod file, as well as the steady state file (and two associated files) needed to compute the steady state. Any assistance would be greatly appreciated.
Zhaochen He
ss_solver2.m (1.73 KB)
ss_solver1.m (1.58 KB)
paper_0_1_steadystate.m (2.11 KB)
paper_0_1.mod (2.06 KB)