Second order approximation and the IRF explosive

Dear Prof. Jpfeifer,

Thanks for your reply. The post you pointed to is very helpful. And I can run the 2nd order approximation well when I reduce the shock size to 0.01.

However, for the code you posted in Policy frontier, it uses the command “osr” which is designed for the linear-quadratic problem. What I want to do is to find the values of the optimal policy coefficients which can maximize the welfare. The welfare is defined as a variable as the utility of the household. I have clearly written the model in level and the steady states. The parameter values of the policy rule do Not impact the steady states. I think I might have to write a function which can solve the maximization problem based on the function of welfare, but I don’t know how to do it in Dynare. Could you please help me with it?

Thank you very much. I am looking forward to your reply.