Use stacked bars in contribution plots.

time-shift
Stéphane Adjemian (Charybdis) 2017-06-29 16:07:53 +02:00
parent 33967e9702
commit 061588d2d2
1 changed files with 13 additions and 4 deletions

View File

@ -74,9 +74,11 @@ for i = 1:length(vnames)
end
end
% Initialize an array for the contributions.
contribution = zeros(ds1.nobs, ds1.vobs + 1);
% Evaluate RHS with all the actual paths.
ds = ds1;
contribution = zeros(ds.nobs, ds.vobs + 1);
rhseval = eval(rhs);
contribution(:, 1) = rhseval.data;
@ -96,6 +98,13 @@ end
% Create the contributions plot.
figure('Name', lhs);
plot(1:ds.nobs, contribution);
seriesnames = ds.name;
legend('All Endogenous', seriesnames{:});
hold on
cc = contribution(:,2:end);
ccneg = cc; ccneg(cc>=0) = nan;
ccpos = cc; ccpos(cc<0) = nan;
bar(1:ds.nobs, ccneg,'stack');
bar(1:ds.nobs, ccpos,'stack');
plot(1:ds.nobs, contribution(:,1), '-k', 'linewidth', 3);
hold off
title(sprintf('Decomposition of %s', lhs))
legend('Total (LHS variable)', vnames{:});