Unstable Dynare - Optimal Policy

Hello everyone,

I am running an optimal fiscal policy exercise with the Unstable version of Dynare.
The model is a standard RBC model (with variable capacity utilisation as the only “new" feature) where the Gvt is choosing optimally capital and labour tax to maximize welfare and sustain a certain amount of debt (e.g the model is the same as in Ferraro, 2010).

The exercise I run is here: starting from an arbitrary point characterised by an initial level of Gvt debt and capital, the economy converges to its optimal-policy steady state (with its associated level of debt)

The problem encountered is here: in principle, by choosing the trajectory for fiscal instruments, Gvt should be also choosing in any period the amount of debt it holds.
However, looking at the result of the simulation, it looks as something is wrong: whereas all variables show a smooth/theory consistent (?) dynamics, gvt debt appears always diverging.

Does anyone know why this is happening?

I also have a second question: how can I run/code an optimal policy simulation from an initial steady state to a final one, when the steady state is provided analytically??

Attached below my .mod file, thanks for your time.
WelfareMax.mod (4.07 KB)

I don’t really know your model, but is the unit root intended? It might explain divergence, because there is then nothing that guarantees that your model is going to return to any given terminal point.

The answer to your second question depends on the context. If you are doing perfect foresight, you need to provide and endval-block (or when working with histval an initval block, see github.com/DynareTeam/dynare/pull/1182/commits/26baff91c8e609827dda9f983a2da3906ece4e5b).