Deterministic simulation: shocks block setup

Hello everyone.

I’m studying the transition dynamics (in a perfect-foresight setup) of a 56-gen OLG model. The transition periods are 150. However, I find it difficult to set up the shocks (deterministic) for the mortality rates. During the transition, the mortality rates change for each of the 56 generations for 150 periods, so I have a matrix instead of a classic vector. Is there a way to insert them smartly in the shocks block? It would be difficult to insert 56 exogenous variables and for each of them put 150 values. Moreover, I also have two additional shocks to include given that I have 2 types of mortality rates (the unconditional and the conditional ones).

P.s. for example, is it possible to use the “for” loop in the shocks block? I tried but it doesn’t work to me.

Thank you in advance.

Alex Crescentini.

There are essentially two ways out:

  1. Use macro-processor directives to construct the shocks-block. That would allow for a for-type loop.
  2. Forgo the shocks block and directly write the oo_.exo_simul-matrix that would be constructed based on the shocks-block before calling perfect_foresight_solver.

Based on your description, I would go for option 2.

1 Like

Thank you Johannes, this is exactly what I was looking for. So, if I got into this the code should be the following:

shocks;
oo_.exo_simul = mymatrix
end;

Is it right?

No. Not shocks block at all:

perfect_foresight_setup(periods=150);
oo_.exo_simul=mymatrix;
perfect_foresight_solver;

Just be careful when assigning the mymatrix that it correctly reflects the ordering.

1 Like

It worked. Many thanks for the help Johannes.

Alex.