# Deterministic simulation: shocks block setup

**URL:** <https://forum.dynare.org/t/deterministic-simulation-shocks-block-setup/19099>\
**Category:** Perfect foresight simulations\
**Created:** [15 October 2021 10:38 UTC](https://forum.dynare.org/t/deterministic-simulation-shocks-block-setup/19099 "2021-10-15T10:38:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex.crescentini](https://forum.dynare.org/user_avatar/forum.dynare.org/alex.crescentini/32/18322_2.png) [@alex.crescentini](https://forum.dynare.org/u/alex.crescentini)\
**Post date:** [15 October 2021 10:38 UTC](https://forum.dynare.org/t/deterministic-simulation-shocks-block-setup/19099/1 "2021-10-15T10:38:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [15 October 2021 13:39 UTC](https://forum.dynare.org/t/deterministic-simulation-shocks-block-setup/19099/2 "2021-10-15T13:39:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alex.crescentini](https://forum.dynare.org/user_avatar/forum.dynare.org/alex.crescentini/32/18322_2.png) [@alex.crescentini](https://forum.dynare.org/u/alex.crescentini)\
**Post date:** [15 October 2021 13:56 UTC](https://forum.dynare.org/t/deterministic-simulation-shocks-block-setup/19099/3 "2021-10-15T13:56:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [15 October 2021 14:12 UTC](https://forum.dynare.org/t/deterministic-simulation-shocks-block-setup/19099/4 "2021-10-15T14:12:58Z")

</div>

No. Not shocks block at all:

```auto
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.

---

<div class="post-metadata">

**Author:** ![alex.crescentini](https://forum.dynare.org/user_avatar/forum.dynare.org/alex.crescentini/32/18322_2.png) [@alex.crescentini](https://forum.dynare.org/u/alex.crescentini)\
**Post date:** [15 October 2021 14:30 UTC](https://forum.dynare.org/t/deterministic-simulation-shocks-block-setup/19099/5 "2021-10-15T14:30:53Z")

</div>

It worked. Many thanks for the help Johannes.

Alex.
