*
* Creates a Tiao-Box ("Modeling multiple time series with
* applications", JASA, 1981, vol 76, pp 802-816) cross
* correlation matrix with +,- and . symbols for significant
* positive, negative and insignificant cross correlations
* respectively.
*
* Syntax:
*
* @MVIdent(lags=# of lags) start end
* # list of series
*
* Revision Schedule:
*  06/05 Written by Tom Doan, Estima
*
procedure MVIdent start end
type integer start end
option integer lags 12
*
local vect[integer] list
local integer startl endl
local integer i j l n
local vect[rect] mcorr
local vect[rect[label]] lcorr
local series ccorr
*
enter(varying,entries=n) list
*
dim mcorr(lags) lcorr(lags)
ewise mcorr(i)=%zeros(n,n)
do i=1,lags
   dim lcorr(i)(n,n)
end do i
*
inquire(reglist) startl<<start endl<<end
# list
do i=1,n
   do j=1,n
      cross(noprint) list(i) list(j) startl endl 1 lags ccorr
      do l=1,lags
         compute mcorr(l)(i,j)=ccorr(l)
         if ccorr(l)>2.0/sqrt(%nobs)
            compute lcorr(l)(i,j)='+'
         else
         if ccorr(l)<-2.0/sqrt(%nobs)
            compute lcorr(l)(i,j)='-'
         else
            compute lcorr(l)(i,j)='.'
      end do l
   end do j
end do i
*
report(action=define)
do l=1,lags
   report(atrow=1,atcol=(n+1)*(l-1)+(n+1)/2,align=center) 'Lag '+l
   report(atrow=1,atcol=(n+1)*l,align=left) '|'
   report(atrow=2,atcol=(n+1)*(l-1)+1) mcorr(l)
   report(atrow=n+3,atcol=(n+1)*(l-1)+1,align=center) lcorr(l)
end do l
report(action=format,picture='##.###')
report(action=show)
end



