Page 1 of 6

Dynamic conditional correlation multivariate GARCH

Posted: Mon Mar 16, 2009 10:22 pm
by kpukthua
Hi

I'm a rigorous Eviews user for research.

Does anyone know how we can write a program to perform Dynamic Conditional Correlation Multivariate GARCH in Eviews?
If you know, please email me at kpukthua@mail.sdsu.edu

My name is Kuntara. Thank you very much!

Re: Dynamic conditional correlation multivariate GARCH

Posted: Fri Mar 20, 2009 4:32 am
by Hvtcapollo
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(1-T(1)-T(2)+T(1)*(z1(-1)^2)+T(2)*var_z1t(-1),1)
dcc.append var_z2t=@nan(1-T(1)-T(2)+T(1)*(z2(-1)^2)+T(2)*var_z2t(-1),1)
dcc.append cov_z1tz2t=@nan((1-T(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^2-2*rho12*z1*z2)/detrRt)-10*pen

'estimate the model
smpl s1
dcc.ml(showopts, m=500, c=1e-5)

'display output and graphs
show dcc.output
graph corr.line rho12
show corr

Re: Dynamic conditional correlation multivariate GARCH

Posted: Sat Mar 28, 2009 11:27 am
by kpukthua
Thank you very much. I really appreciate your help.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Sat Jun 13, 2009 9:07 am
by volantpanda
it is what i m looking for...but how to modify the logl function? i m a new to eviews, and no such a programing book near me...

Re: Dynamic conditional correlation multivariate GARCH

Posted: Sun Jun 14, 2009 2:46 am
by Sulzfalk
I also have a question concerning this code. By now I understand the whole routine, especially why the ML estimator is of the given form for the bivariate case. The only thing I don't understand is the initialization of the parameters T(1) and T(2) for the dynamic equation of the matrix which is normaly denoted as Q_{t} in the literature. If I understood correctly, it is assumed that Q_{t} follows a GARCH(1,1) process as well. But how can I come up with initial values chosen in "a clever way" for the ML-estimation? Is there an alternative way to estimate T(1) and T(2) beforehand which can be used for the ML estimation?
Any help or hints will be highly appreciated :)

Re: Dynamic conditional correlation multivariate GARCH

Posted: Sun Jun 14, 2009 9:13 am
by trubador
For multivariate estimations, getting the starting values from univariate counterparts are considered as a "clever" approach. So, if it is assumed to follow a GARCH(1,1) process, then you can solve a GARCH model prior to ML estimation and supply the estimated parameters as input.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Tue Jun 16, 2009 11:39 am
by Hvtcapollo
I agree with trubador. You can estimate the GARCH(1,1) for the q11 and q22 (Based on z1, z2 respectively) to get the starting value for T(1) and T(2). However, in this case, it's not really sensitive if the sample size is large enough, say 3500-4000 obs. I tried and see the estimated result is approximately equal.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Wed Jun 17, 2009 3:25 am
by Sulzfalk
First and foremost I want to thank you for your help!
Although I agree that for large enough sample sizes the initial values do not matter I still have two conceptual questions:

- If I use z1 and z2 for estimating the GARCH(1,1) equations for q11 and q22 what are the mean equations? I tried 'z1 c' and 'z2 c' respectively and the results seem correct to me, since

c = 1- arch_constant - garch_constant

in the variance equation holds approx. for both cases, which should be true for estimating
q11_{t}= 1-T(1)-T(2) + T(1)*z1_{t-1} + T(2) *q11_{t-1}
q22_{t}= 1-T(1)-T(2) + T(1)*z2_{t-1} + T(2) *q22_{t-1}

On the other hand I might be wrong because the arch and garch terms are in both cases not significant with p-values exceeding 0.1

- Moreover I guess that in any case you get two possible starting values for T(1) and T(2) from estimating q11 and q22. Which should one choose?

Re: Dynamic conditional correlation multivariate GARCH

Posted: Wed Jun 17, 2009 8:13 pm
by Hvtcapollo
you can use "z c" for the mean equation, I think. However, since the z is standardized residual then the c must be very close to 0. Anyway, you just estimate to see the possible initial value for T(1) and T(2).

The equation for the conditional variance should be

q11_{t}= 1-T(1)-T(2) + T(1)*(z1_{t-1})^2 + T(2) *q11_{t-1}
q22_{t}= 1-T(1)-T(2) + T(1)*(z2_{t-1})^2 + T(2) *q22_{t-1}

I guess you can use either estimated result from GARCH as the initial value for T(1) and T(2). But, you should try to estimate for both cases to see the output. The estimated result for T(1) and T(2) should satisfy the conditions that: They are significant and (T(1)+T(2))<1 ( to ensure the process is mean reverting). As long as the conditions are satisfied, the result is pretty and you can stop for the estimation and start writing your report. That's what I think, I did this project 1 year ago so may be I miss some points. Anyway, good luck!

Re: Dynamic conditional correlation multivariate GARCH

Posted: Mon Jun 22, 2009 9:27 pm
by Atish Kumar Dash
Hi,

I worked on codes provided by Hvtcapollo above to estimate dynamic conditional correlation under bivariate GARCH. Herewith, I am attaching the DCC result and the workfile. Kindly let me know if it is correct.I also do not exactly know how to get the correlation coefficienct from the output. This is for the first time I am computing DCC.

It would be of great help if you could guide me in this regard.

Thanks and regards
Atish

Re: Dynamic conditional correlation multivariate GARCH

Posted: Fri Jul 10, 2009 8:36 pm
by vivian
Thanks very much for sharing the code. I used this code for my research as well, it turned out that there is always an error box saying " Missing values in @LOGL series at current coefficients at observation 1 in 'DO_DCC.ML(SHOWOPTS, M=500,C=1E-5)' "

Could you guys tell me where went wrong? I will really appreciate your help ....

so sad ....

Re: Dynamic conditional correlation multivariate GARCH

Posted: Sun Jul 12, 2009 11:28 pm
by trubador
It is a general problem and you can find numerous explanations if you search the forum. Like this one

Re: Dynamic conditional correlation multivariate GARCH

Posted: Thu Aug 20, 2009 3:31 pm
by fandifferent
Hi,

Thanks for sharing the code. However, I have some doubts regarding the logl function. In the code provided by Hvtcapollo, I find that the logl function lacks three terms appearing in the literatures, including the log(DetrDt) calculated before in the code. The other two are hard to write down because I can't write in matrix form here. This confuses me, as it seems that the calculated DetrDt was not used anywhere in the code.

It has been a long time since the last reply. If anyone knows why this happens please kindly tell. I will appreciate it very much.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Wed Sep 16, 2009 3:55 am
by fanfan
Hi,

I was really happy to find the codes provided by Hvtcapollo. However, when i performed the estimation in Eviews, I do not get any results for T(1) and T(2), they were still starting values of 0.2 and 0.7. The correlation i got is also a scaler value instead of time-varying. The ARCH and GARCH estimates turned out fine though...
As I am unfamiliar with Eviews, could any kind soul advise on the estimation procedure in Eviews? I suspect I might have missed out some steps and information. How do I run the program in Eviews, using the codes supplied by Hvtcapollo? Pls help!

Thanks to all kind souls out there....: ) really appreciate your help.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Wed Mar 31, 2010 1:55 am
by Lix
Does anyone know how to set up the loglikelihood for Trivariate DCC? Can I used a QMLE to estimate Trivariate DCC?
Thanks.