I'm beginner in rats.
recently I'm interestd in DY Spillover Index, and DY(2012) say Spillover table can normalize the elements of the variance decomposotion matrix with the column sum of these elements.
I want to compare row and column normalization.
Following is the replication code for DY(2011) proposed by TomDoan. and I delete some country for handling easily.
If I want to column normalzation , How can I make this?
I think revise this parts. but I'm not sure.
Code: Select all
errors(model=returnvar,steps=nsteps,factor=gfactor,stderrs=gstderrs,print,results=gfevd)
compute gfevdx=%xt(gfevd,nsteps)
Code: Select all
compute usegirf=1
open data dy_ej2009.xls
calendar(w) 1992:1:10
data(format=xls,org=columns,sheet="weekly_realreturns",top=2,left=2) 1992:01:10 2007:11:23 $
rrdjia rrftse rrfra rrger
dec vect[int] returns
enter(varying) returns
# rrdjia rrftse rrfra rrger
dec vect[string] shortlabels(%size(returns))
enter shortlabels
# "US" "UK" "FRA" "GER"
* Setup and estimate two lag VAR
system(model=returnvar)
variables returns
lags 1 2
det constant
end(system)
estimate(noprint)
* Analyze the 10 step responses
*
compute nsteps=2
*********************************************************************
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,print,results=gfevd)
compute gfevdx=%xt(gfevd,nsteps)
display "10-Step-Ahead Variance Decomposition" gfevdx*100
45.13557 18.77770 17.34848 18.73825
16.46141 39.58519 23.17755 20.77585
14.63099 22.14470 37.81998 25.40433
15.92989 20.09512 25.79258 38.18241
Code: Select all
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)=fromvar(i)+1-tovar(i)
compute spillover=100.0*%sum(fromvar)/%nvar
*
report(action=define,title="Table 3. Spillover Table for Global Market 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)
US UK FRA GER From Others
US 45.1 18.8 17.3 18.7 55
UK 16.5 39.6 23.2 20.8 60
FRA 14.6 22.1 37.8 25.4 62
GER 15.9 20.1 25.8 38.2 62
Contribution to others 47 61 66 65 239
Contribution including own 108 99 96 97 59.8%
Best,
hyde82