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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
| *
* Replication file for Diebold and Yilmaz(2009), "Measuring Financial
* Asset Return and Volatility Spillovers, with Application to Global
* Equity Markets," Economic Journal, vol. 119, no. 534, 158-171.
*
* Analysis of returns data
*
* If you make usegirf=1, this will use the generalized spillover
* measures proposed in Diebold and Yilmaz(2011), "Better to Give than to
* Receive: Predictive Directional Measurement of Volatility Spillovers",
* IJF, to appear. usegirf=0 does the Choleski factorization used in the
* 2009 paper.
*
compute usegirf=1
*
open data vol1.xls
calendar(d) 2012:07:03
data(format=xls,org=columns,sheet="vol1",top=1,left=1) 2012:07:03 2015:12:30 $
lnaexvol lnaxvol lnftjsevol lnftsevol lnsp500vol
dec vect[int] returns
enter(varying) returns
#lnaexvol lnaxvol lnftjsevol lnftsevol lnsp500vol
dec vect[string] longlabels(%size(returns))
enter longlabels
# "lnaexvol" "lnaxvol" "lnftjsevol" "lnftsevol" "lnsp500vol"
dec vect[string] shortlabels(%size(returns))
enter shortlabels
# "lnaexvol" "lnaxvol" "lnftjsevol" "lnftsevol" "lnsp500vol"
*
* Setup and estimate two lag VAR
*
system(model=returnvar)
variables returns
lags 1 1
det constant
end(system)
*
estimate(noprint)
*
* Save the full estimation range for later use
*
compute rstart=%regstart(),rend=%regend()
*
* Analyze the 5 step responses
*
compute nsteps=5
*********************************************************************
*
* Produce the appropriate "factor" matrix from %sigma
*
function FactorMatrix
type rect FactorMatrix
if usegirf
compute FactorMatrix=%sigma*inv(%diag(%sqrt(%xdiag(%sigma))))
else
compute FactorMatrix=%decomp(%sigma)
end
*********************************************************************
*
compute gfactor=FactorMatrix()
*
errors(model=returnvar,steps=nsteps,factor=gfactor,stderrs=gstderrs,noprint,results=gfevd)
compute gfevdx=%xt(gfevd,nsteps)
*
* These are for computing the contributions from others, to others and
* to others including own for each variable.
*
dec vect tovar(%nvar) fromvar(%nvar) tototal(%nvar)
ewise fromvar(i)=%sum(%xrow(gfevdx,i))-gfevdx(i,i)
ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
ewise tototal(i)=tovar(i)+1-fromvar(i)
compute spillover=100.0*%sum(tovar)/%nvar
*
report(action=define,title="Spillover Table for Industry Returns")
report(atrow=1,atcol=2,align=center,fillby=rows) shortlabels
report(atrow=2,atcol=1,fillby=cols) shortlabels
report(atrow=2,atcol=2) 100.0*gfevdx
report(atrow=%nvar+2,atcol=1,fillby=rows) "Contribution to others" 100.0*tovar
report(atrow=%nvar+3,atcol=1,fillby=rows) "Contribution including own" 100.0*tototal
report(atcol=%nvar+2,atrow=1) "From Others"
report(atcol=%nvar+2,atrow=2,fillby=cols) 100.0*fromvar
report(atrow=%nvar+2,atcol=%nvar+2,fillby=cols) 100.0*%sum(tovar)
report(atrow=%nvar+3,atcol=%nvar+2,align=right) %strval(spillover,"##.#")+"%"
report(atrow=2,atcol=2,torow=%nvar+1,tocol=%nvar+1,action=format,picture="*.#")
report(atrow=%nvar+2,torow=%nvar+3,atcol=1,tocol=%nvar+2,action=format,picture="###")
report(atcol=%nvar+2,atrow=2,torow=%nvar+2,action=format,picture="###")
report(action=show)
*
* Rolling window analysis
*
compute nspan=60
dec series totalspill
dec symm netpairvar(%nvar,%nvar) pafromuvar(%nvar,%nvar) pafromdvar(%nvar,%nvar)
dec vect[series] fromspill(%nvar) tospill(%nvar) netspill(%nvar)
dec symm[series] netpairspill(%nvar,%nvar) pafromuspill(%nvar,%nvar) pafromdspill(%nvar,%nvar)
clear(zeros) fromspill topspill totalspill netspill pafromuspill pafromdspill netpairspill
* set pafromspill rstart+nspan-1 rend = 0.0
do end=rstart+nspan-1,rend
estimate(noprint) end-nspan+1 end
*
* Skip any data points where the rolling VAR has an explosive root.
*
eigen(cvalues=cv) %modelcompanion(returnvar)
if %cabs(cv(1))>=1.0 {
compute totalspill(end)=%na
next
}
compute gfactor=FactorMatrix()
errors(model=returnvar,steps=nsteps,factor=gfactor,stderrs=gstderrs,noprint,results=gfevd)
compute gfevdx=%xt(gfevd,nsteps)
ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
ewise fromvar(i)=%sum(%xrow(gfevdx,i))-gfevdx(i,i)
ewise netpairvar(i,j)=gfevdx(i,j)-gfevdx(j,i)
ewise pafromuvar(i,j)=gfevdx(i,j)
ewise pafromdvar(i,j)=gfevdx(j,i)
compute totalspill(end)=100.0*%sum(tovar)/%nvar
compute %pt(fromspill,end,100.0*fromvar)
compute %pt(tospill,end,100.0*tovar)
compute %pt(netspill,end,100.0*(tovar-fromvar))
compute %pt(netpairspill,end,100.0*netpairvar)
compute %pt(pafromuspill,end,100.0*pafromuvar)
compute %pt(pafromdspill,end,100.0*pafromdvar)
end do end
graph(header="Figure 1. Total Volatility Spillovers, SA And UK,NTLD,US,GER")
# totalspill rstart+nspan-1 rend
*
spgraph(vfields=3,hfields=2,$
header="Figure 3. Directional Volatility Spillovers, FROM SA And UK,NTLD,US,GER")
do i=1,%nvar
graph(header=longlabels(i),style=bar)
# fromspill(i) rstart+nspan-1 rend
end do i
spgraph(done)
*
*
spgraph(vfields=3,hfields=2,$
header="Figure 4. Directional Volatility Spillovers, TO SA And UK,NTLD,US,GER")
do i=1,%nvar
graph(header=longlabels(i),style=bar)
# tospill(i) rstart+nspan-1 rend
end do i
spgraph(done)
*
spgraph(vfields=3,hfields=2,$
header="Figure 5. Net Volatility Spillovers,SA And UK,NTLD,US,GER")
do i=1,%nvar
graph(header=longlabels(i),style=bar)
# netspill(i) rstart+nspan-1 rend
end do i
spgraph(done)
*
spgraph(vfields=5,hfields=2,$
header="Figure 6. up Pairwise Volatility Spillovers")
do i=1,%nvar
do j=i+1,%nvar
graph(header=shortlabels(i)+shortlabels(j),style=bar)
#pafromuspill(i,j)
end do j
end do i
spgraph(done)
*
spgraph(vfields=5,hfields=2,$
header="Figure 7. down Pairwise Volatility Spillovers")
do i=1,%nvar
do j=i+1,%nvar
graph(header=shortlabels(i)+shortlabels(j),style=bar)
#pafromdspill(j,i)
end do j
end do i
spgraph(done)
*
spgraph(vfields=5,hfields=2,$
header="Figure 8. Net Pairwise Volatility Spillovers")
do i=1, %nvar
do j=i+1,%nvar
graph(header=shortlabels(i)+shortlabels(j),style=bar)
#netpairspill(i,j)
end do j
end do i
spgraph(done)
print 2012:07:03 2015:12:30 totalspill tospill fromspill netspill netpairspill pafromuspill pafromdspill |
Partager