Hi,

I’m trying to solve a dynamic portfolio choice problem by Dynare 4.

The problem is, when I do the simulation (2nd order), the system always generate some very big exogenous random shocks. Then I get "NaN’ in the simulation result.

It is weired since the variance of my shock is 0.0001. but in simulation the system generates some big shocks (not only once). The typical process is: in some period,(say, 102th period), the shock is 1.500, then the 103th period is e06, the 104th period the shock is e18, etc…finally it gets to NaN… Not only the endogenous variables go to NaN, but also the exogenous shocks go to NaN…

I worked on it for 2 days but I still cannot figure out the reason. The only finding is, if I enlarge a parameter in my code named “cost”(which is just a penalty parameter in the model, has nothing to do with the shock), then it’s less likely to get a NaN in simulation.

Can anyone tell me how to fix it?

I attach my .mod and .m file here.

portfolio.mod (1.83 KB)

portfolio_steadystate.m (506 Bytes)