hi,
I'm Using rats code for two step estimation DCC-GARCH. how and where should i to compute a mean equation r_t=μ+γ_1 r_(t-1)+γ_2 r_(t-1)^us+ε_t
let say if i want to see the DCC-GARCH for US VS ASEAN country.. below are code.
*
OPEN DATA "C:\Users\user\Desktop\msci rats.xls"
CALENDAR(D) 1993:1:1
DATA(FORMAT=XLS,ORG=COLUMNS,SHEET="pre",LEFT=2) 1993:01:01 1996:12:31 USXUS USXMalaysia USXPhilipines USXSingapore $
USXThailand USXIndonesia
*
* 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=6
dec vect[series] x(n)
compute i=0
dofor [string] s = "US" "Malaysia" "Philipines" "Singapore" "Thailand" "Indonesia"
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
You would need to create a MODEL for the mean. This is probably somewhat similar to what you're doing, except that it does a one-step DCC (which should work fine as well with a model the size of yours).
cal(daily) 1990:1:1
open data stock_index_2003.xls
data(org=obs,format=xls) 1990:1:1 2003:3:21
*
compute gstart=1990:1:3 , gend=2003:3:21
*
* Parameters for the regression function
*
dec vect[series] y(10) u(10)
compute fill=0
dofor s = th in mal ko hk jp ph sg tw us
compute fill=fill+1
set y(fill) = 100.0*log(s{0}/s{1})
end dofor s
*
dec vect[equation] asiaeq(9)
do i=1,9
equation asiaeq(i) y(i)
# constant y(i){1} y(10){1}
end do i
*
equation useq y(10)
# constant y(10){1}
group mod10 asiaeq(1) asiaeq(2) asiaeq(3) asiaeq(4) asiaeq(5) asiaeq(6) asiaeq(7) $
asiaeq(8) asiaeq(9) useq
*
garch(model=mod10,mv=dcc,hmatrices=hh,rvectors=uu)
Thank you so much for your help.
1)Let say If i want to use the two step estimation. Is it possible?
2)If its not possible, let say I want to compute the correlation matrix from the code you suggest. how can it be done?
the result that i'm trying to achieve is almost similar to the estimation of this journal http://ideas.repec.org/a/eee/reveco/v20y2011i4p717-732.html
I run the code you suggest..the mean result is what i wanted earlier. However, the result doesn't seem right. the DCC(2)= 0.0000. such as below:
MV-GARCH, DCC - Estimation by BFGS
Convergence in 82 Iterations. Final criterion was 0.0000099 <= 0.0000100
Daily(5) Data From 1993:01:05 To 1996:12:31
Usable Observations 1041
Log Likelihood -8506.6482
You would have to post the program and data for me to see what's happening. However, it looks like variable 6 (U.S.?) has very different GARCH dynamics than the other series. DCC really doesn't work well unless all the series are fairly similar since it forces the joint GARCH dynamics to be explained by just 2 parameters.
1. You have the variables defined wrong. You need US to be at the end of the list since I assume that's the one you want as the 6th variable:
dofor s = MY PH SG TH IND US
compute fill=fill+1
set y(fill) = 100.0*log(s{0}/s{1})
end dofor s
2. You're not going to get a DCC model to fit these data---there just isn't enough similarity. The US data is basically uncorrelated with the other five and even the Asia series are generally only mildly correlated (other than MY and SG). Maybe there are some timing issues with your data?
I've another question. how do i apply the ljung box in my data? is it ok if i just use :
garch(model=mod6,mv=dcc,hmatrices=hh,rvectors=rd) / y
set z1 = rd(t)(1)/sqrt(hh(t)(1,1))
set z2 = rd(t)(2)/sqrt(hh(t)(2,2))
set z3 = rd(t)(3)/sqrt(hh(t)(3,3))
set z4 = rd(t)(4)/sqrt(hh(t)(4,4))
set z5 = rd(t)(5)/sqrt(hh(t)(5,5))
set z6 = rd(t)(6)/sqrt(hh(t)(6,6))
@bdindtests(number=40) z1
@bdindtests(number=40) z2
@bdindtests(number=40) z3
@bdindtests(number=40) z4
@bdindtests(number=40) z5
@bdindtests(number=40) z6
*
* Multivariate Q statistic. This requires transforming the residuals to
* eliminate the time-varying correlations.
*
dec vect[series] zu(%nvar)
do time=%regstart(),%regend()
compute %pt(zu,time,%solve(%decomp(hh(time)),rd(time)))
end do time
@mvqstat(lags=40)
# zu