Policy function incomplete - only linear terms are computed

Dear all,
I have encountered the following problem while using the second order approximation: When computing the policy function, the the computer stops after having computed the linear approximation. I let it run and after more than nine hours, it then returned the theoretical moments with “NaN” entries - still not having computed the second order parts of the policy function. What does this mean? Would be great if anyone gave me a hint what is going on. Taking the first order approximation worked fine.
I have attached the code. Many Thanks for your help.

NGstochastic2.mod (3.32 KB)

Dear Ansgar,

the expression (pi(-1))^chi, with pi = 0 et chi=1, results in a bug in the parser.
We need to fix the bug, but it is alos either a bug in the model or a little weird modeling:

pi(-1) can be negative and if chi isn’t an integer, (pi(-1)^chi will be complex.