Professional Documents
Culture Documents
These are example Eviews program codes used to generate the results in this chapter.
Please note that the data on banks distance to default (DD) is generated by the Monetary and Capital
Markets Department of the IMF, referred to in the chapter as MFD FP database, but not widely distributed
given the sensitive nature of the data. But DD may be generated using the methodology given in Box 2 of
the chapter. In this program, the DD data are represented by the codes {Country name} SYSDD for
banking system DDs or by {Country name}BDD{Bank #} for bank DDs.
'This program takes the original data and calculates the coexceedances and the control variables
'calculating the weakly change in the daily distances to default for all banks all countries (leave out banks with
little data: uk2, fr2, it5, and it6)
Germany
genr wdbd1= (bdbdd1-bdbdd1(-5))/(@abs(bdbdd1(-5)))
genr wdbd2= (bdbdd2-bdbdd2(-5))/(@abs(bdbdd2(-5)))
genr wdbd3= (bdbdd3-bdbdd3(-5))/(@abs(bdbdd3(-5)))
genr wdbd4= (bdbdd4-bdbdd4(-5))/(@abs(bdbdd4(-5)))
genr wbdsys= (bdsysdd-bdsysdd(-5))/(@abs(bdsysdd(-5)))
Spain
genr wdes1= (esbdd1-esbdd1(-5))/(@abs(esbdd1(-5)))
genr wdes2= (esbdd2-esbdd2(-5))/(@abs(esbdd2(-5)))
genr wdes3= (esbdd3-esbdd3(-5))/(@abs(esbdd3(-5)))
genr wdes4= (esbdd4-esbdd4(-5))/(@abs(esbdd4(-5)))
genr wessys= (essysdd-essysdd(-5))/(@abs(essysdd(-5)))
Eastern European
genr westeur= (esteurav-esteurav(-5))/(@abs(esteurav(-5)))
France
genr wdfr1= (frbdd1-frbdd1(-5))/(@abs(frbdd1(-5)))
'genr wdfr2= (frbdd2-frbdd2(-5))/(@abs(frbdd2(-5)))
genr wdfr3= (frbdd3-frbdd3(-5))/(@abs(frbdd3(-5)))
genr wfrsys= (frsysdd-frsysdd(-5))/(@abs(frsysdd(-5)))
Ireland
genr wdir1= (irbdd1-irbdd1(-5))/(@abs(irbdd1(-5)))
genr wdir2= (irbdd2-irbdd2(-5))/(@abs(irbdd2(-5)))
genr wdir3= (irbdd3-irbdd3(-5))/(@abs(irbdd3(-5)))
genr wirsys= (irsysdd-irsysdd(-5))/(@abs(irsysdd(-5)))
Italy
genr wdit1= (itbdd1-itbdd1(-5))/(@abs(itbdd1(-5)))
genr wdit2= (itbdd2-itbdd2(-5))/(@abs(itbdd2(-5)))
genr wdit3= (itbdd3-itbdd3(-5))/(@abs(itbdd3(-5)))
genr wdit4= (itbdd4-itbdd4(-5))/(@abs(itbdd4(-5)))
'genr wdit5= (itbdd5-itbdd5(-5))/(@abs(itbdd5(-5)))
'genr wdit6= (itbdd6-itbdd6(-5))/(@abs(itbdd6(-5)))
2
Netherlands
genr wdnl1= (nlbdd1-nlbdd1(-5))/(@abs(nlbdd1(-5)))
genr wdnl2= (nlbdd2-nlbdd2(-5))/(@abs(nlbdd2(-5)))
genr wnlsys= (nlsysdd-nlsysdd(-5))/(@abs(nlsysdd(-5)))
United Kingdom
genr wduk1= (ukbdd1-ukbdd1(-5))/(@abs(ukbdd1(-5)))
'genr wduk2= (ukbdd2-ukbdd2(-5))/(@abs(ukbdd2(-5)))
genr wduk3= (ukbdd3-ukbdd3(-5))/(@abs(ukbdd3(-5)))
genr wduk4= (ukbdd4-ukbdd4(-5))/(@abs(ukbdd4(-5)))
genr wduk5= (ukbdd5-ukbdd5(-5))/(@abs(ukbdd5(-5)))
genr wduk6= (ukbdd6-ukbdd6(-5))/(@abs(ukbdd6(-5)))
genr wuksys= (uksysdd-uksysdd(-5))/(@abs(uksysdd(-5)))
United States
genr wdus1= (usbdd1-usbdd1(-5))/(@abs(usbdd1(-5)))
genr wdus2= (usbdd2-usbdd2(-5))/(@abs(usbdd2(-5)))
genr wdus3= (usbdd3-usbdd3(-5))/(@abs(usbdd3(-5)))
genr wdus4= (usbdd4-usbdd4(-5))/(@abs(usbdd4(-5)))
genr wdus5= (usbdd5-usbdd5(-5))/(@abs(usbdd5(-5)))
genr wdus6= (usbdd6-usbdd6(-5))/(@abs(usbdd6(-5)))
genr wdus7= (usbdd7-usbdd7(-5))/(@abs(usbdd7(-5)))
genr wdus8= (usbdd8-usbdd8(-5))/(@abs(usbdd8(-5)))
genr wdus9= (usbdd9-usbdd9(-5))/(@abs(usbdd9(-5)))
genr wdus10= (usbdd10-usbdd10(-5))/(@abs(usbdd10(-5)))
genr wdus11= (usbdd11-usbdd11(-5))/(@abs(usbdd11(-5)))
genr wdus12= (usbdd12-usbdd12(-5))/(@abs(usbdd12(-5)))
genr wdus13= (usbdd13-usbdd13(-5))/(@abs(usbdd13(-5)))
genr wdus14= (usbdd14-usbdd14(-5))/(@abs(usbdd14(-5)))
genr wussys= (ussysdd-ussysdd(-5))/(@abs(ussysdd(-5)))
'stack all individual banks to get the bottom 15th percentile of the distribution in a new page, then go back to the
original page, link to use the saved threshold, then unlink to convert the link into a series
pageselect Original
link threshbanks.linkto StackedBanks\threshb
unlink threshbanks
'create a group of all banks wd, then convert group into a matrix keeping the NA's (leave out banks with little
data: uk2, fr2, it5, and it6)
group groupbankswd wdbd1 wdbd2 wdbd3 wdbd4 wdes1 wdes2 wdes3 wdes4 wdfr1 wdfr3 wdir1 wdir2
wdir3 wdit1 wdit2 wdit3 wdit4 wdit7 wdit8 wdnl1 wdnl2 wduk1 wduk3 wduk4 wduk5 wduk6 wdus1 wdus2 wdus3
wdus4 wdus5 wdus6 wdus7 wdus8 wdus9 wdus10 wdus11 wdus12 wdus13 wdus14
matrix(3105,40) matrixbankswd
stomna(groupbankswd,matrixbankswd)
vector(3105) vthreshbanks
stomna(threshbanks, vthreshbanks)
'create a dummy matrix to hold the coexceedances for each bank in each country
matrix(3105,40) coexc
3
for !i = 1 to 3105
for !j = 1 to 40
if matrixbankswd(!i,!j) < threshbanks(!i) then
coexc(!i,!j) = 1
else coexc(!i,!j) = 0
endif
next
next
vector(3105) coexcger
vector(3105) coexcsp
vector(3105) coexcfr
vector(3105) coexcir
vector(3105) coexcit
vector(3105) coexcnl
vector(3105) coexcuk
vector(3105) coexcus
vector(3105) coexcgermod
vector(3105) coexcitmod
vector(3105) coexcspmod
vector(3105) coexcukmod
vector(3105) coexcusmod
vector(3105) coexcirmod
for !i = 1 to 3105
if coexcger(!i) > 2 then
coexcgermod(!i) = 2
else coexcgermod(!i) = coexcger(!i)
endif
endif
mtos(coexcir, coexcirser)
mtos(coexcfr, coexcfrser)
mtos(coexcgermod, coexcgermodser)
mtos(coexcitmod, coexcitmodser)
mtos(coexcnl, coexcnlser)
mtos(coexcspmod, coexcspmodser)
mtos(coexcukmod, coexcukmodser)
mtos(coexcusmod, coexcusmodser)
mtos(coexcirmod, coexcirmodser)
'find the bottom 15 percentile threshold for the stock market controls, and convert them into vectors
vector(3105) vthreshdowj
vector(3105) vthreshiseq
vector(3105) vthreshn100
vector(3105) vthreshnasdaq
stomna(threshdowj,vthreshdowj)
stomna(threshiseq,vthreshiseq)
stomna(threshn100,vthreshn100)
stomna(threshnasdaq,vthreshnasdaq)
vector(3105) vwrdowj
vector(3105) vwriseq
vector(3105) vwrn100
vector(3105) vwrnasdaq
stomna(wrdowj,vwrdowj)
stomna(wriseq,vwriseq)
stomna(wrn100,vwrn100)
stomna(wrnasdaq,vwrnasdaq)
'create an indicator vector for each stock market control to hold 1 if the return is in the bottom 5 percentile of the
disctribution of weekly returns
vector(3105) inddowj
vector(3105) indiseq
vector(3105) indn100
vector(3105) indnasdaq
for !i = 1 to 3105
if vwrdowj(!i) < vthreshdowj(!i) then
inddowj(!i) = 1
else inddowj(!i) = 0
endif
next
'create indicator vector for all stock market shocksnote that N100 data only starts from 2000, which is why the
variable indstmkt can only take a maximum of 2 before 2000 and a maximum of 3 after 2000.
vector(3105) indstmkt
indstmkt = indiseq + indn100 + indnasdaq
mtos(indstmkt, indstmktser)
'calculate the weekly change in the slope of the yield curve for Irelandthis was not used in the paper as data on
gigb1yr only started from 2005.
'run a GARCH(1,1) using the stock market returns calculated above, and save the variances
smpl @all
'----------------------------------------------------------------------------------
'correlations b/w the change in dd's of Ireland's and other countries' systems
smpl @all
'-----------------------------------------------------------------------------
'correlations b/w the % change in dd's of Ireland's and lags of other countries' systems
smpl @all
'--------------------------------------------------------------------------------
'compute rolling correlations b/w dd's of Ireland's and other countries' systems - for all country pairs
smpl @all
vector(3105) rolcoriruk
vector(3105) rolcorirus
vector(3105) rolcorirger
vector(3105) rolcorirnl
vector(3105) rolcorirfr
vector(3105) rolcoririt
vector(3105) rolcorirsp
vector(3105) rolcorukus
vector(3105) rolcorukger
vector(3105) rolcoruknl
vector(3105) rolcorukfr
vector(3105) rolcorukit
vector(3105) rolcoruksp
vector(3105) rolcorusger
vector(3105) rolcorusnl
vector(3105) rolcorusfr
vector(3105) rolcorusit
vector(3105) rolcorussp
vector(3105) rolcorgernl
vector(3105) rolcorgerfr
vector(3105) rolcorgerit
vector(3105) rolcorgersp
vector(3105) rolcornlfr
vector(3105) rolcornlit
vector(3105) rolcornlsp
vector(3105) rolcorfrit
vector(3105) rolcorfrsp
vector(3105) rolcoritsp
rolcoriruk(!k+1+259)=@cor(irsysdd, uksysdd)
rolcorirus(!k+1+259)=@cor(irsysdd, ussysdd)
rolcorirger(!k+1+259)=@cor(irsysdd, bdsysdd)
rolcorirnl(!k+1+259)=@cor(irsysdd, nlsysdd)
rolcorirfr(!k+1+259)=@cor(irsysdd, frsysdd)
rolcoririt(!k+1+259)=@cor(irsysdd, itsysdd)
rolcorirsp(!k+1+259)=@cor(irsysdd, essysdd)
rolcorukus(!k+1+259)=@cor(uksysdd, ussysdd)
rolcorukger(!k+1+259)=@cor(uksysdd, bdsysdd)
rolcoruknl(!k+1+259)=@cor(uksysdd, nlsysdd)
rolcorukfr(!k+1+259)=@cor(uksysdd, frsysdd)
rolcorukit(!k+1+259)=@cor(uksysdd, itsysdd)
rolcoruksp(!k+1+259)=@cor(uksysdd, essysdd)
rolcorusger(!k+1+259)=@cor(ussysdd, bdsysdd)
rolcorusnl(!k+1+259)=@cor(ussysdd, nlsysdd)
9
rolcorusfr(!k+1+259)=@cor(ussysdd, frsysdd)
rolcorusit(!k+1+259)=@cor(ussysdd, itsysdd)
rolcorussp(!k+1+259)=@cor(ussysdd, essysdd)
rolcorgernl(!k+1+259)=@cor(bdsysdd, nlsysdd)
rolcorgerfr(!k+1+259)=@cor(bdsysdd, frsysdd)
rolcorgerit(!k+1+259)=@cor(bdsysdd, itsysdd)
rolcorgersp(!k+1+259)=@cor(bdsysdd, essysdd)
rolcornlfr(!k+1+259)=@cor(nlsysdd, frsysdd)
rolcornlit(!k+1+259)=@cor(nlsysdd, itsysdd)
rolcornlsp(!k+1+259)=@cor(nlsysdd, essysdd)
rolcorfrit(!k+1+259)=@cor(frsysdd, itsysdd)
rolcorfrsp(!k+1+259)=@cor(frsysdd, essysdd)
rolcoritsp(!k+1+259)=@cor(itsysdd, essysdd)
next
vector(3105) rolcoravg
for !i = 1 to 3105
rolcoravg(!i) = (rolcoriruk(!i) + rolcorirus(!i) + rolcorirger(!i) + rolcorirnl(!i) + rolcorirfr(!i) + rolcoririt(!i) +
rolcorirsp(!i) + rolcorukus(!i) + rolcorukger(!i) + rolcoruknl(!i) + rolcorukfr(!i) + rolcorukit(!i) + rolcoruksp(!i) +
rolcorusger(!i) + rolcorusnl(!i) + rolcorusfr(!i) + rolcorusit(!i) + rolcorussp(!i) + rolcorgernl(!i) + rolcorgerfr(!i) +
rolcorgerit(!i) + rolcorgersp(!i) + rolcornlfr(!i) + rolcornlit(!i) + rolcornlsp(!i) + rolcorfrit(!i) + rolcorfrsp(!i) +
rolcoritsp(!i))/28
next
smpl @all
mtos(rolcoravg, rolcoravgser)
mtos(rolcoriruk, rolcorirukser)
mtos(rolcorirus, rolcorirusser)
mtos(rolcorirger, rolcorirgerser)
mtos(rolcorirnl, rolcorirnlser)
mtos(rolcorirfr, rolcorirfrser)
mtos(rolcoririt, rolcoriritser)
mtos(rolcorirsp, rolcorirspser)
'HP filter
for %C avg iruk irus irger irnl irfr irit irsp
rolcor{%C}ser.hpf hpt_rolcor{%C}
next
'---------------------------------------------------------------------------------------------------------------
'compute rolling correlations b/w the % change in dd's of Ireland's and other countries' systems - for all country
pairs
smpl @all
vector(3105) wrolcoriruk
vector(3105) wrolcorirus
vector(3105) wrolcorirger
vector(3105) wrolcorirnl
vector(3105) wrolcorirfr
vector(3105) wrolcoririt
vector(3105) wrolcorirsp
10
vector(3105) wrolcorukus
vector(3105) wrolcorukger
vector(3105) wrolcoruknl
vector(3105) wrolcorukfr
vector(3105) wrolcorukit
vector(3105) wrolcoruksp
vector(3105) wrolcorusger
vector(3105) wrolcorusnl
vector(3105) wrolcorusfr
vector(3105) wrolcorusit
vector(3105) wrolcorussp
vector(3105) wrolcorgernl
vector(3105) wrolcorgerfr
vector(3105) wrolcorgerit
vector(3105) wrolcorgersp
vector(3105) wrolcornlfr
vector(3105) wrolcornlit
vector(3105) wrolcornlsp
vector(3105) wrolcorfrit
vector(3105) wrolcorfrsp
vector(3105) wrolcoritsp
wrolcoriruk(!k+1+259)=@cor(wirsys, wuksys)
wrolcorirus(!k+1+259)=@cor(wirsys, wussys)
wrolcorirger(!k+1+259)=@cor(wirsys, wbdsys)
wrolcorirnl(!k+1+259)=@cor(wirsys, wnlsys)
wrolcorirfr(!k+1+259)=@cor(wirsys, wfrsys)
wrolcoririt(!k+1+259)=@cor(wirsys, witsys)
wrolcorirsp(!k+1+259)=@cor(wirsys, wessys)
wrolcorukus(!k+1+259)=@cor(wuksys, wussys)
wrolcorukger(!k+1+259)=@cor(wuksys, wbdsys)
wrolcoruknl(!k+1+259)=@cor(wuksys, wnlsys)
wrolcorukfr(!k+1+259)=@cor(wuksys, wfrsys)
wrolcorukit(!k+1+259)=@cor(wuksys, witsys)
wrolcoruksp(!k+1+259)=@cor(wuksys, wessys)
wrolcorusger(!k+1+259)=@cor(wussys, wbdsys)
wrolcorusnl(!k+1+259)=@cor(wussys, wnlsys)
wrolcorusfr(!k+1+259)=@cor(wussys, wfrsys)
wrolcorusit(!k+1+259)=@cor(wussys, witsys)
wrolcorussp(!k+1+259)=@cor(wussys, wessys)
wrolcorgernl(!k+1+259)=@cor(wbdsys, wnlsys)
wrolcorgerfr(!k+1+259)=@cor(wbdsys, wfrsys)
wrolcorgerit(!k+1+259)=@cor(wbdsys, witsys)
wrolcorgersp(!k+1+259)=@cor(wbdsys, wessys)
wrolcornlfr(!k+1+259)=@cor(wnlsys, wfrsys)
wrolcornlit(!k+1+259)=@cor(wnlsys, witsys)
wrolcornlsp(!k+1+259)=@cor(wnlsys, wessys)
wrolcorfrit(!k+1+259)=@cor(wfrsys, witsys)
11
wrolcorfrsp(!k+1+259)=@cor(wfrsys, wessys)
wrolcoritsp(!k+1+259)=@cor(witsys, wessys)
next
vector(3105) wrolcoravg
for !i = 1 to 3105
wrolcoravg(!i) = (wrolcoriruk(!i) + wrolcorirus(!i) + wrolcorirger(!i) + wrolcorirnl(!i) + wrolcorirfr(!i) +
wrolcoririt(!i) + wrolcorirsp(!i) + wrolcorukus(!i) + wrolcorukger(!i) + wrolcoruknl(!i) + wrolcorukfr(!i) + wrolcorukit(!i)
+ wrolcoruksp(!i) + wrolcorusger(!i) + wrolcorusnl(!i) + wrolcorusfr(!i) + wrolcorusit(!i) + wrolcorussp(!i) +
wrolcorgernl(!i) + wrolcorgerfr(!i) + wrolcorgerit(!i) + wrolcorgersp(!i) + wrolcornlfr(!i) + wrolcornlit(!i) +
wrolcornlsp(!i) + wrolcorfrit(!i) + wrolcorfrsp(!i) + wrolcoritsp(!i))/28
next
smpl @all
mtos(wrolcoravg, wrolcoravgser)
mtos(wrolcoriruk, wrolcorirukser)
mtos(wrolcorirus, wrolcorirusser)
mtos(wrolcorirger, wrolcorirgerser)
mtos(wrolcorirnl, wrolcorirnlser)
mtos(wrolcorirfr, wrolcorirfrser)
mtos(wrolcoririt, wrolcoriritser)
mtos(wrolcorirsp, wrolcorirspser)
'HP filter
for %C avg iruk irus irger irnl irfr irit irsp
wrolcor{%C}ser.hpf hpt_wrolcor{%C}
next
'---------------------------------------------------------------------------------------------------------------
'compute rolling correlations b/w dd's of the Irish banks and US, UK, and GER
smpl @all
vector(3105) rolcorir1uk
vector(3105) rolcorir2uk
vector(3105) rolcorir3uk
vector(3105) rolcorir1us
vector(3105) rolcorir2us
vector(3105) rolcorir3us
vector(3105) rolcorir1ger
vector(3105) rolcorir2ger
vector(3105) rolcorir3ger
rolcorir1uk(!k+1+259)=@cor(irbdd1, uksysdd)
rolcorir1us(!k+1+259)=@cor(irbdd1, ussysdd)
rolcorir1ger(!k+1+259)=@cor(irbdd1, bdsysdd)
rolcorir2uk(!k+1+259)=@cor(irbdd2, uksysdd)
rolcorir2us(!k+1+259)=@cor(irbdd2, ussysdd)
rolcorir2ger(!k+1+259)=@cor(irbdd2, bdsysdd)
12
rolcorir3uk(!k+1+259)=@cor(irbdd3, uksysdd)
rolcorir3us(!k+1+259)=@cor(irbdd3, ussysdd)
rolcorir3ger(!k+1+259)=@cor(irbdd3, bdsysdd)
next
smpl @all
mtos(rolcorir1uk, rolcorir1ukser)
mtos(rolcorir1us, rolcorir1usser)
mtos(rolcorir1ger, rolcorir1gerser)
mtos(rolcorir2uk, rolcorir2ukser)
mtos(rolcorir2us, rolcorir2usser)
mtos(rolcorir2ger, rolcorir2gerser)
mtos(rolcorir3uk, rolcorir3ukser)
mtos(rolcorir3us, rolcorir3usser)
mtos(rolcorir3ger, rolcorir3gerser)
'---------------------------------------------------------------------------------------------------------------
'compute rolling correlations b/w the % change in dd's of Irish banks and US, UK, and GER
smpl @all
vector(3105) wrolcorir1uk
vector(3105) wrolcorir1us
vector(3105) wrolcorir1ger
vector(3105) wrolcorir2uk
vector(3105) wrolcorir2us
vector(3105) wrolcorir2ger
vector(3105) wrolcorir3uk
vector(3105) wrolcorir3us
vector(3105) wrolcorir3ger
wrolcorir1uk(!k+1+259)=@cor(wdir1, wuksys)
wrolcorir1us(!k+1+259)=@cor(wdir1, wussys)
wrolcorir1ger(!k+1+259)=@cor(wdir1, wbdsys)
wrolcorir2uk(!k+1+259)=@cor(wdir2, wuksys)
wrolcorir2us(!k+1+259)=@cor(wdir2, wussys)
wrolcorir2ger(!k+1+259)=@cor(wdir2, wbdsys)
wrolcorir3uk(!k+1+259)=@cor(wdir3, wuksys)
wrolcorir3us(!k+1+259)=@cor(wdir3, wussys)
wrolcorir3ger(!k+1+259)=@cor(wdir3, wbdsys)
next
smpl @all
mtos(wrolcorir1uk, wrolcorir1ukser)
mtos(wrolcorir1us, wrolcorir1usser)
mtos(wrolcorir1ger, wrolcorir1gerser)
mtos(wrolcorir2uk, wrolcorir2ukser)
mtos(wrolcorir2us, wrolcorir2usser)
13
mtos(wrolcorir2ger, wrolcorir2gerser)
mtos(wrolcorir3uk, wrolcorir3ukser)
mtos(wrolcorir3us, wrolcorir3usser)
mtos(wrolcorir3ger, wrolcorir3gerser)
smpl @all
'Ordered logit regression: Options: d=arg (default="n"): Specify likelihood: normal likelihood function, ordered
probit ("n" ), logistic likelihood function, ordered logit ("l"), Type I extreme value likelihood function, ordered
Gompit ("x").
'equation eql1.ordered(d=l) coexcirser c coexcirser(-1) indstmktser yieldcurve voliseq volnasdaq ---------- add
yield curve when available
'----------------------------------------------------------------------------------------
'add interest rate
'vector(3105) coexcbankir1
'vector(3105) coexcbankir2
'vector(3105) coexcbankir3
'coexcbankir1=@columnextract(coexc,11)
'coexcbankir2=@columnextract(coexc,12)
'coexcbankir3=@columnextract(coexc,13)
'mtos(coexcbankir1,coexcbankir1ser)
'mtos(coexcbankir2,coexcbankir2ser)
14
'mtos(coexcbankir3,coexcbankir3ser)
'ordered logit regression, --- interest rate not in shorter regressions !!!:
'----------- short version of model does not contain interest rates !!!!!: