*
* GARCHMVDCC2.RPF
*
* Multivariate GARCH with two-step DCC estimator. This can be used when
* the number of dependent variables gets so large that using the GARCH
* instruction with MV=DCC (which does full information maximum
* likelihood rather than two-step) becomes infeasible.
*
all 6237
open data g10xrate.xls
data(format=xls,org=columns) / usxjpn usxfra usxsui usxnld usxuk usxbel usxger usxcan
*
* Convert exchange rates to returns, and place into the VECT[SERIES] X
* that will be used as the dependent variables in the GARCH model.
*
compute n=8
dec vect[series] x(n)
compute i=0
dofor [string] s = "jpn" "fra" "sui" "nld" "uk" "bel" "ger" "can"
compute xrate="usx"+s,i=i+1
set x(i) = 100.0*log(%s(xrate)/%s(xrate){1})
end dofor
*
dec vect[series] eps(n)
*
* FULLBETA will be the coefficient vector for the full model. This
* includes 4 univariate GARCH coefficients for each of the dependent
* variables, plus the 2 DCC coefficients.
*
dec vect fullbeta(4*n+2)
*
* Do univariate GARCH models. Save the standardized residuals into
* eps(i). Copy the coefficients into the proper slots in the full beta
* matrix.
*
do i=1,n
garch(p=1,q=1,resids=r,hseries=h) / x(i)
set eps(i) = r/sqrt(h)
do j=1,4
compute fullbeta(n*(j-1)+i)=%beta(j)
end do j
end do i
*
* Compute the covariance matrix of the standardized residuals
*
vcv(matrix=rr)
# eps
*
* Create the series[symm] uu (outer product of residuals). Make it the
* unconditional value prior to the sample.
*
dec series[symm] uu q
gset uu %regstart() %regend() = %outerxx(%xt(eps,t))
gset uu 1 %regstart()-1 = rr
gset q = rr
*
* Log likelihood for the DCC phase, taking the residuals as given
*
nonlin a b
dec frml[symm] qf
frml qf = (qx=(1-a-b)*rr+a*uu{1}+b*q{1})
frml logl = q=qf,%logdensity(%cvtocorr(q),%xt(eps,t))
compute b=.80,a=.10
maximize logl 2 *
*
* Insert the estimates into the final two slots in fullbeta
*
compute fullbeta(4*n+1)=%beta(1),fullbeta(4*n+2)=%beta(2)
*
* Do one iteration of the full model with METHOD=BHHH to get
* the grand covariance matrix.
*
garch(p=1,q=1,mv=dcc,method=bhhh,initial=fullbeta,iters=1) / x