Second order approximation and the IRF explosive

Dear Prof. Jpfeifer,

Many thanks for your generous help. It helped me a lot!

I notice that you didn’t put the stoch_simul command in the mod-file. However, in the post Optimal policy parameters in a non-linear model, you indicated me that the maximization code should be put after a stoch_simul-command because that one is needed to initialize all the structures used. Could you please help me explain whether should I put the maximization code right after the stoch_simul command or just delete it? And why?

Besides, how can I set the grid step during the process of optimal parameter value search? For example, I define the range of the parameters to be optimized as 0 to 3, rather than 0 to Inf in your posted code, and I also want to set the grid search step is 0.01 during this range. How can I do it in dynare?

I am looking forward to your reply.