| 1 |
function vds = fn_vds_abs(irfs); |
| 2 |
%vds = fn_vds(irfs) |
| 3 |
% |
| 4 |
% Inputs: |
| 5 |
% irfs: nsteps-by-n-by-r. For each shock of r shocks, impulse responses are nsteps-by-n. |
| 6 |
%--- |
| 7 |
% Outputs: |
| 8 |
% vds: nsteps-by-n-by-r. For each shock of r shocks, variance decompositions (%) are nsteps-by-n. |
| 9 |
% |
| 10 |
% Copyright (C) 1997-2012 Tao Zha |
| 11 |
% |
| 12 |
% This free software: you can redistribute it and/or modify |
| 13 |
% it under the terms of the GNU General Public License as published by |
| 14 |
% the Free Software Foundation, either version 3 of the License, or |
| 15 |
% (at your option) any later version. |
| 16 |
% |
| 17 |
% It is distributed in the hope that it will be useful, |
| 18 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
% GNU General Public License for more details. |
| 21 |
% |
| 22 |
% If you did not received a copy of the GNU General Public License |
| 23 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 24 |
% |
| 25 |
|
| 26 |
[nsteps, n,r] = size(irfs); |
| 27 |
|
| 28 |
vds = zeros(nsteps,n,r); |
| 29 |
|
| 30 |
vds_square_cum = cumsum(abs(irfs),1); |
| 31 |
vds_square_sum = repmat(sum(vds_square_cum,3),[1 1 r]); |
| 32 |
vds = (vds_square_cum ./ vds_square_sum) .* 100; |
| 33 |
|