Affecting each iteration of the mod file

Hi everyone,
I would like to know if it is possible to declare a variable “time” within the mod file affecting other endogenous variable. I would like to have this “time” variable assuming value=1 during the first iteration, value=2 during the second and so on for the number of iterations specified with the periods option!

Thank You in advance

What exactly do you want to do? You can of course define an exogenous variable taking on every value you like. But that will not work with every solution technique you may have in mind.

I wil ltry to be more specific. I need to declare within a simple (3 equations) NK model an endogenous variable that depends explicitly on the iteration: for example Y = 1/(t+1) where t is the current iteration. the solution technique would be on my understanding the standard approimation to the first order.
Thank You for asnwering and sorry if I cannot be more clear.

I am not sure I understand why you need to have this dependence on t. Is it because you want to build a model with time varying parameters?

If you define an endogenous variable, say we call it t, as follows:

t = t(-1) + 1; 

and set the initial condition to zero, you will have exactly the trend you want. The problem is that you cannot simulate such a model with a perturbation technique (ie calling stoch_simul). This approximation rely on an approximation of the original equation around the deterministic steady state. First problem is that there is no steady state for t here since we have a unit root with drift. Suppose that we approximate the model around t^{\star}=0, even if 0 is not a steady state. Then using a first order Taylor expansion we will have the following approximation (at first order):

y \approx \frac{1}{t+1}_{\Bigg|_{t=t^{\ast}}} + \frac{\mathrm d}{\mathrm dt}\left(\frac{1}{t+1}\right)_{\Bigg|_{t=t^{\ast}}}\left(t-t^{\ast}\right)

that is

y-1 \approx -t

More generally, if 1/(1+t) is multiplied by another endogenous variable, you will loose the product in the linearisation. If you have in mind a model with time varying parameters, this will certainly not help. In principle, you may use an extended path approach or simulate the perfect foresight version of your model, but again since your model does not admit a steady state you will have to work on the terminal condition (it is not difficult to determine the level of t at the horizon of the perfect foresight model).

Best,
Stéphane