# \[share\] shock contributions labels and groups

**URL:** <https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091>\
**Category:** Dynare contributions and examples\
**Created:** [19 April 2013 09:46 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091 "2013-04-19T09:46:16Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vermandel](https://forum.dynare.org/user_avatar/forum.dynare.org/vermandel/32/5866_2.png) [@Vermandel](https://forum.dynare.org/u/Vermandel)\
**Post date:** [19 April 2013 09:46 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/1 "2013-04-19T09:46:16Z")

</div>

I run a medium scale model for my thesis with a lot of shocks. I needed to group them to make the shock contribution more clear than the current way it’s showed by dynare.

To do so, download attached dynare files and put them in /dynare/matlab/ folder. For instance, when using the Smets & Wouters model given by jpfeifer [Smets/Wouters (2007) in Dynare 4.2.5](https://forum.dynare.org/t/smets-wouters-2007-in-dynare-4-2-5/2491/1) , adding at the end of the mod file :

`
options_.groups{1}={'ea';'epinf'};
options_.groups{2}={'eg';'eb';'ew'};
options_.groups{3}={'em';'eqs'};
options_.labels = char( 'Supply', 'Demand', 'Monetary' );
shock_decomposition y; `

this will aggregate the shocks by the given groups (those given in the example are dummy). if options\_.labels is not given, the code will automatically generate some group names.

[http://img593.imageshack.us/img593/275/65060284.png](http://img593.imageshack.us/img593/275/65060284.png)

I wanted to edit dynare argument of the function shock\_decomposition(), but i couldnt (dynare was giving me an error). I guess that some important dynare internal functions are declared in dynare.exe, my hex editor told me so (but i cannot edit it, i’m not a C coder).  
[shock\_decomposition.m](https://forum.dynare.org/uploads/default/original/2X/b/bf32e507b6bdd87d2d354aff44daed5754d5ab47.m) (3.09 KB)  
[graph\_decomp.m](https://forum.dynare.org/uploads/default/original/2X/b/bf6c391ced4f35a30d74ac20764a26a5d8463c2e.m) (3.81 KB)

---

<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 April 2013 07:57 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/2 "2013-04-20T07:57:00Z")

</div>

First of all, you don’t need to deal with C-code. Everything here is done in Matlab. Second, the whole shock decomposition is stored in oo\_.shock\_decomposition. Thus, you could just use this information for graphing.

---

<div class="post-metadata">

**Author:** ![costa](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@costa](https://forum.dynare.org/u/costa)\
**Post date:** [14 November 2013 20:51 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/3 "2013-11-14T20:51:35Z")

</div>

Hi all,  
I´m trying to do the same decomposition metioned previously, but I didn´t understand where should I place the part of the code below:  
options\_.groups{1}={‘ea’;‘epinf’};  
options\_.groups{2}={‘eg’;‘eb’;‘ew’};  
options\_.groups{3}={‘em’;‘eqs’};  
options\_.labels = char( ‘Supply’, ‘Demand’, ‘Monetary’ );

Is it before or inside the estimation comand ? Or is it inside the shock\_decomposition comand ?

I did a research about this in the forum, but I didn´t find the answer.

Thanks for the attention.

---

<div class="post-metadata">

**Author:** ![federico](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/c2a13f/32.png) [@federico](https://forum.dynare.org/u/federico)\
**Post date:** [16 November 2013 10:24 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/4 "2013-11-16T10:24:20Z")

</div>

before the shock decomposition command

---

<div class="post-metadata">

**Author:** ![costa](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@costa](https://forum.dynare.org/u/costa)\
**Post date:** [16 November 2013 22:09 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/5 "2013-11-16T22:09:25Z")

</div>

Hi Frederico,

I know this should be posted in the help part of the forum, but could you take a look and say what is wrong with the part of the code below? I got an “unexpected name” message from dynare, refering to the shock command inside the shock\_decompositon command.

options\_.groups{1}={‘eps\_ah’;‘eps\_ys’;‘eps\_sh\_i’;‘eps\_sh\_w’;‘eps\_ys’;};  
options\_.groups{2}={‘eps\_sh\_c’};  
options\_.groups{3}={‘eps\_sh\_m’};  
options\_.groups{4}={‘eps\_prsF’;‘eps\_yF’;‘eps\_iF’;‘eps\_piF’;‘eps\_prfF’;‘eps\_prfF’;‘eps\_proF’};  
options\_.labels = char( ‘supply’, ‘demand’, ‘monetary’,‘external’);

stoch\_simul(irf=0) y\_hat, picz\_hat, rer\_hat, l\_hat, ca\_y\_hat, i\_hat, c\_hat, inv\_hat;

shock\_decomposition(parameter\_set = calibration, shocks= (options\_.groups{1};options\_.groups{2};options\_.groups{3};  
options\_.groups{4}) ,labels= options\_.labels)

y\_hat, picz\_hat, rer\_hat, l\_hat, ca\_y\_hat wr\_hat c\_hat inv\_hat pri\_hat;

---

<div class="post-metadata">

**Author:** ![federico](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/c2a13f/32.png) [@federico](https://forum.dynare.org/u/federico)\
**Post date:** [18 November 2013 09:24 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/6 "2013-11-18T09:24:45Z")

</div>

try to move all the label afetr stoch\_simul  
and simply use the command shock\_decomposition without any other option and see if it works.

Besides, I remember i had same troubles in running this options with dynare \> 4.3 version.  
I succesfully ues it with dynare 4.2.5 .

If it does’t work i think you should post your mod file and see what i can do.

---

<div class="post-metadata">

**Author:** ![Vermandel](https://forum.dynare.org/user_avatar/forum.dynare.org/vermandel/32/5866_2.png) [@Vermandel](https://forum.dynare.org/u/Vermandel)\
**Post date:** [19 November 2013 16:45 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/7 "2013-11-19T16:45:03Z")

</div>

here is attached an example file with Smets & Wouters codes.  
[Smets\_Wouters\_2007\_Dynare425.zip](https://forum.dynare.org/uploads/default/original/2X/d/de9b868eac8141359d80db89d65a234072d79b56.zip) (22.8 KB)

---

<div class="post-metadata">

**Author:** ![costa](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@costa](https://forum.dynare.org/u/costa)\
**Post date:** [1 December 2013 18:45 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/8 "2013-12-01T18:45:41Z")

</div>

Hi Vermandel and Frederico,

I think this problem is related with the dynare version, because I ran the code above and got the chart without the labels. I´m using dynare 4.3.3. Which version are you using, Vermandel?

---

<div class="post-metadata">

**Author:** ![federico](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/c2a13f/32.png) [@federico](https://forum.dynare.org/u/federico)\
**Post date:** [2 December 2013 09:11 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/9 "2013-12-02T09:11:43Z")

</div>

It works surely under dynare version 4.2.5

---

<div class="post-metadata">

**Author:** ![Oriana](https://forum.dynare.org/letter_avatar_proxy/v4/letter/o/96bed5/32.png) [@Oriana](https://forum.dynare.org/u/Oriana)\
**Post date:** [30 May 2015 11:15 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/10 "2015-05-30T11:15:47Z")

</div>

Hi,

I am working with dynare 4.3.3 version.  
I got,

Starting Dynare (version 4.3.3).  
Starting preprocessing of the model file …  
ERROR: nonlinearomega.mod:1713.48-53: syntax error, unexpected NAME, expecting DATAFILE or LABELS or PARAMETER\_SET or SHOCKS

What is unexpected since in nonlinearomega.mod:1713.48-53 I already have SHOCKS ( for confirmation, please, see the file above).  
Is this a bug?  
[nonlinearomega-2 2 USA 2.zip](https://forum.dynare.org/uploads/default/original/2X/e/e92fe8fd8e8641457d6904a182d091541f94ff8f.zip) (554 KB)

---

<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:** [31 May 2015 20:32 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/11 "2015-05-31T20:32:14Z")

</div>

Sorry, but this is no supported function of Dynare. If the original author does not help you out, you will have to solve this yourself.

---

<div class="post-metadata">

**Author:** ![Oriana](https://forum.dynare.org/letter_avatar_proxy/v4/letter/o/96bed5/32.png) [@Oriana](https://forum.dynare.org/u/Oriana)\
**Post date:** [2 June 2015 09:42 UTC](https://forum.dynare.org/t/share-shock-contributions-labels-and-groups/3091/12 "2015-06-02T09:42:19Z")

</div>

Thank you. I already solved it myself!
