Graph produced by shock_decomposition

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!

No. You would have to do this yourself. See also [Grouping multiple shocks in historical decomposition). The discussion and link there might be helpful.

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,

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

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

Please also see towards the end of the webpage
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

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 (22.9 KB)

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.

1 Like

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