-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcomputeDYtable.m
68 lines (52 loc) · 1.87 KB
/
computeDYtable.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function [DYtable,spillover,fromvar,tovar,net] = computeDYtable(estMdl, steps, useGIRF)
% Return Diebold and Yilmaz Index table and other components.
% Syntax [DYtable,spillover,fromvar,tovar,net] = computeDYtable(estMdl, steps, useGIRF)
%
% Compute Diebold and Yilmaz (2009, 2012) Spillover Index
%
% DYtable has a structure
%
% (i,j) var1 var2 ... ... varK FROM
% var1 x% Sum(DY(i,j),j <> 1)
% var2 Sum(DY(i,j),j <> 2)
% ...
% ...
% varK Sum(DY(i,j),j <> K)
% TO Sum( ... ... ... i <> K SPILLOVER INDEX
% DY(i,j),
% i <> 1)
%
% DYtable is of size (K+1) x (K+1)
% Column (K+1)th is FROM OTHERS; Row(K+1)th is TO OTHERS. Cell
% DYtable(K+1,K+1) is the SPILLOVER INDEX. While, Net=(TOVAR - FROMVAR).
%
% Reference: Diebold and Yilmaz (2009,2012,2014).
% Author: Binh Thai Pham, PhD. ([email protected]). 2020.
if nargin < 3
useGIRF = 0;
end
if nargin < 2
steps = 10;
end
if isobject(estMdl) && isa(estMdl,'varm') && (~isempty(estMdl.AR))
K = estMdl.NumSeries;
if useGIRF == 0
oMSPE = 100*computeMSPEkj(estMdl,steps);
fromvar = sum(oMSPE,2) - diag(oMSPE);
tovar = sum(oMSPE,1) - diag(oMSPE)';
spillover = sum(tovar) / K;
DYtable = [oMSPE fromvar; [tovar spillover]];
net = tovar - fromvar;
else % if useGIRF ~= 0
gMSPE = 100*computeGMSPEkj(estMdl,steps,true);
fromvar = sum(gMSPE,2) - diag(gMSPE);
tovar = sum(gMSPE,1) - diag(gMSPE)';
spillover = sum(tovar) / K;
DYtable = [gMSPE fromvar; [tovar spillover]];
tovar = tovar';
net = tovar - fromvar;
end
else
DYtable = [];
end
end