Constant conditional correlation bivariate GARCH

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

toninho
Posts: 1
Joined: Thu Apr 15, 2010 1:10 pm

Constant conditional correlation bivariate GARCH

Postby toninho » Thu Apr 15, 2010 2:16 pm

Does anybody know how can I write a program to estimate a bivariate version Bollerslev's (1990) constant conditional correlation multivariate GARCH. I know that eviews can do it out of the box, without the need for a program, but since I want to parametrize the covariance equation in order to allow for a time trend and a variance threshold, I would like to have the basic CCC progam so I can modify it.

Many thanks

kusdhianto
Posts: 14
Joined: Thu Apr 22, 2010 2:40 am

Re: Constant conditional correlation bivariate GARCH

Postby kusdhianto » Fri Jul 29, 2011 3:37 am

Hi,

maybe it's too late and you already found the answer, but I just modified tvgarch program (from example files in EViews) to estimate CCC Trivariate GARCH. Since it is trivariate, it should be easier for you to modify it for bivariate estimation.
Anybody please verify the modified program, should there be any error I am eager to discuss it. I left the original version of the program in the code below, the modified lines are started with '#.

I wish it could help.

Code: Select all

' TV_GARCH.PRG (10/10/2000) ' example program for EViews LogL object ' revised for version 5.0 (11/19/2009) ' ' restricted version of ' tri-variate BEKK of Engle and Kroner (1995): ' ' y = mu + res ' res ~ N(0,H) ' ' H = omega*omega' + beta H(-1) beta' + alpha res(-1) res(-1)' alpha' ' ' where, ' y = 3 x 1 ' mu = 3 x 1 ' H = 3 x 3 (symmetric) ' H(1,1) = variance of y1 (saved as var_y1) ' H(1,2) = cov of y1 and y2 (saved as cov_y1y2) ' H(1,3) = cov of y1 and y2 (saved as cov_y1y3) ' H(2,2) = variance of y2 (saved as var_y2) ' H(2,3) = cov of y1 and y3 (saved as cov_y2y3) ' H(3,3) = variance of y3 (saved as var_y3) ' omega = 3 x 3 lower triangular (# I changed this to be diagonal matrix) ' beta = 3 x 3 diagonal ' alpha = 3 x 3 diagonal ' 'change path to program path '%path = @runpath 'cd %path ' load workfile 'load intl_fin.wf1 ' dependent variables of all series must be continues series y1 = dlog(sp500) series y2 = dlog(ftse) series y3 = dlog(nikkei) ' set sample ' first observation of s1 need to be one or two periods after ' the first observation of s0 sample s0 3/3/94 8/1/2000 sample s1 3/7/94 8/1/2000 ' initialization of parameters and starting values ' change below only to change the specification of model smpl s0 'get starting values from univariate GARCH equation eq1.arch(m=100,c=1e-5) y1 c equation eq2.arch(m=100,c=1e-5) y2 c equation eq3.arch(m=100,c=1e-5) y3 c ' declare coef vectors to use in GARCH model coef(3) mu mu(1) = eq1.c(1) mu(2) = eq2.c(1) mu(3) = eq2.c(1) coef(6) omega omega(1) = (eq1.c(2))^.5 omega(2) = 0 omega(3) = eq2.c(2)^.5 omega(4) = 0 omega(5) = 0 omega(6) = eq3.c(2)^.5 coef(3) alpha alpha(1) = (eq1.c(3))^.5 alpha(2) = (eq2.c(3))^.5 alpha(3) = (eq2.c(3))^.5 coef(3) beta beta(1) = (eq1.c(4))^.5 beta(2) = (eq2.c(4))^.5 beta(3) = (eq3.c(4))^.5 '# get starting value for constant correlation coef(3) ro ro(1) = @cor(y1,y2) ro(2) = @cor(y1,y3) ro(3) = @cor(y2,y3) ' use sample var-cov as starting value of variance-covariance matrix series cov_y1y2 = @cov(y1-mu(1), y2-mu(2)) series cov_y1y3 = @cov(y1-mu(1), y3-mu(3)) series cov_y2y3 = @cov(y2-mu(2), y3-mu(3)) series var_y1 = @var(y1) series var_y2 = @var(y2) series var_y3 = @var(y3) series sqres1 = (y1-mu(1))^2 series sqres2 = (y2-mu(2))^2 series sqres3 = (y3-mu(3))^2 'standardized residual series sr1 = (y1-mu(1))/@sqrt(var_y1) series sr2 = (y2-mu(2))/@sqrt(var_y2) series sr3 = (y3-mu(3))/@sqrt(var_y3) series res1res2 = (y1-mu(1))*(y2-mu(2)) series res1res3 = (y1-mu(1))*(y3-mu(3)) series res2res3 = (y3-mu(3))*(y2-mu(2)) ' constant adjustment for log likelihood !mlog2pi = 3*log(2*@acos(-1)) ' ........................................................... ' LOG LIKELIHOOD ' set up the likelihood ' 1) open a new blank likelihood object name tvgarch ' 2) specify the log likelihood model by append ' ........................................................... logl tvgarch ' squared errors and cross errors tvgarch.append @logl logl tvgarch.append sqres1 = (y1-mu(1))^2 tvgarch.append sqres2 = (y2-mu(2))^2 tvgarch.append sqres3 = (y3-mu(3))^2 'tvgarch.append res1res2 = (y1-mu(1))*(y2-mu(2)) 'tvgarch.append res1res3 = (y1-mu(1))*(y3-mu(3)) 'tvgarch.append res2res3 = (y3-mu(3))*(y2-mu(2)) ' variance and covariance series tvgarch.append var_y1 = omega(1)^2 + beta(1)^2*var_y1(-1) + alpha(1)^2*sqres1(-1) tvgarch.append var_y2 = omega(3)^2 + beta(2)^2*var_y2(-1) + alpha(2)^2*sqres2(-1) tvgarch.append var_y3 = omega(6)^2 + beta(3)^2*var_y3(-1) + alpha(3)^2*sqres3(-1) '# Standardized Residual tvgarch.append sr1 = (y1-mu(1))/@sqrt(var_y1) tvgarch.append sr2 = (y2-mu(2))/@sqrt(var_y2) tvgarch.append sr3 = (y3-mu(3))/@sqrt(var_y3) 'tvgarch.append cov_y1y2 = omega(1)*omega(2) + beta(2)*beta(1)*cov_y1y2(-1) + alpha(2)*alpha(1)*res1res2(-1) 'tvgarch.append cov_y1y3 = omega(1)*omega(4)+ beta(3)*beta(1)*cov_y1y3(-1) + alpha(3)*alpha(1)*res1res3(-1) 'tvgarch.append cov_y2y3 = omega(2)*omega(4) + omega(3)*omega(5) + beta(3)*beta(2)*cov_y2y3(-1) + alpha(3)*alpha(2)*res2res3(-1) ' determinant of the variance-covariance matrix 'tvgarch.append deth = var_y1*var_y2*var_y3 - var_y1*cov_y2y3^2-cov_y1y2^2*var_y3+2*cov_y1y2*cov_y2y3*cov_y1y3-cov_y1y3^2*var_y2 '# tvgarch.append deth = (var_y1)*(var_y2)*(var_y3) '# determinant of constant correlation matrix tvgarch.append detp = 1 - ro(1)^2 - ro(2)^2 + 2*ro(1)*ro(2)*ro(3) - ro(3)^2 '#components of last term of LLF '# other components p1,p2,p3,m1,m2,m3 tvgarch.append p1 = -ro(2) + ro(1)*ro(3) tvgarch.append p2 = -ro(1) + ro(2)*ro(3) tvgarch.append p3 = ro(1)*ro(2) - ro(3) tvgarch.append m1 = 1 - ro(3)^2 tvgarch.append m2 = 1 - ro(2)^2 tvgarch.append m3 = 1 - ro(1)^2 '# last term of LLF tvgarch.append last = (1/detp)*(sr3*(p1*sr1 + p3*sr2 + m3*sr3)+sr2*(p2*sr1 + m2*sr2 + p3*sr3)+sr1*(m1*sr1 + p2*sr2 + p1*sr3)) ' calculate the elements of the inverse of var_cov (H) matrix ' numbered as vech(inv(H)) 'tvgarch.append invh1 = (var_y2*var_y3-cov_y2y3^2)/deth 'tvgarch.append invh2 = -(cov_y1y2*var_y3-cov_y1y3*cov_y2y3)/deth 'tvgarch.append invh3 = (cov_y1y2*cov_y2y3-cov_y1y3*var_y2)/deth 'tvgarch.append invh4 = (var_y1*var_y3-cov_y1y3^2)/deth 'tvgarch.append invh5 = -(var_y1*cov_y2y3-cov_y1y2*cov_y1y3)/deth 'tvgarch.append invh6 = (var_y1*var_y2-cov_y1y2^2)/deth ' log-likelihood series tvgarch.append logl = -0.5*(!mlog2pi + log(deth) + log(detp) + last) ' remove some of the intermediary series 'tvgarch.append @temp invh1 invh2 invh3 invh4 invh5 invh6 sqres1 sqres2 sqres3 res1res2 res1res3 res2res3 deth ' estimate the model smpl s1 tvgarch.ml(showopts, m=10000, c=1e-5) ' change below to display different output show tvgarch.output graph var.line var_y1 var_y2 var_y3 '# Covariance Matrix cov_y1y2 = ro(1)*@SQRT(var_y1*var_y2) cov_y1y3 = ro(2)*@SQRT(var_y1*var_y3) cov_y2y3 = ro(3)*@SQRT(var_y2*var_y3) graph cov.line cov_y1y2 cov_y1y3 cov_y2y3 show var show cov ' LR statistic for univariate vs trivariate 'scalar lr = -2*(eq1.@logl + eq2.@logl + eq3.@logl - tvgarch.@logl) 'scalar lr_pval = 1 - @cchisq(lr,3)

tunelbana
Posts: 2
Joined: Tue Jun 18, 2013 5:28 am

Re: Constant conditional correlation bivariate GARCH

Postby tunelbana » Tue Jun 18, 2013 5:40 am

Hi,

Think you for your Ccc code. Is it possible to add var equations to this code?
I need to estimate var-ccc model with exogenous variables in both var and variance type of equations.
Do Eviews can do that?

Think you for your reply,
Joanna

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Constant conditional correlation bivariate GARCH

Postby trubador » Wed Jun 19, 2013 12:09 am

Yes, you can modify the code so as to include exogenous variables. However, note that the code is for version 5.0 and is not needed anymore for higher versions. You can use System object to build and estimate a VAR-CCC model.

misscats
Posts: 29
Joined: Wed Mar 19, 2014 8:37 am

Re: Constant conditional correlation bivariate GARCH

Postby misscats » Wed Apr 02, 2014 11:34 am

This tread is the only place I could find ccc garch codes providing some useful codes.

I try to apply the code (for trivariate garch) to a bivariate garch. I find it out it is not as straightforward as it is.

Here is my code for a ccc bivariate garch-in-mean model. The code works fine. The table reports coefficients but not standard errors, z-stat and prob.

Can anyone indicate me where goes wrong?

I attach my codes and workfile here. Hopefully, this can be solved and people think it is useful.

(Dear trubador, I have searched and learned how to do ML modelling from dcc to ccc here. I also tried a lot on my own. Just hope you don't think I take anything for granted.)

Code: Select all

load 15daysgap_undated.wf1 series y1=bm19 series y2=fx sample s1 1 @last group indepvars1 ftallsh fx(-1) ir smb hml mom dummy1 group indepvars2 fx(-1) equation eq1.ARCH(THRSH=1,GED,ARCHM=VAR,S=0,BACKCAST=0.7,DERIV=AA, m=100, c=1e-5) y1 C INDEPVARS1 @ DUMMY1 equation eq2.ARCH(THRSH=1,GED,ARCHM=VAR,S=0,BACKCAST=0.7,DERIV=AA, m=100, c=1e-5) y2 C INDEPVARS2 'save the conditional variances eq1.makegarch garch1 eq2.makegarch garch2 'Residuals and mu eq1.makeresid(s) res1 eq2.makeresid(s) res2 'declare coef vectors to use in GARCH model ' y = mu + res -> y = mu + H*lambda + res ' res ~ N(0,H) ' ' H = omega*omega' + beta H(-1) beta' + alpha res(-1) res(-1)' alpha' + lev res(-1;<0) + duminvar dummy1 coef(2) lambda lambda(1) = eq1.c(1) lambda(2) = eq2.c(1) coef(2) mu mu(1)=@mean(res1) mu(2)=@mean(res2) coef(3) omega omega(1)=@sqrt(@abs(eq1.c(10))) omega(2)=0 omega(3)=@sqrt(@abs(eq2.c(4))) coef(2) alpha alpha(1) = @sqrt(@abs(eq1.c(11))) alpha(2) = @sqrt(@abs(eq2.c(5))) coef(2) lev lev(1) =@sqrt(@abs(eq1.c(12))) lev(2) =@sqrt(@abs(eq1.c(6))) coef(3) beta beta(1)=@sqrt(@abs(eq1.c(13))) beta(2)=@sqrt(@abs(eq2.c(7))) beta(3)=(beta(1)*beta(2))^.5 coef(1)duminvar duminvar(1)=@sqrt(@abs(eq1.c(14))) '# get starting value for constant correlation coef(1) ro ro(1) = @cor(y1,y2) ' use sample var-cov as starting value of variance-covariance matrix ' res1 =y1-mu(1)-lambda(1)*garch1 series cov_y1y2 = @nan(@cov(y1-mu(1)-lambda(1)*garch1, y2-mu(2)-lambda(2)*garch2) ,1) series var_y1 = @nan(@var(y1-lambda(1)*garch1),1) series var_y2 = @nan(@var(y2-lambda(2)*garch2),1) scalar corr12=@cor(res1,res2) series sqres1 = @nan((y1-mu(1)-lambda(1)*garch1)^2,1) series sqres2 = @nan((y2-mu(2)-lambda(2)*garch2)^2,1) series res1res2 = @nan( (y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2),1) series sqresneg1 =(res1<0)^2 series sqresneg2 =(res2<0)^2 series res1res2neg=(res1<0)*(res2<0) 'standardized residual series sr1 = @nan((y1-mu(1)-lambda(1)*garch1)/@sqrt(var_y1),1) series sr2 = @nan((y2-mu(2)-lambda(2)*garch2)/@sqrt(var_y2),1) ' constant adjustment for log likelihood !mlog2pi = 2*log(2*@acos(-1)) ' LOG LIKELIHOOD ' set up the likelihood ' 1) open a new blank likelihood object (L.O.) name bvgarch ' 2) specify the log likelihood model by append ' ........................................................... logl bvgarch ' squared errors and cross errors bvgarch.append @logl logl bvgarch.append sqres1 =@nan(( (y1-mu(1)-lambda(1)*garch1)^2),1) bvgarch.append sqres2 = @nan(((y2-mu(2)-lambda(2)*garch2)^2),1) 'bvgarch.append res1res2 = @nan(((y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2)) ,1) bvgarch.append sqresneg1 = (res1<0)^2 bvgarch.append sqresneg2 = (res2<0)^2 'bvgarch.append res1res2neg=(res1<0)*(res2<0) ' calculate the variance and covariance series ' H = omega*omega' + beta H(-1) beta' + alpha res(-1) res(-1)' alpha' + lev res(-1;<0) + duminvar dummy1 bvgarch.append var_y1 = @nan(omega(1)^2 + (beta(1)^2)*var_y1(-1) + (alpha(1)^2)*sqres1(-1) + (lev(1)^2)*sqres1(-1)*sqresneg1(-1)+(duminvar(1)^2)*dummy1,1) bvgarch.append var_y2 = @nan(omega(3)^2 +( beta(2)^2)*var_y2(-1) + (alpha(2)^2)*sqres2(-1) + (lev(2)^2)*sqres1(-1)*sqresneg2(-1),1) '# Standardized Residual bvgarch.append sr1 = (y1-mu(1)-lambda(1)*garch1)/@sqrt(var_y1) bvgarch.append sr2 = (y2-mu(2)-lambda(2)*garch2)/@sqrt(var_y2) ' determinant of the variance-covariance matrix bvgarch.append deth = var_y1*var_y2 - cov_y1y2^2 '# determinant of constant correlation matrix bvgarch.append detp = 1 - ro(1)^2 '# other components p1,p2,p3,m1,m2,m3 bvgarch.append p2 = -ro(1) '# last term of LLF bvgarch.append last = (1/detp)*(sr2*(p2*sr1)+sr1*(sr1 + p2*sr2)) ' inverse elements of the variance-covariance matrix bvgarch.append invh1 = var_y2/deth bvgarch.append invh3 = var_y1/deth bvgarch.append invh2 = -cov_y1y2/deth ' log-likelihood series bvgarch.append logl =-0.5*(!mlog2pi + (invh1*sqres1+2*invh2*res1res2+invh3*sqres2) + log(deth)) ' estimate the model sample s2 4 @last smpl s2 bvgarch.ml(showopts, m=100, c=1e-5) ' change below to display different output show bvgarch.output graph var.line var_y1 var_y2
Attachments
15daysgap_undated.wf1
(16.06 KiB) Downloaded 633 times

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Constant conditional correlation bivariate GARCH

Postby trubador » Wed Apr 02, 2014 1:19 pm

The model is ill-defined for a number of reasons. You'll find similar problems if you search the forum.
For instance, carefully examine the univariate output (i.e. eq1). And the number of observations (sample size) is relatively small for this type of model.

misscats
Posts: 29
Joined: Wed Mar 19, 2014 8:37 am

Re: Constant conditional correlation bivariate GARCH

Postby misscats » Thu Apr 03, 2014 2:08 am

Many thanks for your reply, trubador.


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 2 guests