1.Can I ask you how is theoretical momet calculated after implementing ramsey_policy?

Are they related to the moment of IRF?

In addition, is it problematic if there exists a unit root? Does that mean my model is wrong or need correction such as stationarization? I think that Dynare can not calcaulate the theoretic moment for some variables because of the unit root.

After setting up the first order conditions of the planners problem, Dynare conducts a first order approximation. This results in a linear state-space system representing the solution. See

Yes, they are related to IRFs in the sense that in each period shocks realize that trigger IRFs. The sum of the respective IRFs at each point in time causes the variables to move. The moments are then computed on these variables (although only conceptually if you consider theoretical moments)

Your code loads a lump_noS_params_nw.mat, but you only provided a lump_noS_params.mat. Unit roots are not a problem, if they come from economic features of the model as opposed to coding errors. Of course, the unconditional second moments of the unit root variables do not exist as they are infinite.

Because it affects cco and ccr and unit roots in consumption are uncommon. But total consumption CC is not affected. This indicates that shocks permanently shift consumption from one type of agent to the others. Maybe this is a feature of the model.

You are solving a Ramsey problem. Thus, there are equations of the Ramsey problem added to the problem. These are the first M_.ramsey_eq_nbr equations, followed by the M_.orig_eq_nbr original equations, resulting in M_.eq_nbr total equations.