Perturbation theory

Your model contains several unit roots. This explains the NaN. Some unconditional moments simply do not exist.

Regarding the file you sent me, the loop you wrote is extremely inefficient. Take a look at [Using dynare for a solver for OSR and calibration)