Suppose I have rational expectations model of the form: x_{t+1} = F(n_{t-1})*x_t - G(n_{t-1})*x_{t-1}, where n_t = f(x_{t-1}, n_{t-1})

I want to lag the model so that it becomes entirely backward looking and get rid of the rational expectations, then solve it as deterministic. So that:

x_t = F()*x_{t-1} … etc

However, If I lag every variable those in the vector n_t will appear only in lagged terms. To avoid this I simply redefine n_{t-1} = n_l and lag only the variables in x.

Prior the lagging the model works, but afterwards gives this error:

Warning: Matrix is singular to working precision.
Error using eig
Input to EIG must not contain NaN or Inf.

and some other errors that follow from the latter.

Do you know if what I am doing is possible and if I do it in the right way? Also how can I get a more descriptive error that leads me to the problem?

I am using the deterministic solver from the beginning. Are you implying that with a deterministic model the non-lagged version with forward looking variables should give identical results as the lagged one?

Yes, because with perfect foresight, future values of variables are known at time t when the decisions are made. This is the correct way of modelling. In contrast, lagging everything by one period is wrong.

The thing is that I have done the same kind of lagging with a simpler deterministic model. The reason was that with the forward looking version the simulation was giving different results (relative to the lagged version) for the long run values for cases when the model does not converge. It seems to me that when there are forward variables dynare imposes convergence to the ss, while when the same model is lagged this does not occur. The user guide says something similar unless ‘ednval’ is specified. In my case this is not possible as I am interested in cases when the model does not converge at all (not just to another ss).

You may ask why do I do this at all. I am trying to use dynare for bifurcation analysis. That is, I simulate the long run behaviour for different parameter values and random displacements from the steady state. A similar thing is done by Branch and McGough (2010) which also lag their model.

It is true that for a simple deterministic model I can solve it in matlab without the need of dynare. But for larger models the way in which equations are entered in dynare provides great convenience.

At the end I guess my questions becomes: Can I use dynare to enter a model of this sort and simulate a not converging model without imposing convergence (I was trying to do this so far by transforming the fw RE to entirely backward looking system)?

I am not sure I understand what you are doing. Solving a perfect foresight model involves solving a system of NT equations in NT unknowns. Because of leads and lags at the initial and terminal points, 0 and T, you also need initial and terminal conditions. What exactly are you now doing differently? It seems by somehow arbitrarily changing the timing you make some of the exogenous terminal conditions an endogenous variable to be solved for.

Yes, an entirely backward looking dynamical system of the type: x_t = F(x_{t-1}) , does not need a terminal condition. Then starting from a given displacement from the ss for some parameter values the model will be converging to the ss, for others it may explode to infinity and lastly you may have neither of these but fluctuations around some attractors. This is easily solved in matlab for small models, given t-1 values you compute t values and move to next period without any terminal condition.

How and where in its algorithm does dynare impose this terminal condition? Could there be more clever way to carry out this lagging and get rid of the terminal condition?

If your system is purely backward-looking, the terminal values are never used and should not play any role.
But what still eludes me is your lagging. I don’t get how you can transform a dynamic forward-looking problem into a purely backward-looking one. Say you have an Euler equation of the form

Of course this transformation is not equivalent due to the conditional expectations. But for a deterministic model does it matter? As I said this is done here: ideas.repec.org/a/eee/dyncon/v3 … -1508.html

How are these terminal values used in dynare when you have +1 variables?

Yes, it matters, because typically your system takes the form of forward-looking, backward-looking and static equations:

1/c=beta*1/c(+1)*r(+1)
c+i=y
k=(1-delta)*k(-1)+i
Consumption in the last period T will depend on consumption in period T+1, which itself is a function of capital at time T+1. But your system will not endogenously determine capital at time T+1. This is the reason you need to set a terminal condition for c. Lagging everything by one period will not help to solve this problem, because then consumption in T depends on capital at time T, but the system only endogenously determines capital at time T-1.