# Graph produced by shock\_decomposition

**URL:** https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454
**Category:** ML/Bayesian estimation
**Created:** [31 January 2015 07:37 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454 "2015-01-31T07:37:03Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Grant](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/a5b964/32.png) [@Grant](https://forum.dynare.org/u/Grant)
#### Post date: [31 January 2015 07:37 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454/1 "2015-01-31T07:37:03Z")

</div>

Dear Jpfeifer,

I have constructed a large model including a rich set of shocks (more than 15 shocks). I use the “shock\_decomposition” command to produce the historical shock decomposition graph. Since some shocks only show minor effects on the variance of endogenous variables, I want to only show some important shocks, say whose contribution are larger than 5% in the variance decomposition in the graph, rather than the graph including the whole set of shocks directly generated by dynare. For example, I have shocks A B C D. I just want to show shock A and B in the graph of shock decomposition, and combine shock C and D together and name them as E in the graph. Is it possible in dynare?

I am looking forward to your help. Thanks!

---

<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: [1 February 2015 08:00 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454/2 "2015-02-01T08:00:03Z")

</div>

No. You would have to do this yourself. See also [[Grouping multiple shocks in historical decomposition](https://forum.dynare.org/t/grouping-multiple-shocks-in-historical-decomposition/3867/1)). The discussion and link there might be helpful.

---

<div class="post-metadata">

### Author: ![Grant](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/a5b964/32.png) [@Grant](https://forum.dynare.org/u/Grant)
#### Post date: [10 February 2015 03:13 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454/3 "2015-02-10T03:13:47Z")

</div>

Dear Jpfeifer,

Thanks for your reply. I know that all results of shock\_decomposition is stored in oo\_.shock\_decomposition. But because of my large model and rick set of shocks, the matlab cannot display all the elements. Is there a way to get out all the results, say the elements in oo\_.shock\_decomposition? So that I can put them in excel and draw the graph.

Regards,

---

<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: [10 February 2015 11:54 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454/4 "2015-02-10T11:54:31Z")

</div>

You can use the Matlab `xlswrite`-function to write the layers of `oo_.shock_decomposition` to Excel.

---

<div class="post-metadata">

### Author: ![Julie](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@Julie](https://forum.dynare.org/u/Julie)
#### Post date: [23 February 2019 17:03 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454/5 "2019-02-23T17:03:19Z")

</div>

Regarding the “xlswrite” function, please could you give me an example of how to export the shock decomposition results to Excel/Matlab ( plotting)?  
Best

---

<div class="post-metadata">

### Author: ![punnoosejacob](https://forum.dynare.org/user_avatar/forum.dynare.org/punnoosejacob/32/5976_2.png) [@punnoosejacob](https://forum.dynare.org/u/punnoosejacob)
#### Post date: [23 February 2019 19:53 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454/6 "2019-02-23T19:53:28Z")

</div>

Please also see towards the end of the webpage  
[https://www.dynare.org/manual/Shock-Decomposition.html#FOOT7](https://www.dynare.org/manual/Shock-Decomposition.html#FOOT7)

As Johannes said, it is also easy to write the shock decomposition directly to an xls file using the standard xlswrite function. It may be useful to see the order in which shock contributions are ordered at the beginning of the webpage.

Reuben

---

<div class="post-metadata">

### Author: ![Julie](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@Julie](https://forum.dynare.org/u/Julie)
#### Post date: [23 February 2019 20:14 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454/7 "2019-02-23T20:14:42Z")

</div>

I have tried to add “write\_xls” function to the option of shock decomposition command: shock\_groups(name=group1); ‘A shock’=ew; ‘B shock’=eqs,eg; ’ C shock’=ea; ‘D shock’=em; end; shock\_decomposition (use\_shock\_groups=group1,write\_xls)y; however, it reports " ERROR: usmodel.mod: line 855, c…

please see attached the file (line 855)[usmodel.mod](https://forum.dynare.org/uploads/default/original/2X/1/1ec38db6713558534a13daf5bf4fe1c3d3aa8272.mod) (22.9 KB)

---

<div class="post-metadata">

### Author: ![punnoosejacob](https://forum.dynare.org/user_avatar/forum.dynare.org/punnoosejacob/32/5976_2.png) [@punnoosejacob](https://forum.dynare.org/u/punnoosejacob)
#### Post date: [23 February 2019 20:42 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454/8 "2019-02-23T20:42:38Z")

</div>

I think you need to use the

Command: **plot\_shock\_decomposition** _(OPTIONS…) [VARIABLE\_NAME]…;_

_Description_

This command plots the historical shock decomposition already computed by `shock_decomposition` or `realtime_shock_decomposition` . For that reason, it must come after one of these commands. The `variable_names` provided govern which variables the decomposition is plotted for.

---

<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: [25 February 2019 08:14 UTC](https://forum.dynare.org/t/graph-produced-by-shock-decomposition/4454/9 "2019-02-25T08:14:10Z")

</div>

Indeed. As @punnoosejacob pointed out, `write_xls` is an option of the `plot_shock_decomposition`-command, not of the `shock_decomposition`-command
