# 3 exogenous shocks at a time

**URL:** <https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393>\
**Category:** Dynare help (legacy posts)\
**Created:** [19 March 2010 17:07 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393 "2010-03-19T17:07:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcb2010](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/ed8c4c/32.png) [@mcb2010](https://forum.dynare.org/u/mcb2010)\
**Post date:** [19 March 2010 17:07 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/1 "2010-03-19T17:07:44Z")

</div>

Hi all,  
I am trying to extend the model in Dynare User Guide by Schorfheide through adding a third exogenous shock (risk premium shock) in addition to the monetary and technology shocks. I would like to know if it is OK to have 3 shocks in the model in the sense that I simulate all 3 shocks at a time, in order to end up with the impulse response functions for all 3 shocks at once. While incorporating a third shock into the model, is there anything special I need to watch out, apart from the stochastic process I define for the shock?

Thanks a lot in advance.

Isabel

---

<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:** [20 March 2010 09:57 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/2 "2010-03-20T09:57:04Z")

</div>

Dear Isabel,

this should be no problem. However, it might be somewhat tricky to simultaneously feed all three shocks into Dynare for a single impulse response. Usually, if you define three shocks, Dynare output gives you three series of impulse responses. If you only want a single one with all three shocks at once, you have to define a fourth exogenous shocks, let’s say epscommon, which you add to each of the 3 equations you want to shocks (probably with a scaling factor for differing variances). This shock can then be interpreted as entering all three of the other shocks at once. The impulse response of Dynare to this shock is the one you are looking for.

Best regards

Johannes

---

<div class="post-metadata">

**Author:** ![mcb2010](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/ed8c4c/32.png) [@mcb2010](https://forum.dynare.org/u/mcb2010)\
**Post date:** [23 March 2010 16:10 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/3 "2010-03-23T16:10:22Z")

</div>

That sounds very helpful already. Thank you very much Johannes!

Best,

Isabel

---

<div class="post-metadata">

**Author:** ![xuz](https://forum.dynare.org/letter_avatar_proxy/v4/letter/x/8e7dd6/32.png) [@xuz](https://forum.dynare.org/u/xuz)\
**Post date:** [8 April 2016 22:36 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/4 "2016-04-08T22:36:13Z")

</div>

hi, I read through this thread and some related treads but I still cannot get the code working. The simple model with two exogenous shocks is

[code]  
var a, b;  
varexo e, u;  
parameters rho;  
rho = 0.95;

model;  
a = rho_a(-1) + e;  
b = rho_b(-1) + u;  
end;

shocks;  
var e; stderr 1;  
var u; stderr 1;  
end;

stoch\_simul(order=1);[/code]

The modified model with c is the sum of the shock e and shock u is

[code]  
var a, b;  
varexo e, u, c;  
parameters rho;  
rho = 0.95;

model;  
a = rho_a(-1) + e;  
b = rho_b(-1) + u;  
c=e+u;  
end;

shocks;  
var e; stderr 1;  
var u; stderr 1;  
var c; stderr 2;  
end;

stoch\_simul(order=1);[/code]

The error I got is “ERROR: There are 3 equations but 2 endogenous variables!”

I know why I got this error but I cannot write a correct model that gives a irf of shock c which is the sum of e and u.

If I try the following code:

[code]  
var a, b;  
varexo u, c;  
parameters rho;  
rho = 0.95;

model;  
a = rho_a(-1) + c-u;  
b = rho_b(-1) + u;  
end;

shocks;  
var e; stderr 1;  
var u; stderr 1;  
var c; stderr 2;  
end;

stoch\_simul(order=1);[/code]

Then I’ll introduce the correlation of shock u to a. I know in this example it makes no sense to look at the sum of shocks. I just use it simple to know how to construct the sum of shocks and get the irf. Thanks!

---

<div class="post-metadata">

**Author:** ![xuz](https://forum.dynare.org/letter_avatar_proxy/v4/letter/x/8e7dd6/32.png) [@xuz](https://forum.dynare.org/u/xuz)\
**Post date:** [8 April 2016 22:46 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/5 "2016-04-08T22:46:26Z")

</div>

Got it working by

[code]  
var a, b;  
varexo e, u c;  
parameters rho;  
rho = 0.95;

model;  
a = rho_a(-1) + 1/2_c;  
b = rho_b(-1) + 1/2_c;  
end;

shocks;  
var e; stderr 1;  
var u; stderr 1;  
var c; stderr 2;  
end;

stoch\_simul(order=1);[/code]

---

<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:** [14 April 2016 08:47 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/6 "2016-04-14T08:47:22Z")

</div>

@xuz What are you trying to achieve? In your last try, e and u do not appear in the model. You are working with one shock only.

---

<div class="post-metadata">

**Author:** ![xuz](https://forum.dynare.org/letter_avatar_proxy/v4/letter/x/8e7dd6/32.png) [@xuz](https://forum.dynare.org/u/xuz)\
**Post date:** [1 May 2016 23:55 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/7 "2016-05-01T23:55:51Z")

</div>

> [@jpfeifer](#):
>
> @xuz What are you trying to achieve? In your last try, e and u do not appear in the model. You are working with one shock only.

Professor Pfeifer , if I have a model like

[code]var a, b, c;  
varexo d, e, f;  
parameters rho xi;  
rho = 0.95;  
xi =0.8;

model;  
a = rho_a(-1) + xi_ b + d;  
b = rho_b(-1) + xi_c+e;  
c = rho_c(-1) + xi_a + f;  
end;

shocks;  
var d; stderr 1;  
var e; stderr 2;  
var f; stderr 3;  
end;

stoch\_simul(order=1);[/code]

Question 1: What kind of code should I use if i want a irf for 3 shocks hitting the system at the same time? Is the following new shock g working?

[code]var a, b, c;  
varexo d, e, f, g;  
parameters rho xi;  
rho = 0.95;  
xi =0.8;

model;  
a = rho_a(-1) + xi_ b + d+1/sqrt(1^2+2^2+3^2)_g;  
b = rho_b(-1) + xi_c+e+2/sqrt(1^2+2^2+3^2)g;  
c = rhoc(-1) + xi_a + f+3/sqrt(1^2+2^2+3^2)\*g;  
end;

shocks;  
var d; stderr 1;  
var e; stderr 2;  
var f; stderr 3;  
var g; stderr sqrt(1^2+2^2+3^2);  
end;

stoch\_simul(order=1);[/code]

if I have a model like

[code]var a, b, c;  
varexo d, e, f;  
parameters rho xi;  
rho = 0.95;  
xi =0.8;

model;  
a = rho_a(-1) + xi_ b + d+ xi_d(-1);  
b = rho_b(-1) + xi_c+e;  
c = rho_c(-1) + xi\*a + f;  
end;

shocks;  
var d; stderr 1;  
var e; stderr 2;  
var f; stderr 3;  
end;

stoch\_simul(order=1);[/code]

Question 2: Is the following new shock gg working? Thanks!

[code]var a, b, c;  
varexo d, e, f, gg;  
parameters rho xi;  
rho = 0.95;  
xi =0.8;

model;  
a = rho_a(-1) + xi_ b + d+1/sqrt(1^2+2^2+3^2)_gg +xi \* 1/sqrt(1^2+2^2+3^2)gg(-1);  
b = rhob(-1) + xi_c+e+2/sqrt(1^2+2^2+3^2)_gg;  
c = rho_c(-1) + xi\*a + f+3/sqrt(1^2+2^2+3^2)\*gg;  
end;

shocks;  
var d; stderr 1;  
var e; stderr 2;  
var f; stderr 3;  
var gg; stderr sqrt(1^2+2^2+3^2);  
end;

stoch\_simul(order=1);[/code]

---

<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:** [6 May 2016 08:04 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/8 "2016-05-06T08:04:22Z")

</div>

Without context, it is hard to see what you are after and why you have that particular form for the variance of the common shock g. But in principle adding a common shock to each of the exogenous processes is correct when you want to simultaneously shock all three of them. Dynare will do a one standard deviation shock, which is

```auto

```

The variable a will therefore be hit by 1, b by 2,and c by three

---

<div class="post-metadata">

**Author:** ![nkscholtes](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/7ab992/32.png) [@nkscholtes](https://forum.dynare.org/u/nkscholtes)\
**Post date:** [2 August 2016 19:54 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/9 "2016-08-02T19:54:42Z")

</div>

From browsing through other posts, it seems that under linearity, the proposed solution is equivalent to simply adding the IRFs associated to the three shocks. Is that correct? In which case, is it simply a case of going into the oo\_ structure and adding the vectors for the IRFs associated to each endogenous variable specified in stoch\_simul? Thanks in advance for your reply.

---

<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 August 2016 06:58 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/10 "2016-08-03T06:58:46Z")

</div>

Yes, under linearity that is true. Alternatively, you can use the simult\_-function as in [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)

---

<div class="post-metadata">

**Author:** ![nkscholtes](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/7ab992/32.png) [@nkscholtes](https://forum.dynare.org/u/nkscholtes)\
**Post date:** [4 August 2016 11:42 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/11 "2016-08-04T11:42:06Z")

</div>

Thanks very much for the reply! Things seem to be running smoothly (for now)

---

<div class="post-metadata">

**Author:** ![nkscholtes](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/7ab992/32.png) [@nkscholtes](https://forum.dynare.org/u/nkscholtes)\
**Post date:** [8 August 2016 08:08 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/12 "2016-08-08T08:08:37Z")

</div>

Out of curiosity, do you know of any references that specify this or use this method of having simultaneous shocks then adding the IRFs under linearity? It’s intuitive to me but as most people provide a set of IRFS for _each_ shock, it would help to have a reference.

As I’m fairly new to Dynare myself, I was also curious about the convention for writing the AR(1) shock processes. As far as the solver is concerned, does it make a difference if the shock is specified in multiplicative exponential form (i.e exp(error)) or additive log form? Thanks again!

---

<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:** [8 August 2016 12:51 UTC](https://forum.dynare.org/t/3-exogenous-shocks-at-a-time/1393/13 "2016-08-08T12:51:47Z")

</div>

Linearity is such a basic property that people do not discuss it in articles. It is immediately evident by looking at linear policy functions.

It does not matter how you specify your shock process as long as it is consistent. Both specifications are mathematically equivalent.
