Page 1 of 4

### HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Fri Dec 26, 2008 4:36 pm
Is there a way to do this? there is no option in Eviews, but some other
manual way of doing it within the multivariate GARCH (VECH) estimation
framework?

And not this:
1) estimating a GARCH model first without conditional variance in the mean equation
2) generate the conditional variance
3) next create another GARCH system, this time place the conditional variance terms from the first system in the mean equations
4) estimate this system
5) generate the conditional variance with the same name as the first time
6) repeat 4) and 5) until no improvement in model criteria (log likelihood, AIC, etc.)

This will lead to the generated regressors problem!

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Sat Dec 27, 2008 6:18 am
Yes, there is actually. I strongly agree with you that such recursive estimations lead to false or inconsistent results and joint estimation methods should be preferred where possible. You can build a multivariate garch in mean framework in EViews and estimate it easily with LogL object. Besides, you do not need to write a program from scratch and all you have to do is modify a sample program of trivariate garch provided by EViews (the path is ...\EViews6\Example Files\Sample Programs\logl\tv_garch.prg). Although it will be a tedious attempt for models with more than three variables, you can still alter the code to suit your problem.

Please note that original code provided by EViews also contains some small errors. I corrected and showed them as well. And there may also be further errors in the original code and in my modifications. So please check carefully before using it!

As an example, I made the following modifications for the trivariate garch in mean model:

'........ (means rest of the steps are same as the original version of the code)

Code: Select all

`'........' y = mu + lambda*H + res'........'  where,'........'    lambda = 3 x 1'........'get starting values from univariate GARCH equation eq1.arch(archm=var,m=100,c=1e-5) y1 cequation eq2.arch(archm=var,m=100,c=1e-5) y2 cequation eq3.arch(archm=var,m=100,c=1e-5) y3 c'save the conditional varianceseq1.makegarch garch1 eq2.makegarch garch2eq3.makegarch garch3'........' declare coef vectors to use in GARCH modelcoef(3) lambda 'please note that c(1) now belongs to conditional variance in the mean equation and do not forget to change other coefficients accordingly.lambda(1) = eq1.c(1)lambda(2) = eq2.c(1)lambda(3) = eq3.c(1)'........ mu(3) = eq3.c(2) 'in the original specification equation number is misspecified'........ alpha(3) = (eq3.c(4))^.5 'in the original specification equation number is misspecified'........' use sample var-cov as starting value of variance-covariance matrixseries cov_y1y2 = @cov(y1-mu(1)-lambda(1)*garch1, y2-mu(2)-lambda(2)*garch2)series cov_y1y3 = @cov(y1-mu(1)-lambda(1)*garch1, y3-mu(3)-lambda(3)*garch3)series cov_y2y3 = @cov(y2-mu(2)-lambda(2)*garch2, y3-mu(3)-lambda(3)*garch3)series var_y1 = @var(y1-lambda(1)*garch1)series var_y2 = @var(y2-lambda(2)*garch2)series var_y3 = @var(y3-lambda(3)*garch3)series sqres1 = (y1-mu(1)-lambda(1)*garch1)^2series sqres2 = (y2-mu(2)-lambda(2)*garch2)^2series sqres3 = (y3-mu(3)-lambda(3)*garch3)^2series res1res2 = (y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2)series res1res3 = (y1-mu(1)-lambda(1)*garch1)*(y3-mu(3)-lambda(3)*garch3)series res2res3 = (y2-mu(2)-lambda(2)*garch2)*(y3-mu(3)-lambda(3)*garch3)'........' squared errors and cross errorstvgarch.append @logl logltvgarch.append sqres1 = (y1-mu(1)-lambda(1)*garch1)^2tvgarch.append sqres2 = (y2-mu(2)-lambda(2)*garch2)^2tvgarch.append sqres3 = (y3-mu(3)-lambda(3)*garch3)^2tvgarch.append res1res2 = (y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2)tvgarch.append res1res3 = (y1-mu(1)-lambda(1)*garch1)*(y3-mu(3)-lambda(3)*garch3)tvgarch.append res2res3 = (y2-mu(2)-lambda(2)*garch2)*(y3-mu(3)-lambda(3)*garch3)'........`

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Sat Dec 27, 2008 12:35 pm
Thank you for the reply and help. Is the program you refer to a trivariate GARCH-M?
I am only going to use a bivariate model for now.

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Sat Dec 27, 2008 3:49 pm
Tried the tv_garch program but I think it is nothing like the one above:

Code: Select all

`@LOGL LOGLSQRES1 = (Y1-MU(1))^2SQRES2 = (Y2-MU(2))^2SQRES3 = (Y3-MU(3))^2RES1RES2 = (Y1-MU(1))*(Y2-MU(2))RES1RES3 = (Y1-MU(1))*(Y3-MU(3))RES2RES3 = (Y3-MU(3))*(Y2-MU(2))VAR_Y1  =  OMEGA(1)^2 + BETA(1)^2*VAR_Y1(-1) + ALPHA(1)^2*SQRES1(-1)VAR_Y2  = OMEGA(2)^2+OMEGA(4)^2 + BETA(2)^2*VAR_Y2(-1) + ALPHA(2)^2*SQRES2(-1)VAR_Y3  = OMEGA(3)^2+OMEGA(5)^2+OMEGA(6)^2 + BETA(3)^2*VAR_Y3(-1) + ALPHA(3)^2*SQRES3(-1)COV_Y1Y2 = OMEGA(1)*OMEGA(2) + BETA(2)*BETA(1)*COV_Y1Y2(-1) + ALPHA(2)*ALPHA(1)*RES1RES2(-1)COV_Y1Y3 = OMEGA(1)*OMEGA(3) + BETA(3)*BETA(1)*COV_Y1Y3(-1) + ALPHA(3)*ALPHA(1)*RES1RES3(-1)COV_Y2Y3 = OMEGA(2)*OMEGA(3) + OMEGA(4)*OMEGA(5) + BETA(3)*BETA(2)*COV_Y2Y3(-1) + ALPHA(3)*ALPHA(2)*RES2RES3(-1)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_Y2INVH1 = (VAR_Y2*VAR_Y3-COV_Y2Y3^2)/DETHINVH2 = -(COV_Y1Y2*VAR_Y3-COV_Y1Y3*COV_Y2Y3)/DETHINVH3 = (COV_Y1Y2*COV_Y2Y3-COV_Y1Y3*VAR_Y2)/DETHINVH4 = (VAR_Y1*VAR_Y3-COV_Y1Y3^2)/DETHINVH5 = -(VAR_Y1*COV_Y2Y3-COV_Y1Y2*COV_Y1Y3)/DETHINVH6 = (VAR_Y1*VAR_Y2-COV_Y1Y2^2)/DETHLOGL = -0.5*(5.51363119922804 + (INVH1*SQRES1+INVH4*SQRES2+INVH6*SQRES3 +2*INVH2*RES1RES2 +2*INVH3*RES1RES3+2*INVH5*RES2RES3 ) + LOG(DETH))`

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Sun Dec 28, 2008 6:02 am
The code that I modified belongs to the version 6 of EViews and worked well after the modifications I made. Therefore, there may be some differences with earlier versions. However, the logic will be the same and you should adjust the variables accordingly. Plus, you are willing to conduct a bivariate analysis that make things much easier for you. The log likelihood of bivariate model is more parsimonious, and still you do not have write your own because there is also a sample program in EViews written for bivariate garch analysis. If you cannot find it or still have problems just let me know...

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Tue Dec 30, 2008 6:08 pm

Thank you for the help and thank you for your patience. I am using Eviews 6 as well. I will use the bivariate GARCH program then, but having limited experience with programming EVIEWS I do not know how to include the GARCH variance or standard deviation in the mean equation.

This is the program I find in EVIEWS programs folder:

Code: Select all

`' BV_GARCH.PRG (3/30/2004)' Revised for 6.0 (3/7/2007)' example program for EViews LogL object'' restricted version of ' bi-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 = 2 x 1'     mu = 2 x 1'      H = 2 x 2 (symmetric)'          H(1,1) = variance of y1   (saved as var_y1)'          H(1,2) = cov of y1 and y2 (saved as var_y2)'          H(2,2) = variance of y2   (saved as cov_y1y2)'  omega = 2 x 2 low triangular '   beta = 2 x 2 diagonal'  alpha = 2 x 2 diagonal''change path to program path%path = @runpathcd %path' load workfileload intl_fin.wf1' dependent variables of both series must be continuessmpl @allseries y1 = dlog(sp500)series y2 = dlog(tbond)' set sample ' first observation of s1 need to be one or two periods after' the first observation of s0 sample s0 3/1/1994 8/25/2000sample s1 3/2/1994 8/25/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 cequation eq2.arch(m=100,c=1e-5) y2 c' declare coef vectors to use in bi-variate GARCH model' see above for details coef(2) mu mu(1) = eq1.c(1) mu(2)= eq2.c(1)coef(3) omega omega(1)=(eq1.c(2))^.5 omega(2)=0 omega(3)=eq2.c(2)^.5coef(2) alpha alpha(1) = (eq1.c(3))^.5 alpha(2) = (eq2.c(3))^.5 coef(2) beta  beta(1)= (eq1.c(4))^.5  beta(2)= (eq2.c(4))^.5' constant adjustment for log likelihood!mlog2pi = 2*log(2*@acos(-1))' use var-cov of sample in "s1" as starting value of variance-covariance matrixseries cov_y1y2 = @cov(y1-mu(1), y2-mu(2))series var_y1 = @var(y1)series var_y2 = @var(y2)series sqres1 = (y1-mu(1))^2series sqres2 = (y2-mu(2))^2series res1res2 = (y1-mu(1))*(y2-mu(2))' ...........................................................' 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 bvgarchbvgarch.append @logl loglbvgarch.append sqres1 = (y1-mu(1))^2bvgarch.append sqres2 = (y2-mu(2))^2bvgarch.append res1res2 = (y1-mu(1))*(y2-mu(2))' calculate the variance and covariance seriesbvgarch.append var_y1  =  omega(1)^2 + beta(1)^2*var_y1(-1) + alpha(1)^2*sqres1(-1)bvgarch.append var_y2  = omega(3)^2+omega(2)^2 + beta(2)^2*var_y2(-1) + alpha(2)^2*sqres2(-1)bvgarch.append cov_y1y2 = omega(1)*omega(2) + beta(2)*beta(1)*cov_y1y2(-1) + alpha(2)*alpha(1)*res1res2(-1)' determinant of the variance-covariance matrixbvgarch.append deth = var_y1*var_y2 - cov_y1y2^2' inverse elements of the variance-covariance matrixbvgarch.append invh1 = var_y2/dethbvgarch.append invh3 = var_y1/dethbvgarch.append invh2 = -cov_y1y2/deth' log-likelihood seriesbvgarch.append logl =-0.5*(!mlog2pi + (invh1*sqres1+2*invh2*res1res2+invh3*sqres2) + log(deth))' remove some of the intermediary series' bvgarch.append @temp invh1 invh2 invh3 sqres1 sqres2 res1res2 deth' estimate the modelsmpl s1bvgarch.ml(showopts, m=100, c=1e-5)' change below to display different outputshow bvgarch.outputgraph varcov.line var_y1 var_y2 cov_y1y2show varcov' LR statistic for univariate versus bivariate modelscalar lr = -2*( eq1.@logl + eq2.@logl - bvgarch.@logl )scalar lr_pval = 1 - @cchisq(lr,1)`

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Wed Dec 31, 2008 1:13 am
Below you can find similar modifications for bivariate GARCH-M model:

Code: Select all

`'............'  y = mu + H*lambda + res'............'     lambda = 2 x 1'............'get starting values from univariate GARCH equation eq1.arch(archm=var,m=100,c=1e-5) y1 cequation eq2.arch(archm=var,m=100,c=1e-5) y2 c'save the conditional varianceseq1.makegarch garch1 eq2.makegarch garch2'............' declare coef vectors to use in GARCH modelcoef(2) lambda lambda(1) = eq1.c(1) lambda(2) = eq2.c(1)coef(2) mu mu(1) = eq1.c(2) mu(2)= eq2.c(2)coef(3) omega omega(1)=(eq1.c(3))^.5 omega(2)=0 omega(3)=eq2.c(3)^.5coef(2) alpha alpha(1) = (eq1.c(4))^.5 alpha(2) = (eq2.c(4))^.5 coef(2) beta  beta(1)= (eq1.c(5))^.5  beta(2)= (eq2.c(5))^.5'............' use sample var-cov as starting value of variance-covariance matrixseries cov_y1y2 = @cov(y1-mu(1)-lambda(1)*garch1, y2-mu(2)-lambda(2)*garch2)series var_y1 = @var(y1-lambda(1)*garch1)series var_y2 = @var(y2-lambda(2)*garch2)series sqres1 = (y1-mu(1)-lambda(1)*garch1)^2series sqres2 = (y2-mu(2)-lambda(2)*garch2)^2series res1res2 = (y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2)'............' squared errors and cross errorsbvgarch.append @logl loglbvgarch.append sqres1 = (y1-mu(1)-lambda(1)*garch1)^2bvgarch.append sqres2 = (y2-mu(2)-lambda(2)*garch2)^2bvgarch.append res1res2 = (y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2)'............`

You can copy and paste the modified pieces and replace them in the original code. I do not send you the whole code to highlight and help you better understand the modifications. If you have any problems, please do not hesitate to contact...

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Mon Jan 05, 2009 9:24 am
In the original code I see that in the notes the variances are defined wrong:

' H(1,1) = variance of y1 (saved as var_y1)
' H(1,2) = cov of y1 and y2 (saved as var_y2)
' H(2,2) = variance of y2 (saved as cov_y1y2)

They should be cov_y1y2 and var_y2 respectively. Hope this does not carry down
to the estimation.

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Mon Jan 05, 2009 9:51 am

I have modified the program as below. Hope it is OK now. The programming language of
EVIEWS looks a bit strange to me and not very intuitive. I have had experience with RATS
etc. and I find this much different. Maybe there is a steep learning curve for this.

If you could take a look and tell me what you think it would be great!
Thank you again,
Perry

Code: Select all

`' BV_GARCH.PRG (3/30/2004)' Revised for 6.0 (3/7/2007)' example program for EViews LogL object'' restricted version of ' bi-variate BEKK of Engle and Kroner (1995):''  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''' where''     y = 2 x 1'     mu = 2 x 1'    -> lambda = 2 x 1'      H = 2 x 2 (symmetric)'          H(1,1) = variance of y1   (saved as var_y1)'          H(1,2) = cov of y1 and y2 (saved as var_y2)'          H(2,2) = variance of y2   (saved as cov_y1y2)'  omega = 2 x 2 low triangular '   beta = 2 x 2 diagonal'  alpha = 2 x 2 diagonal''change path to program path%path = @runpathcd %path' load workfileload intl_fin.wf1' dependent variables of both series must be continuessmpl @allseries y1 = dlog(sp500)series y2 = dlog(tbond)' set sample ' first observation of s1 need to be one or two periods after' the first observation of s0 sample s0 3/1/1994 8/25/2000sample s1 3/2/1994 8/25/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 cequation eq1.arch(archm=var,m=100,c=1e-5) y1 cequation eq2.arch(archm=var,m=100,c=1e-5) y2 c'save the conditional varianceseq1.makegarch garch1eq2.makegarch garch2' declare coef vectors to use in bi-variate GARCH model' see above for details 'coef(2) mu' mu(1) = eq1.c(1)' mu(2)= eq2.c(1)'coef(3) omega' omega(1)=(eq1.c(2))^.5' omega(2)=0' omega(3)=eq2.c(2)^.5'coef(2) alpha' alpha(1) = (eq1.c(3))^.5' alpha(2) = (eq2.c(3))^.5 'coef(2) beta ' beta(1)= (eq1.c(4))^.5 ' beta(2)= (eq2.c(4))^.5'new values    ' declare coef vectors to use in GARCH model    coef(2) lambda    lambda(1) = eq1.c(1)    lambda(2) = eq2.c(1)    coef(2) mu    mu(1) = eq1.c(2)    mu(2)= eq2.c(2)    coef(3) omega    omega(1)=(eq1.c(3))^.5    omega(2)=0    omega(3)=eq2.c(3)^.5    coef(2) alpha    alpha(1) = (eq1.c(4))^.5    alpha(2) = (eq2.c(4))^.5    coef(2) beta    beta(1)= (eq1.c(5))^.5    beta(2)= (eq2.c(5))^.5' constant adjustment for log likelihood!mlog2pi = 2*log(2*@acos(-1))'old values' use var-cov of sample in "s1" as starting value of variance-covariance matrix'series cov_y1y2 = @cov(y1-mu(1), y2-mu(2))'series var_y1 = @var(y1)'series var_y2 = @var(y2)'series sqres1 = (y1-mu(1))^2'series sqres2 = (y2-mu(2))^2'series res1res2 = (y1-mu(1))*(y2-mu(2))    series cov_y1y2 = @cov(y1-mu(1)-lambda(1)*garch1, y2-mu(2)-lambda(2)*garch2)    series var_y1 = @var(y1-lambda(1)*garch1)    series var_y2 = @var(y2-lambda(2)*garch2)    series sqres1 = (y1-mu(1)-lambda(1)*garch1)^2    series sqres2 = (y2-mu(2)-lambda(2)*garch2)^2    series res1res2 = (y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2)' ...........................................................' 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'old values'bvgarch.append @logl logl'bvgarch.append sqres1 = (y1-mu(1))^2'bvgarch.append sqres2 = (y2-mu(2))^2'bvgarch.append res1res2 = (y1-mu(1))*(y2-mu(2))    ' squared errors and cross errors    bvgarch.append @logl logl    bvgarch.append sqres1 = (y1-mu(1)-lambda(1)*garch1)^2    bvgarch.append sqres2 = (y2-mu(2)-lambda(2)*garch2)^2    bvgarch.append res1res2 = (y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2)' calculate the variance and covariance seriesbvgarch.append var_y1  =  omega(1)^2 + beta(1)^2*var_y1(-1) + alpha(1)^2*sqres1(-1)bvgarch.append var_y2  = omega(3)^2+omega(2)^2 + beta(2)^2*var_y2(-1) + alpha(2)^2*sqres2(-1)bvgarch.append cov_y1y2 = omega(1)*omega(2) + beta(2)*beta(1)*cov_y1y2(-1) + alpha(2)*alpha(1)*res1res2(-1)' determinant of the variance-covariance matrixbvgarch.append deth = var_y1*var_y2 - cov_y1y2^2' inverse elements of the variance-covariance matrixbvgarch.append invh1 = var_y2/dethbvgarch.append invh3 = var_y1/dethbvgarch.append invh2 = -cov_y1y2/deth' log-likelihood seriesbvgarch.append logl =-0.5*(!mlog2pi + (invh1*sqres1+2*invh2*res1res2+invh3*sqres2) + log(deth))' remove some of the intermediary series' bvgarch.append @temp invh1 invh2 invh3 sqres1 sqres2 res1res2 deth' estimate the modelsmpl s1bvgarch.ml(showopts, m=100, c=1e-5)' change below to display different outputshow bvgarch.outputgraph varcov.line var_y1 var_y2 cov_y1y2show varcov' LR statistic for univariate versus bivariate modelscalar lr = -2*( eq1.@logl + eq2.@logl - bvgarch.@logl )scalar lr_pval = 1 - @cchisq(lr,1)`

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Mon Jan 05, 2009 10:02 am
Am I right that the above program will estimate a multivariate GARCH-M where
the explanatory variables in the mean equations are only the constants (mu) and
the lagged GARCH term?

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Mon Jan 05, 2009 1:38 pm
The error you detected should be corrected as the way you did. I checked the log-likelihood specification and it is correct. So you do not have to worry about the rest of the code. Final version of the code after your modifications seems allright and therefore you should now be able to estimate a bivariate GARCH-M model. If you encounter any further problems, we can work on them as well.

If you had some experience on any other programming language or software package, then you could easily learn EViews. I can assure you that you will reap the benefits with little patience. Although the programming language of EViews is different than that of RATS, it really increases the flexibility with its ease of use. RATS is extremely command-driven, which I believe gives the ability to perform difficult tasks via writing procedures or using the built-in ones. Therefore, it has a wider range of applications. On the other hand, commands and programming language are interestingly similar (in narrow sense) between EViews and MATLAB. Hopefully, in the near future QMS will broaden the area of use of EViews via adding new features and improving the current ones.

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Mon Jan 05, 2009 2:07 pm
trubador wrote: Hopefully, in the near future QMS will broaden the area of use of EViews via adding new features and improving the current ones.

That's certainly our plan. Of course any suggestions/requests for specific features would be greatly appreciated.

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Wed Dec 01, 2010 1:55 am
I used this code, but I don't find any in mean element i the final estimation result
there shouldn't be or there is and I can't find it?

I have modified the program as below. Hope it is OK now. The programming language of
EVIEWS looks a bit strange to me and not very intuitive. I have had experience with RATS
etc. and I find this much different. Maybe there is a steep learning curve for this.

If you could take a look and tell me what you think it would be great!
Thank you again,
Perry

Code: Select all

`' BV_GARCH.PRG (3/30/2004)' Revised for 6.0 (3/7/2007)' example program for EViews LogL object'' restricted version of ' bi-variate BEKK of Engle and Kroner (1995):''  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''' where''     y = 2 x 1'     mu = 2 x 1'    -> lambda = 2 x 1'      H = 2 x 2 (symmetric)'          H(1,1) = variance of y1   (saved as var_y1)'          H(1,2) = cov of y1 and y2 (saved as var_y2)'          H(2,2) = variance of y2   (saved as cov_y1y2)'  omega = 2 x 2 low triangular '   beta = 2 x 2 diagonal'  alpha = 2 x 2 diagonal''change path to program path%path = @runpathcd %path' load workfileload intl_fin.wf1' dependent variables of both series must be continuessmpl @allseries y1 = dlog(sp500)series y2 = dlog(tbond)' set sample ' first observation of s1 need to be one or two periods after' the first observation of s0 sample s0 3/1/1994 8/25/2000sample s1 3/2/1994 8/25/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 cequation eq1.arch(archm=var,m=100,c=1e-5) y1 cequation eq2.arch(archm=var,m=100,c=1e-5) y2 c'save the conditional varianceseq1.makegarch garch1eq2.makegarch garch2' declare coef vectors to use in bi-variate GARCH model' see above for details 'coef(2) mu' mu(1) = eq1.c(1)' mu(2)= eq2.c(1)'coef(3) omega' omega(1)=(eq1.c(2))^.5' omega(2)=0' omega(3)=eq2.c(2)^.5'coef(2) alpha' alpha(1) = (eq1.c(3))^.5' alpha(2) = (eq2.c(3))^.5 'coef(2) beta ' beta(1)= (eq1.c(4))^.5 ' beta(2)= (eq2.c(4))^.5'new values    ' declare coef vectors to use in GARCH model    coef(2) lambda    lambda(1) = eq1.c(1)    lambda(2) = eq2.c(1)    coef(2) mu    mu(1) = eq1.c(2)    mu(2)= eq2.c(2)    coef(3) omega    omega(1)=(eq1.c(3))^.5    omega(2)=0    omega(3)=eq2.c(3)^.5    coef(2) alpha    alpha(1) = (eq1.c(4))^.5    alpha(2) = (eq2.c(4))^.5    coef(2) beta    beta(1)= (eq1.c(5))^.5    beta(2)= (eq2.c(5))^.5' constant adjustment for log likelihood!mlog2pi = 2*log(2*@acos(-1))'old values' use var-cov of sample in "s1" as starting value of variance-covariance matrix'series cov_y1y2 = @cov(y1-mu(1), y2-mu(2))'series var_y1 = @var(y1)'series var_y2 = @var(y2)'series sqres1 = (y1-mu(1))^2'series sqres2 = (y2-mu(2))^2'series res1res2 = (y1-mu(1))*(y2-mu(2))    series cov_y1y2 = @cov(y1-mu(1)-lambda(1)*garch1, y2-mu(2)-lambda(2)*garch2)    series var_y1 = @var(y1-lambda(1)*garch1)    series var_y2 = @var(y2-lambda(2)*garch2)    series sqres1 = (y1-mu(1)-lambda(1)*garch1)^2    series sqres2 = (y2-mu(2)-lambda(2)*garch2)^2    series res1res2 = (y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2)' ...........................................................' 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'old values'bvgarch.append @logl logl'bvgarch.append sqres1 = (y1-mu(1))^2'bvgarch.append sqres2 = (y2-mu(2))^2'bvgarch.append res1res2 = (y1-mu(1))*(y2-mu(2))    ' squared errors and cross errors    bvgarch.append @logl logl    bvgarch.append sqres1 = (y1-mu(1)-lambda(1)*garch1)^2    bvgarch.append sqres2 = (y2-mu(2)-lambda(2)*garch2)^2    bvgarch.append res1res2 = (y1-mu(1)-lambda(1)*garch1)*(y2-mu(2)-lambda(2)*garch2)' calculate the variance and covariance seriesbvgarch.append var_y1  =  omega(1)^2 + beta(1)^2*var_y1(-1) + alpha(1)^2*sqres1(-1)bvgarch.append var_y2  = omega(3)^2+omega(2)^2 + beta(2)^2*var_y2(-1) + alpha(2)^2*sqres2(-1)bvgarch.append cov_y1y2 = omega(1)*omega(2) + beta(2)*beta(1)*cov_y1y2(-1) + alpha(2)*alpha(1)*res1res2(-1)' determinant of the variance-covariance matrixbvgarch.append deth = var_y1*var_y2 - cov_y1y2^2' inverse elements of the variance-covariance matrixbvgarch.append invh1 = var_y2/dethbvgarch.append invh3 = var_y1/dethbvgarch.append invh2 = -cov_y1y2/deth' log-likelihood seriesbvgarch.append logl =-0.5*(!mlog2pi + (invh1*sqres1+2*invh2*res1res2+invh3*sqres2) + log(deth))' remove some of the intermediary series' bvgarch.append @temp invh1 invh2 invh3 sqres1 sqres2 res1res2 deth' estimate the modelsmpl s1bvgarch.ml(showopts, m=100, c=1e-5)' change below to display different outputshow bvgarch.outputgraph varcov.line var_y1 var_y2 cov_y1y2show varcov' LR statistic for univariate versus bivariate modelscalar lr = -2*( eq1.@logl + eq2.@logl - bvgarch.@logl )scalar lr_pval = 1 - @cchisq(lr,1)`

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Wed Dec 01, 2010 2:19 am
Lambdas are the coefficents of variances in the mean equations.

### Re: HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

Posted: Fri Dec 03, 2010 7:16 am