Dynamic conditional correlation multivariate GARCH
Moderators: EViews Gareth, EViews Moderator
Re: Dynamic conditional correlation multivariate GARCH
does anybody know how to incorporate asymmetry in DCCGARCH model? i will be grateful to you if somebody can provide me asymmetric DCCGARCH programme?
thanking you
thanking you
Re: Dynamic conditional correlation multivariate GARCH
Hey!
The above given code works very well for estimating the DCCGARCH, but as I understand it, the code uses the whole sample to estimate the correlation and uses that sample to estimate the correlation at each time t.
In my study, I want to use the DCCGARCH in the bivariate case and roll a insample period of for say 500 observations to forecast an outofsample of, say 800 obervations. I want it to be a rollingwindow forecast, shifting the insample 1period ahead when forecasting the next days correlation. I tried to modify the code but wasn't even close to succeeding. Can anyone help me with this?
Regards
The above given code works very well for estimating the DCCGARCH, but as I understand it, the code uses the whole sample to estimate the correlation and uses that sample to estimate the correlation at each time t.
In my study, I want to use the DCCGARCH in the bivariate case and roll a insample period of for say 500 observations to forecast an outofsample of, say 800 obervations. I want it to be a rollingwindow forecast, shifting the insample 1period ahead when forecasting the next days correlation. I tried to modify the code but wasn't even close to succeeding. Can anyone help me with this?
Regards

 Posts: 1
 Joined: Tue Jul 19, 2011 5:48 am
Re: Dynamic conditional correlation multivariate GARCH
Hi everybody,
I have managed to use the code provided kindly by hvtcapollo and produced reasonable rho values.
Probably an easy question but im not an expert in statistics, which of the series in the code gives the values of the conditional variances/st devs? (is it var_z1 and var_z2 or Z1/Z2 or something else)
please help. I need to know urgently
thanks a lot
I have managed to use the code provided kindly by hvtcapollo and produced reasonable rho values.
Probably an easy question but im not an expert in statistics, which of the series in the code gives the values of the conditional variances/st devs? (is it var_z1 and var_z2 or Z1/Z2 or something else)
please help. I need to know urgently
thanks a lot
Re: Dynamic conditional correlation multivariate GARCH
Hvtcapollo wrote:You can consider this code. I used it last year for my research and you should be ok if using it for the bivariate. For trivariate u need to modify a litle bit especially for the log likelihood function.Code: Select all
'change path to program path
%path=@runpath
cd %path
'load workfile containing the return series
load nikkei_sp.WF1
'set sample range
sample s1 1/06/1995 12/25/2007
scalar pi=3.14159
'defining the return series in terms of y1 and y2
series y1=r_nikkei
series y2=r_sp
'fitting univariate GARCH(1,1) models to each of the two returns series
equation eq_y1.arch(1,1,m=1000,h) y1 c
equation eq_y2.arch(1,1,m=1000,h) y2 c
'extract the standardized residual series from the GARCH fit
eq_y1.makeresids(s) z1
eq_y2.makeresids(s) z2
'extract garch series from univariate fit
eq_y1.makegarch() garch1
eq_y2.makegarch() garch2
'Caculate sample variance of series z1, z2 and covariance of z1and z2 and correlation between z1 and z2
scalar var_z1=@var(z1)
scalar var_z2=@var(z2)
scalar cov_z1z2=@cov(z1,z2)
scalar corr12=@cor(z1,z2)
'defining the starting values for the var(z1) var(z2) and covariance (z1,z2)
series var_z1t=var_z1
series var_z2t=var_z2
series cov_z1tz2t=cov_z1z2
'declare the coefficient starting values
coef(2) T
T(1)=0.2
T(2)=0.7
' ...........................................................
' LOG LIKELIHOOD for correlation part
' set up the likelihood
' 1) open a new blank likelihood object and name it 'dcc'
' 2) specify the log likelihood model by append
' ...........................................................
logl dcc
dcc.append @logl logl
'specify var_z1t, var_z2t, cov_z1tz2t
dcc.append var_z1t=@nan(1T(1)T(2)+T(1)*(z1(1)^2)+T(2)*var_z1t(1),1)
dcc.append var_z2t=@nan(1T(1)T(2)+T(1)*(z2(1)^2)+T(2)*var_z2t(1),1)
dcc.append cov_z1tz2t=@nan((1T(1)T(2))*corr12+T(1)*z1(1)*z2(1)+T(2)*cov_z1tz2t(1),1)
dcc.append pen=(var_z1t<0)+(var_z2t<0)
'specify rho12
dcc.append rho12=cov_z1tz2t/@sqrt(@abs(var_z1t*var_z2t))
'defining the determinant of correlation matrix and determinant of Dt
dcc.append detrRt=(1(rho12^2))
dcc.append detrDt=@sqrt(garch1*garch2)
dcc.append pen=pen+(detrRt<0)
dcc.append detrRt=@abs(detrRt)
'define the log likelihood function
dcc.append logl=(1/2)*(2*log(2*pi)+log(detrRt)+(z1^2+z2^22*rho12*z1*z2)/detrRt)10*pen
'estimate the model
smpl s1
dcc.ml(showopts, m=500, c=1e5)
'display output and graphs
show dcc.output
graph corr.line rho12
show corr
thanks for the code!
i wonder how to compute q11,t and q22,t from the DCC model and save them seperately please?

 Posts: 2
 Joined: Thu Nov 17, 2011 4:28 am
Re: Dynamic conditional correlation multivariate GARCH
i am not able to get answers with this code.
is this code incomplete??
please help.
is this code incomplete??
please help.

 Posts: 2
 Joined: Thu Nov 17, 2011 4:28 am
Re: Dynamic conditional correlation multivariate GARCH
hello,
i am not able to generate logl series with the above program. thus i am not able to reach the final results. kindly help me in solving this problem.
thnk you..
i am not able to generate logl series with the above program. thus i am not able to reach the final results. kindly help me in solving this problem.
thnk you..

 Posts: 1
 Joined: Tue Mar 05, 2013 11:23 pm
Re: Dynamic conditional correlation multivariate GARCH
Hello to all,
I'm currently trying to using this code I copied from another post and modified it to allow assymetries (ADCC). I'm trying to testing contagion on index returns series...
I don't understand the following error message that Eviews 6 shows:
Missing values in @LOGL series at current coefficients at observation 1/24/1993 in "DO_DCC.ML(B,SHOWOPTS,M=1000,C=1E5)"
Could anyone help me with this?
Thanks in advance.
I'm currently trying to using this code I copied from another post and modified it to allow assymetries (ADCC). I'm trying to testing contagion on index returns series...
Code: Select all
'ADCC Model by Cappiello et al (2006)
'Load workfile and measure length of series
series obscount = 1
scalar obslength = @sum(obscount)
'Specify the return series
series y1 = bovespa
series y2 = igbvl
'Specify the number of iterations in the MLE (Engle & Sheppard (2001) used just one iteration)
!itermle = 1000
'Specify the initial values of the parameters
coef(1) alpha
coef(1) beta
coef(1) gamma
'Values may vary depending on which will result in the highest Likelihood value
alpha(1) = 0.04
beta(1) = 0.94
gamma(1) = 0.02
'Setting the sample
sample s0 @first+1 @last
sample s1 @first+2 @last
sample sf @first+3 @last
sample sf_alt @first+13 @last
'Initialization at sample s0
smpl s0
'Each return series is modeled with their respective GARCH specifications:
'Use BollerslevWooldridge QML
'Standard errors
equation eq1.arch(1,1,thrsh=1,m=1000,c=1e5,h) y1 c y1(1) 'res_s11_1000 @ res_s11_1000
equation eq2.arch(1,1,thrsh=1,m=1000,c=1e5,h) y2 c y2(1) 'res_s22_1000 @ res_s22_1000
'Make residual series
eq1.makeresids e1
eq2.makeresids e2
'Make a garch series from the univariate estimates
eq1.makegarch h11
eq2.makegarch h22
'Normalizing the residuals from e to e* (named as "e1n" and "e2n")
series e1n = e1/h11^0.5
series e2n = e2/h22^0.5
'Make residual series for asymmetries in DCC model
series n1n = @recode(e1n<0,e1n*e1n,0)
series n2n = @recode(e2n<0,e2n*e2n,0)
'The Q_bar=E[en*en'] components and its sample equivalent
series qbar11 = @mean(e1n*e1n)
series qbar12 = @mean(e1n*e2n)
series qbar21 = @mean(e2n*e1n)
series qbar22 = @mean(e2n*e2n)
'The N_bar
series nbar11 = @mean(n1n*n1n)
series nbar12 = @mean(n1n*n2n)
series nbar21 = @mean(n2n*n1n)
series nbar22 = @mean(n2n*n2n)
'The (en*en') matrix components
series e11n = e1n*e1n
series e12n = e1n*e2n
series e21n = e2n*e1n
series e22n = e2n*e2n
'The (nn*nn') matrix components
series n11n = n1n*n1n
series n12n = n1n*n2n
series n21n = n2n*n1n
series n22n = n2n*n2n
'Initialize the elements of Qt for variance targeting
series q11 = @var(e1)
series q12 = @cov(e1,e2)
series q21 = @cov(e2,e1)
series q22 = @var(e2)
'***********************************************************************************************
'Declare a Loglikelihood object
logl dcc
dcc.append @logl logl
'The elements of matrix Qt
dcc.append q11 = (qbar11  (alpha(1))^2*qbar11  (beta(1))^2*qbar11 + (gamma(1))^2*nbar11) + (alpha(1))^2*e11n(1) + (gamma(1))^2*n11n(1) + (beta(1))^2*q11(1)
dcc.append q12 = (qbar12  (alpha(1))^2*qbar12  (beta(1))^2*qbar12 + (gamma(1))^2*nbar12) + (alpha(1))^2*e12n(1) + (gamma(1))^2*n12n(1) + (beta(1))^2*q12(1)
dcc.append q21 = (qbar21  (alpha(1))^2*qbar21  (beta(1))^2*qbar21 + (gamma(1))^2*nbar21) + (alpha(1))^2*e21n(1) + (gamma(1))^2*n21n(1) + (beta(1))*2*q21(1)
dcc.append q22 = (qbar22  (alpha(1))^2*qbar22  (beta(1))^2*qbar22 + (gamma(1))^2*nbar22) + (alpha(1))^2*e22n(1) + (gamma(1))^2*n22n(1) + (beta(1))^2*q22(1)
'As input to detQQQ
dcc.append q12n = ((qbar11  (alpha(1))^2*qbar11  (beta(1))^2*qbar11 + (gamma(1))^2*nbar11) + (alpha(1))^2*e11n(1) + (gamma(1))^2*n11n(1) + (beta(1))^2*q11(1))/((abs(q11)^0.5)*(abs(q22)^0.5))
dcc.append q21n = ((qbar21  (alpha(1))^2*qbar21  (beta(1))^2*qbar21 + (gamma(1))^2*nbar21) + (alpha(1))^2*e21n(1) + (gamma(1))^2*n21n(1) + (beta(1))*2*q21(1))/((abs(q22)^0.5)*(abs(q11)^0.5))
'Setting up the Loglikelihood function, assuming that resid ~ N(0,H)
'The Loglikelihood function is L' = 0.5*{summation from t=1 to T of ([log of determinant of inverse(diag[Qt])*Qt*inverse(diag[Qt])] + [en'*inverse(diag[Qt])*Qt*inverse(diag[Qt])*en])
'Taking the adjoint{inverse(diag[Qt])*Qt*inverse(diag[Qt])}
dcc.append detQQQ = 1  q12n*q21n
'Tomando el adjoint{inverse(diag[Qt])*Qt*inverse(diag[Qt])}
dcc.append cofact11 = 1*1
dcc.append cofact12 =(1)*q21n
dcc.append cofact21 =(1)*q12n
dcc.append cofact22 = 1*1
'Taking the inverse{inverse(diag[Qt])*Qt*inverse(diag[Qt])}
dcc.append invQQQ11 = cofact11/detQQQ
dcc.append invQQQ12 = cofact12/detQQQ
dcc.append invQQQ21 = cofact21/detQQQ
dcc.append invQQQ22 = cofact22/detQQQ
'Taking the en'*inverse{inverse(diag[Qt])*Qt*inverse(diag[Qt])}*en
dcc.append enQQQen11 = e1n*invQQQ11*e1n
dcc.append enQQQen12 = e1n*invQQQ12*e2n
dcc.append enQQQen21 = e2n*invQQQ21*e1n
dcc.append enQQQen22 = e2n*invQQQ22*e2n
'Append the loglikelihood function
'Instead of log(detQQQ) use log(abs(detQQQ))
dcc.append logl = 0.5*(log(abs(detQQQ)) + (enQQQen11+enQQQen21+ enQQQen12+enQQQen22))
'Specifies the sample data where the estimation will be made
smpl s1
'Estimates the parameters now using BHHH algorithm
dcc.ml(b, showopts, m=!itermle, c=1e5)
'A detQQQnpd = 0 indicates detQQQ is positive definite
series count = (detQQQ<=0)
scalar detQQQnpd = @sum(count)
'Display the estimated parameters
show dcc.output
'Forecast the q's by initializing them
series q11f = 0
series q12f = 0
series q21f = 0
series q22f = 0
'Specify the sample period to be forecasted
smpl sf
series q11f = (qbar11  (alpha(1))^2*qbar11  (beta(1))^2*qbar11 + (gamma(1))^2*nbar11) + (alpha(1))^2*e11n(1) + (gamma(1))^2*n11n(1) + (beta(1))^2*q11(1)
series q12f = (qbar12  (alpha(1))^2*qbar12  (beta(1))^2*qbar12 + (gamma(1))^2*nbar12) + (alpha(1))^2*e12n(1) + (gamma(1))^2*n12n(1) + (beta(1))^2*q12(1)
series q21f = (qbar21  (alpha(1))^2*qbar21  (beta(1))^2*qbar21 + (gamma(1))^2*nbar21) + (alpha(1))^2*e21n(1) + (gamma(1))^2*n21n(1) + (beta(1))*2*q21(1)
series q22f = (qbar22  (alpha(1))^2*qbar22  (beta(1))^2*qbar22 + (gamma(1))^2*nbar22) + (alpha(1))^2*e22n(1) + (gamma(1))^2*n22n(1) + (beta(1))^2*q22(1)
'To plot the timevarying conditional correlation
smpl sf_alt
series rt = q12f/(@sqr(q11f)*@sqr(q22f))
graph rtgraph.line rt
show rtgraph
delete e1n e2n
delete q12n q21n
delete n1n n2n
delete n11n n12n n21n n22n
delete e11n e12n e21n e22n
delete qbar*
delete xbar*
delete cofact*
delete enqqqen*
delete invqqq*
delete enqqqen*
delete eigenvect*
delete invqqq*
show detqqqnpd
series eigmins
scalar eigmin
for !j = 4 to obslength
'Input the hijsim to the elements of a 2x2 Q matrix
sym(2) Q
Q(1,1) = q11f(!j)
Q(2,1) = q21f(!j)
Q(2,2) = q22f(!j)
'Take the eigenvalues of Q
vector(4) Qeigenval
Qeigenval = @eigenvalues(Q)
'Collect the min eigenvalues in each Qt
eigmins(!j) = @min(Qeigenval)
next
eigmin = @min(eigmins)
show eigmin
I don't understand the following error message that Eviews 6 shows:
Missing values in @LOGL series at current coefficients at observation 1/24/1993 in "DO_DCC.ML(B,SHOWOPTS,M=1000,C=1E5)"
Could anyone help me with this?
Thanks in advance.
Re: Dynamic conditional correlation multivariate GARCH
Carefully place your sample periods. For instance, you should use "smpl sf" instead of "smpl s1" before calling the estimation algorithm...
Re: Dynamic conditional correlation multivariate GARCH
I am having trouble extending the DCC code to the trivariate case... Please help!!
Re: Dynamic conditional correlation multivariate GARCH
Dear trubador,
I used the codes you provided for DCCGARCH for eviews 5.0 and got the warning message "unmatched parenthesis" after typing the code"dcc.ml(showopts, m=500, c=1e5)". Would you please enlighten me how to solve the problem? Thank you very much
I used the codes you provided for DCCGARCH for eviews 5.0 and got the warning message "unmatched parenthesis" after typing the code"dcc.ml(showopts, m=500, c=1e5)". Would you please enlighten me how to solve the problem? Thank you very much
Re: Dynamic conditional correlation multivariate GARCH
The code is not mine.
I am not sure if anything specific to version 5 is going on, but the message is pretty clear: There is at least one missing bracket somewhere in the code that you are currently using.
I am not sure if anything specific to version 5 is going on, but the message is pretty clear: There is at least one missing bracket somewhere in the code that you are currently using.
Re: Dynamic conditional correlation multivariate GARCH
Hi Trubador,
I have trouble running the ADCC code on the attached data set.
It keeps saying missing values at 11/09/2007. This is a random date in the middle of my workfile.
I cannot understand what the problem might be! I have checked the starting values yet nothing seems to help.
Any ideas? Much appreciated!
I have trouble running the ADCC code on the attached data set.
It keeps saying missing values at 11/09/2007. This is a random date in the middle of my workfile.
I cannot understand what the problem might be! I have checked the starting values yet nothing seems to help.
Any ideas? Much appreciated!
 Attachments

 trial2.wf1
 (88.83 KiB) Downloaded 528 times

 trial_adcc_code.docx
 (16.66 KiB) Downloaded 632 times
Re: Dynamic conditional correlation multivariate GARCH
There is a typo in your likelihood specification, which leads to explosive behavior:
dcc.append q21 = (qbar21  (alpha(1))^2*qbar21  (beta(1))^2*qbar21 + (gamma(1))^2*nbar21) + (alpha(1))^2*e21n(1) + (gamma(1))^2*n21n(1) + (beta(1))*2*q21(1)
Just replace the red part with ^
dcc.append q21 = (qbar21  (alpha(1))^2*qbar21  (beta(1))^2*qbar21 + (gamma(1))^2*nbar21) + (alpha(1))^2*e21n(1) + (gamma(1))^2*n21n(1) + (beta(1))*2*q21(1)
Just replace the red part with ^
Re: Dynamic conditional correlation multivariate GARCH
Thanks so much!!!!
Re: Dynamic conditional correlation multivariate GARCH
I have seen that there are some other posts about this but none of the answers seem to make any difference for me: the problem is that when I run the LOGL I get up that I have missing values....
If anybody could help that would be brilliant as I have not much experience in this area (which is also why the code I am using is not mine but one I found in this forum)
For info purposes: I am running a spot price against a portfolio  both weekly returns
'change path to program path
%path=@runpath
cd %path
'load workfile containing the return series
load spot_pfh.WF1
'set sample range
sample s1 1/07/2000 6/09/2006
scalar pi=3.14159
'defining the return series in terms of y1 and y2
series y1=spot
series y2=pf_h
'fitting univariate GARCH(1,1) models to each of the two returns series
equation eq_y1.arch(1,1,m=1000,h) y1 c
equation eq_y2.arch(1,1,m=1000,h) y2 c
'extract the standardized residual series from the GARCH fit
eq_y1.makeresids(s) z1
eq_y2.makeresids(s) z2
'extract garch series from univariate fit
eq_y1.makegarch() garch1
eq_y2.makegarch() garch2
'Caculate sample variance of series z1, z2 and covariance of z1and z2 and correlation between z1 and z2
scalar var_z1=@var(z1)
scalar var_z2=@var(z2)
scalar cov_z1z2=@cov(z1,z2)
scalar corr12=@cor(z1,z2)
'defining the starting values for the var(z1) var(z2) and covariance (z1,z2)
series var_z1t=var_z1
series var_z2t=var_z2
series cov_z1tz2t=cov_z1z2
'declare the coefficient starting values
coef(2) T
T(1)=0.2
T(2)=0.7
logl dcc
dcc.append @logl logl
'specify var_z1t, var_z2t, cov_z1tz2t
dcc.append var_z1t=@nan(1T(1)T(2)+T(1)*(z1(1)^2)+T(2)*var_z1t(1),1)
dcc.append var_z2t=@nan(1T(1)T(2)+T(1)*(z2(1)^2)+T(2)*var_z2t(1),1)
dcc.append cov_z1tz2t=@nan((1T(1)T(2))*corr12+T(1)*z1(1)*z2(1)+T(2)*cov_z1tz2t(1),1)
dcc.append pen=(var_z1t<0)+(var_z2t<0)
'specify rho12
dcc.append rho12=cov_z1tz2t/@sqrt(@abs(var_z1t*var_z2t))
'defining the determinant of correlation matrix and determinant of Dt
dcc.append detrRt=(1(rho12^2))
dcc.append detrDt=@sqrt(garch1*garch2)
dcc.append pen=pen+(detrRt<0)
dcc.append detrRt=@abs(detrRt)
'define the log likelihood function
dcc.append logl=(1/2)*(2*log(2*pi)+log(detrRt)+(z1^2+z2^22*rho12*z1*z2)/detrRt)10*pen
'estimate the model
smpl s1
dcc.ml(showopts, m=500, c=1e5)
This is when I get up that I have missing values  again, if anybody has time to help I would very much appreciate it
If anybody could help that would be brilliant as I have not much experience in this area (which is also why the code I am using is not mine but one I found in this forum)
For info purposes: I am running a spot price against a portfolio  both weekly returns
'change path to program path
%path=@runpath
cd %path
'load workfile containing the return series
load spot_pfh.WF1
'set sample range
sample s1 1/07/2000 6/09/2006
scalar pi=3.14159
'defining the return series in terms of y1 and y2
series y1=spot
series y2=pf_h
'fitting univariate GARCH(1,1) models to each of the two returns series
equation eq_y1.arch(1,1,m=1000,h) y1 c
equation eq_y2.arch(1,1,m=1000,h) y2 c
'extract the standardized residual series from the GARCH fit
eq_y1.makeresids(s) z1
eq_y2.makeresids(s) z2
'extract garch series from univariate fit
eq_y1.makegarch() garch1
eq_y2.makegarch() garch2
'Caculate sample variance of series z1, z2 and covariance of z1and z2 and correlation between z1 and z2
scalar var_z1=@var(z1)
scalar var_z2=@var(z2)
scalar cov_z1z2=@cov(z1,z2)
scalar corr12=@cor(z1,z2)
'defining the starting values for the var(z1) var(z2) and covariance (z1,z2)
series var_z1t=var_z1
series var_z2t=var_z2
series cov_z1tz2t=cov_z1z2
'declare the coefficient starting values
coef(2) T
T(1)=0.2
T(2)=0.7
logl dcc
dcc.append @logl logl
'specify var_z1t, var_z2t, cov_z1tz2t
dcc.append var_z1t=@nan(1T(1)T(2)+T(1)*(z1(1)^2)+T(2)*var_z1t(1),1)
dcc.append var_z2t=@nan(1T(1)T(2)+T(1)*(z2(1)^2)+T(2)*var_z2t(1),1)
dcc.append cov_z1tz2t=@nan((1T(1)T(2))*corr12+T(1)*z1(1)*z2(1)+T(2)*cov_z1tz2t(1),1)
dcc.append pen=(var_z1t<0)+(var_z2t<0)
'specify rho12
dcc.append rho12=cov_z1tz2t/@sqrt(@abs(var_z1t*var_z2t))
'defining the determinant of correlation matrix and determinant of Dt
dcc.append detrRt=(1(rho12^2))
dcc.append detrDt=@sqrt(garch1*garch2)
dcc.append pen=pen+(detrRt<0)
dcc.append detrRt=@abs(detrRt)
'define the log likelihood function
dcc.append logl=(1/2)*(2*log(2*pi)+log(detrRt)+(z1^2+z2^22*rho12*z1*z2)/detrRt)10*pen
'estimate the model
smpl s1
dcc.ml(showopts, m=500, c=1e5)
This is when I get up that I have missing values  again, if anybody has time to help I would very much appreciate it
Who is online
Users browsing this forum: No registered users and 11 guests