# Simulating an exogeneous change in an exogenous variable

**URL:** <https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043>\
**Category:** Stochastic simulations\
**Created:** [2 July 2024 06:47 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043 "2024-07-02T06:47:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![antopon](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@antopon](https://forum.dynare.org/u/antopon)\
**Post date:** [2 July 2024 06:47 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/1 "2024-07-02T06:47:28Z")

</div>

Good morning, community. I am not very familiar with dynare and this may seem obvious to most of you. I built a three country model with natural hazards where investment in flood defences is endogenous but I would like to see what happens to GDP, capital, damages caused by storms, etc when we invest 2 different amounts in flood defences and compare with the optimum under the same shocks. Is this possible?  
I tried to build the dr functions and do the simulations in excel but this seems a bit cumbersome.  
thank you for your help

---

<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:** [2 July 2024 07:05 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/2 "2024-07-02T07:05:10Z")

</div>

> [@Two shocks simultaneously in a model](https://forum.dynare.org/t/two-shocks-simultaneously-in-a-model/5665/2):
>
> If you are working with a linearized model (order=1), the IRF to a joint shock is the sum of the individual IRFs. That way you can create any linear combination. If you want to do this more formally, you can use the simult\_-function to generate any combination you like (even at higher order). See [github.com/JohannesPfeifer/DSGE\_mod/blob/master/RBC\_news\_shock\_model/RBC\_news\_shock\_model.mod](https://github.com/JohannesPfeifer/DSGE_mod/blob/master/RBC_news_shock_model/RBC_news_shock_model.mod) for an example

may contain the answer.

---

<div class="post-metadata">

**Author:** ![antopon](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@antopon](https://forum.dynare.org/u/antopon)\
**Post date:** [2 July 2024 08:36 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/3 "2024-07-02T08:36:28Z")

</div>

Sorry for the confusion, I made a typo mistake. It’s not the shock that I would like to simulate but what happens when an endogenous variable, investment in some type of infrastructure like flood defences, is forced to have specific values for 5 periods. I tried to do this by building the dr functions in excel but it gets too messy. I don’t know if this is relevant but I am using 2nd and 3rd order aprox.  
[Threecountries.mod](https://forum.dynare.org/uploads/short-url/mJtoqxnroyWVSEuUfp1SwkdlYwv.mod) (4.1 KB)

---

<div class="post-metadata">

**Author:** ![antopon](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@antopon](https://forum.dynare.org/u/antopon)\
**Post date:** [2 July 2024 12:54 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/4 "2024-07-02T12:54:10Z")

</div>

I think I found how to do it using conditional forecasting. Thank you

---

<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:** [2 July 2024 14:50 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/5 "2024-07-02T14:50:23Z")

</div>

Yes, that can work. But it’s just about finding the necessary exogenous shocks to get the desired endogenous behavior.

---

<div class="post-metadata">

**Author:** ![antopon](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@antopon](https://forum.dynare.org/u/antopon)\
**Post date:** [3 July 2024 06:33 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/6 "2024-07-03T06:33:59Z")

</div>

I see. So it’s not the answer to the question of how the economy will perform under different levels of capital to the same shocks. Back to square one then and building the dr functions in excel. I am a bit surprised that this can’t be done in dynare though.

---

<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:** [3 July 2024 07:51 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/7 "2024-07-03T07:51:43Z")

</div>

What exactly are you trying to do? Now it sounds like you want to trace the IRFs starting from different state values (which capture the whole effect of past shocks). That would be a case of GIRFs: [DSGE\_mod/RBC\_state\_dependent\_GIRF/RBC\_state\_dependent\_GIRF.mod at master · JohannesPfeifer/DSGE\_mod · GitHub](https://github.com/JohannesPfeifer/DSGE_mod/blob/master/RBC_state_dependent_GIRF/RBC_state_dependent_GIRF.mod)

---

<div class="post-metadata">

**Author:** ![antopon](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@antopon](https://forum.dynare.org/u/antopon)\
**Post date:** [3 July 2024 10:00 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/8 "2024-07-03T10:00:59Z")

</div>

I am negotiating budget bids with the Treasury and I would like to support each limit to capital spend with evidence about how the economy may react in different economic scenarios (shocks). These scenarios or shocks need to be the same for all bids and the difference between bids is the amount of public investment

---

<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:** [3 July 2024 13:39 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/9 "2024-07-03T13:39:51Z")

</div>

So public investment is exogenous?

---

<div class="post-metadata">

**Author:** ![antopon](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@antopon](https://forum.dynare.org/u/antopon)\
**Post date:** [4 July 2024 08:06 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/10 "2024-07-04T08:06:48Z")

</div>

It isn’t initially as the first aim was to find an optimal path for public investment and compare those values with actual investment. That has been done. Now, what I would like is to see the consequences of different paths from “actual” to “optimal” public investment in terms of GDP, welfare, damages, employment, etc. In a sense, it’s about making an endogenous variable exogenous and see what happens when this exogenous variable is assigned different values, as in a control, but under the same shocks

---

<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:** [4 July 2024 16:00 UTC](https://forum.dynare.org/t/simulating-an-exogeneous-change-in-an-exogenous-variable/26043/11 "2024-07-04T16:00:08Z")

</div>

Then I think you need to think harder about the economic setup you want to do. The two relevant questions are:

1. How do you want to make investment move? Is it purely exogenous or are there fundamental shocks that alter its value? That may matter for expectation formation and underlying dynamics.
2. What is the information structure underlying your model? Is the sequence of shocks known in the first period? Or do random shocks happen each period?
