OPEN DATA data.RAT
CALENDAR(M) 1995:1
DATA(FORMAT=RATS) 1995:01 2012:04 fdLNPROD fdLNCONS fdlnprodp fdlnprodn fdlnconsp fdlnconsn ectp ectn
*
dec vect[string] longlabel(2)
compute longlabel=||"Producer","Consumer"||
*
declare symmetric sigma
compute sigma = || 0.003590615 | 0.002052338, 0.001185478||
*
EQUATION(coeffs=||0.479485073, 0.310031714, -0.980279559, 0.278064995, 0.229983083, -0.450837039, 0.491263724,$
-0.43552196, 0.650737726, -2.111486237, -0.464802421, 2.542571022, 0.079503715, -0.463929477, 0.320131267||, VARIANCE=0.003590615) PRODUCER FDLNPROD
# Constant FDLNPRODP{1 to 3} FDLNPRODN{1 to 3} FDLNCONSP{1 to 3} FDLNCONSN{1 to 3} ECTP{1 to 1} ECTN{1 to 1}
*
EQUATION(coeffs=||0.132871627, 0.560423276, -0.047239207, -0.009115463, 0.505517265, -0.232825082, 0.777583275,$
-0.410853221, 0.954473996, -0.972418217, -0.357604299, 0.890614568, -0.279174244, -0.677653569, -0.578472856||, VARIANCE=0.001185478) consumer fdlncons
# Constant FDLNPRODP{1 to 3} FDLNPRODN{1 to 3} FDLNCONSP{1 to 3} FDLNCONSN{1 to 3} ECTP{1 to 1} ECTN{1 to 1}
*
group reg1tom producer consumer
*
garch(model=reg1tom, mv=bekk, rvectors=rd, hmatrices=hh, robusterrors,$
pmethod=simplex, piters=20, method=bfgs, iters=500)
*
* Convert to equivalent VECH representation
*
@MVGARCHToVECH(mv=bekk)
disp ##.### %%vech_a
*
* Display eigenvalues of persistence matrix
*
eigen(cvalues=cv) %%vech_a+%%vech_b
disp ##.### cv
*
* Multivariate diagnostics
*
dec vect[series] rstd(%nvar)
do time=%regstart(),%regend()
   eigen(scale) hh(time) * eigfac
   compute %pt(rstd,time,%solve(eigfac,rd(time)))
end do time
*
@mvqstat(lags=10)
# rstd
@mvarchtest(lags=2)
# rstd
*
* VECH coefficients with standard errors
*
summarize(title="(1,1) on (1,1)") %beta(10)^2
summarize(title="(1,2) on (1,1)") %beta(10)*%beta(13)*2.0
summarize(title="(2,2) on (1,1)") %beta(13)^2
**********************************************************
*
* The remainder works only with RATS version 8.2 or later
*
dec vect means(%nregmean)
dec packed cx(%nvar,%nvar)
dec rect ax(%nvar,%nvar) bx(%nvar,%nvar)
nonlin(parmset=garchparms) means cx ax bx
summarize(parmset=garchparms) ax(1,1)^2
summarize(parmset=garchparms) ax(1,1)*ax(1,2)*2.0
summarize(parmset=garchparms) ax(1,2)^2
*
compute ncomp=%nvar*(%nvar+1)/2
dec rect %%vech_ase(ncomp,ncomp)
do m=1,ncomp
   do n=1,ncomp
      compute i=%symmrow(m),j=%symmcol(m),$
              k=%symmrow(n),l=%symmcol(n)
      if k==l {
         summarize(noprint,parmset=garchparms) ax(i,k)*ax(j,l)
         compute %%vech_ase(m,n)=sqrt(%varlc)
      }
      else {
         summarize(noprint,parmset=garchparms) $
             ax(i,k)*ax(j,l)+ax(i,l)*ax(j,k)
         compute %%vech_ase(m,n)=sqrt(%varlc)
      }
   end do n
end do m