RATS 11.1
RATS 11.1

Examples /

REPORTMATRIX.RPF

Home Page

← Previous Next →

REPORTMATRIX.RPF uses REPORT to create a cross table of test statistics for pairs of series (in this case "spillover" tests for a BEKK-GARCH model)

 

This does all pairs from a subset of exchange rates from the g10xrate.xls data file. The pseudo-code for the analysis (for N series) looks like this:

 

do i=1,n

   do j=i+1,n

      ...estimate BEKK GARCH model with returns i and j

      ...do spillover test from I to J, place at column I, row J

      ...do spillover test from J to I, place at column J, row I

   end do j

end do i

 

This will create an N x N matrix with an empty diagonal (since there is no spillover from a series to itself) with the "source" of spillover in the column and the target in the row.

 

It also demonstrates how to use the %CHOICE function to * the test statistics with different levels depending upon the marginal significance levels of the test statistics. This is done using the %SIGNIFTAG function (defined here) which can be adjusted as desired to use different criteria.

 

function %%SignifTag signif

type integer %%SignifTag

type real signif

*

if signif<=.001

   compute %%SignifTag=%choice("THREE")

else

if signif<=.01

   compute %%SignifTag=%choice("TWO")

else

if signif<=.05

   compute %%SignifTag=%choice("ONE")

else

   compute %%SignifTag=%choice("NONE")

end

 

The option special=%%signiftag(%signif) on REPORT will convert to SPECIAL=THREE if the SIGNIF value is below .001, SPECIAL=TWO if it's below .01 (but not below .001, since that would be caught by the first branch), etc.

 

 

open data g10xrate.xls

data(format=xls,org=columns) 1 6237 usxjpn usxfra usxsui usxnld usxuk $

   usxbel usxger usxswe usxcan usxita

 

Sweden and Italy have embedded missing values, so this restricts attention to the others

 

dec vect[labels] countries

input(varying) countries

 JPN FRA SUI NLD UK BEL GER CAN

 

This transforms the raw exchange rates to 100*returns, saved into a HASH[SERIES] with keys XJPN, XFRA etc.

 

dec hash[series] returns

dofor [label] suffix = countries

   set returns("X"+suffix) = 100.0*log(%s("usx"+suffix)/%s("usx"+suffix){1})

end dofor

 

This pulls out the keys for the return series:

 

compute rkeys=%keys(returns)

compute n=%size(rkeys)

 

This initializes the REPORT and fills the first row and first column with the country labels (those will start at column 2 and row 2 respectively):

 

report(action=define)

report(atrow=1,atcol=2) countries

report(atcol=1,atrow=2,fillby=cols) countries

 

This is the inner working of the pseudo-code loop from above. It first estimates the BEKK model on the I and J returns;

 

garch(p=1,q=1,mv=bekk) / returns(rkeys(i)) returns(rkeys(j))

     

With a two-variable BEKK GARCH model, the C's take up the first three positions after the mean model, the A's take the next four and the B's take the four after that. The A block is in the order A(1,1), A(1,2), A(2,1) and A(2,2) where A(i,j) is (with the convention that the lead matrix in the BEKK sandwich is transposed) the effect of i on j. So A(1,2) will be in the fifth position after the mean, and A(2,1) in the sixth; B's being placed similarly four positions later. So the test for spillover from the first series to the second is on coefficients %NREGMEAN+5 and %NREGMEAN+9, and the test in the reverse is %NREGMEAN+6 and %NREGMEAN+10.

 

Note that the test statistics are actually placed at rows/columns I+1 and J+1 since row and column 1 are for the labels.

 

      test(print,zeros,title="BEKK Spillover from "+rkeys(i)+" to "+rkeys(j))

      # %nregmean+5 %nregmean+9

      report(atrow=j+1,atcol=i+1,special=%%signiftag(%signif)) %cdstat

      test(print,zeros,title="BEKK Spillover from "+rkeys(j)+" to "+rkeys(i))

      # %nregmean+6 %nregmean+10

      report(atrow=i+1,atcol=j+1,special=%%signiftag(%signif)) %cdstat

 

Generated Report

The output from the program is about 900 lines mainly of BEKK estimates. (There are 28 different models estimated). However, the point is the following report:

 

  


Copyright © 2026 Thomas A. Doan