When simulating the contributions of shocks to the paths of endogenous variables (using the 'contributions' option in the simulate function) you can easily graph the results by the 'conbar' function designed specifically to that end. The contribution graphs are now also available in reports, thanks to an extension of the 'plotfunc' option of the series objects.
For the sake of this example, we create an otherwise empty database with an artificial multi-column series, and a list of names used for legend entries:
d = struct(); d.x = tseries(1:30,randn(30,5)); legendnames = {'aaa','bbb','ccc','ddd','eee'};In real life, you would of course most likely run something like this:
d = simulate(m,d,range,'contributions',true); d.x = d.x{:,1:end-1}; legendnames = get(m,'elist');Note that the second line above is to remove the last column from the contribution time series, and hence to preserve only the contributions of the individual shocks (recall the the last colum is the contribution of the initial condition and the deterministic drift or constant).
Then, we can add a series object to a report, specifying that we want the input data to be plotted by the conbar function -- note how we use the 'plotfunc' option.
R = report.new(); R.figure('Figure name...','subplot',[2,1],'legend',true); R.graph('Graph name...'); R.series('Series name...',x, ... 'plotfunc',@conbar,'legend',legendnames); R.publish('my_report.pdf');Remember also to set the 'legend' option to true as above in one of the parent objects (the graph, figure, or report) if you want to display also the legend.
There will be quite a few tutorials by Petar specifically focused on the reporting features coming soon.
No comments:
Post a Comment