HOW TO ESTIMATE A MULTIVARIATE GARCH-M MODEL?

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

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

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

Postby trubador » Wed Aug 17, 2011 11:07 pm

First, declare a coefficient vector that corresponds to non-zero elements of the matrix A and initialize it. In your case, it would be something like the following:

Code: Select all

coef(6) Amat
Amat(1) = .2 'A(2,1)
Amat(2) = .2 'A(2,2)
Amat(3) = .2 'A(2,3)
Amat(4) = .2 'A(3,1)
Amat(5) = .2 'A(3,2)
Amat(6) = .2 'A(3,3)

And then, you should modify the equations or series accordingly. For instance, sqres2 and res1res2 should now be defined as:

Code: Select all

tvgarchm.append sqres2 = (y2-mu(2)-Amat(1)*y1(-1)-Amat(2)*y2(-1)-Amat(3)*y3(-1)-lambda(2)*var_y2)^2
tvgarchm.append res1res2 = (y1-0.5*var_y1)*(y2-mu(2)-Amat(1)*y1(-1)-Amat(2)*y2(-1)-Amat(3)*y3(-1)-lambda(2)*var_y2)

You can modify the code along with these lines...

jpk
Posts: 6
Joined: Tue Aug 16, 2011 4:01 am

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

Postby jpk » Thu Aug 18, 2011 6:30 am

Thank you. When I make these changes and run the program I get an error message: 'missing values in @logl series'. Any tips?

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

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

Postby trubador » Thu Aug 18, 2011 7:26 am

This is quite a common mistake made by users when modeling logl in EViews, so please search the forum for possible remedies...

JackCrow
Posts: 2
Joined: Thu Nov 24, 2011 10:51 pm

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

Postby JackCrow » Thu Nov 24, 2011 11:17 pm

Hello. I have been attempting to use the code presented and discussed in this thread to estimate a bivariate garch-in-mean model. I have three major questions.

1. Is there any way to modify the code to make it constant conditional covariance as opposed to BEKK?

2. What exactly is the current program doing? It seems to be estimating two univariate garch-in-mean series and then using those series to generate logl-maximized coefficients in the bivariate model, but this doesn't get around generated regressors, right?

3. How do I actually interpret results? I'm interested in the role of the conditional variance of each equation in both mean equations, i.e., if you have y1=c(1)*garch1+c(2)*garch2+(stuff), y2=c(3)*garch1+c(4)*garch2+(stuff), I want to estimate c(1) through c(4). I understand that lambda(1) is c(1) and lambda(2) is c(4), but the current program seems to restrict the model to two coefficients, with the off-diagonal element of H (the conditional covariance) replacing garch2 in the first equation and garch1 in the second. Correct? If I am interpreting this right, how do I get c(2) and c(3)?

Thank you very much for your help.

banhong86
Posts: 2
Joined: Mon Mar 11, 2013 4:05 pm

Re: HOW TO ESTIMATE A GARCH (1,1) (2,2) (1,2) (2,1) MODELS?

Postby banhong86 » Mon Mar 11, 2013 7:35 pm

Hi,

I'm a beginner for EViews. Currently I have a file named Canada Xchange Rate (as attached below). I am trying to estimate the GARCH (1,1), (2,2), (1,2) and (2,1) models in one script file. My script file is as follows:

'change path to program path
%path = @runpath
cd %path

' load workfile
load canada
' set sample
smpl @all
scalar p=1
scalar q=1
series tt = dlog(value)
freeze tt
arch tt c ar(1)
eq1.makegarch garch1

smpl @all
scalar p=2
scalar q=2
series bt = dlog(value)
freeze bt
arch(2,2) bt c ar(2)
eq1.makegarch garch2

smpl @all
scalar p=1
scalar q=2
series ht = dlog(value)
freeze ht
arch(1,2) ht c ar(2)
eq1.makegarch garch3

smpl @all
scalar p=2
scalar q=1
series kt = dlog(value)
freeze kt
arch(2,1) kt c ar(1)
eq1.makegarch garch4

I would be glad if you could guide me on this. Thank you for your time.

Regards,
Hong
Attachments
Canada Xchange Rate.xlsx
(22.97 KiB) Downloaded 229 times

simlgl
Posts: 6
Joined: Sat Aug 10, 2013 2:56 am

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

Postby simlgl » Sat Aug 17, 2013 12:18 pm

Hi Trubador,

I am trying to estimate a BEKK Model where I can analyse volatility spillovers between 4 commodities and 3 stocks, making it a 7x7 matrix. So far, I have got to this point:

smpl @all
series y1 = agriculture
series y2 = crudeoil
series y3 = energy
series y4 = preciousmetal
series y5 = japan
series y6 = uk
series y7 = usa

equation eq1.arch y1 c
equation eq2.arch y2 c
equation eq3.arch y3 c
equation eq4.arch y4 c
equation eq5.arch y5 c
equation eq6.arch y6 c
equation eq7.arch y7 c

eq1.makegarch garch1
eq2.makegarch garch2
eq3.makegarch garch3
eq4.makegarch garch4
eq5.makegarch garch5
eq6.makegarch garch6
eq7.makegarch garch7

coef(7) lambda
lambda(1) = eq1.c(1)
lambda(2) = eq2.c(1)
lambda(3) = eq3.c(1)
lambda(4) = eq4.c(1)
lambda(5) = eq5.c(1)
lambda(6) = eq6.c(1)
lambda(7) = eq7.c(1)

coef(7) mu
mu(1) = eq1.c(2)
mu(2) = eq2.c(2)
mu(3) = eq3.c(2)
mu(4) = eq4.c(2)
mu(5) = eq5.c(2)
mu(6) = eq6.c(2)
mu(7) = eq7.c(2)

coef(3) omega
omega(1)=(eq1.c(3))
omega(1)=(eq1.c(3))
omega(1)=(eq1.c(3))
omega(1)=(eq1.c(3))
omega(1)=(eq1.c(3))
omega(1)=(eq1.c(3))
omega(1)=(eq1.c(3))

However I am not sure about omega and how to declare these coefficients, I understand it should be a 7x7 lower triangular matrix? I have already looked through all of these related posts on here and Im stuck at this point. Is there any help you can give? Ive attached the workfile for viewing

Thanks,

SIMLGL
Attachments
newdataupdated.wf1
(1.21 MiB) Downloaded 191 times
garch program.prg
(474 Bytes) Downloaded 213 times

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

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

Postby trubador » Sun Aug 18, 2013 6:58 am

This is just the initialization of coefficients to be used later in the analysis. Omegas are used to construct the constants in the conditional variance equations. I can assure you that you can find all the help an guidance you need in the previous posts of this thread.

simlgl
Posts: 6
Joined: Sat Aug 10, 2013 2:56 am

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

Postby simlgl » Mon Aug 19, 2013 3:10 am

trubador wrote:This is just the initialization of coefficients to be used later in the analysis. Omegas are used to construct the constants in the conditional variance equations. I can assure you that you can find all the help an guidance you need in the previous posts of this thread.


Hi Trubador,

Thanks for the reply.It is much appreciated I've gone through all of the posts here but I just need some confirmation.

Am I right in saying that because my omega is a lower traingular 7x7 matrix, there should be 28 omega commands to enter? For example, would this be right to enter?

omega(1)=(eq1.c(3))^.5 (Can you explain why many programs have "^.5?")
omega(2)=0?.................(What is the reason for most programs having omega 2 as 0?
omega(3)=(eq2.c(3))
omega(4)=(eq3.c(3))
omega(5)=(eq4.c(3))
omega(6)=(eq5.c(3))
omega(7)=(eq6.c(3)).............?

And for my alpha and beta coefficients, which are diagonal matrices, there will also will 28 each to satisfy this equation? Thanks again for your help :)

Regards,

simlgl

Stat_One
Posts: 3
Joined: Sun Oct 13, 2013 10:00 pm

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

Postby Stat_One » Sun Oct 13, 2013 10:09 pm

Hi, do you have the code for the GARCH-M MODEL with 4 times series?? thank.

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

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

Postby misscats » Mon Mar 31, 2014 8:56 am

Hi trubador

I have modified this set of codes. I am learning the garch-m modelling. If anything sounds stupid, please bear with me.

I have two questions hope you can help me to confirm them:

1. May I ask whether this model is the "constant conditional correlation (ccc)" multivariate garch model?

2. It seems the output does not show the correlation of variances, can I write the below equation to get the correlation of variances?

Code: Select all

series corr12=cov_y1y2/(var_y1^.5 * var_y2^.5)


Many thanks for your help.

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

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

Postby trubador » Tue Apr 01, 2014 3:59 am

1) No, it is not a CCC model.
2) Yes, that is the formula of correlation.

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

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

Postby misscats » Tue Apr 01, 2014 4:49 am

Dear trubador
Thanks for your reply. If it is not a ccc model. Which model is it, bekk?

trubador wrote:1) No, it is not a CCC model.

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

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

Postby trubador » Tue Apr 01, 2014 4:56 am

As it is written in the very beginning of the code: "restricted (diagonal) version of tri-variate BEKK".

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

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

Postby misscats » Tue Apr 01, 2014 5:28 am

Dear trubador

Thanks for your reply. I missed to see that information.

My data is in irregular sample period. I read so many discussions here but no matter how I tried I still got errors:
=================================
Missing values in @LOGL series at current coefficients at observation 12/03/1990 in "DO_ BVGARCH.ML(SHOWOPTS, M=100, C=1E-5)".
LogL estimates are not valid in "SHOW BVGARCH.OUTPUT".
VARCOV is not defined in "SHOW VARCOV".
LogL estimates are not valid in "SCALAR LR = -2*( EQ1.@LOGL + EQ2.@LOGL - BVGARCH.@LOGL )".
LR is not defined in "SCALAR LR_PVAL = 1 - @CCHISQ(LR,1)".
=================================

I attach my workfile and the code here.
Please indicate me
(a) which one(s) goes wrong?
(b) With my codes, var_y1, var_y2 and covariance series appear all the same. Is it normal? Are these initial values? So, the output is not successfully generated yet?
(c) As my two equations are with different independent variables. I worry about my covariance equation, may you help me check whether I get it right.
(d) My key result is the correlation of variances. As you have said it is the right equation, is it in the right place of the codes?

Many thanks for your help.

Code: Select all

'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
load 15daysgap.wf1

series y1=bm19
series y2=fx

sample ss

'get starting values from univariate GARCH
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)

    y1(1) =na
    y2(1) =na
    coef(2)  mu
    mu(1)=@mean(y1-res1-lambda(1)*garch1)
    mu(2)=@mean(y2-res2-lambda(2)*garch2)

    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)))

    ' constant adjustment for log likelihood
    !mlog2pi = 2*log(2*@acos(-1))

  ' use sample var-cov as starting value of variance-covariance matrix
 '  res1 =y1-mu(1)-lambda(1)*garch1
    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)

     series sqresneg1 = (res1<0)^2
     series sqresneg2 = (res2<0)^2
     series res1res2neg=(res1<0)*(res2<0)

    ' 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 =( (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)) 
        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)
    bvgarch.append cov_y1y2= @nan(omega(2)+beta(3)*cov_y1y2(-1) + alpha(2)*alpha(1)*res1res2(-1) + lev(2)*lev(1)*sqres1(-1)*res1res2neg(-1) +(duminvar(1)^2)*dummy1,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 matrix
    bvgarch.append deth = var_y1*var_y2 - cov_y1y2^2

  ' 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
    smpl ss
    bvgarch.ml(showopts, m=100, c=1e-5)

series res1 = sqres1^.5
series res2 = sqres2^.5

series stres1 = res1 /(var_y1 ^ .5)
series stres2 = res2 /(var_y2 ^ .5)

series sqres1st = stres1^2
series sqres2st = stres2^2

series stres1res2 = res1*res2 /(var_y1*var_y2)^.5

series corr12=cov_y1y2/(var_y1^.5 * var_y2^.5)

'graph resids1.line stres1 y1
'show resids1
'graph resids2.line stres2 y2
'show resids2


  ' change below to display different output
    show bvgarch.output
    'graph varcov.line var_y1 var_y2 cov_y1y2
    show varcov

    ' LR statistic for univariate versus bivariate model
    scalar lr = -2*( eq1.@logl + eq2.@logl - bvgarch.@logl )
    scalar lr_pval = 1 - @cchisq(lr,1)



Attachments
15daysgap.wf1
(38.03 KiB) Downloaded 133 times

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

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

Postby trubador » Tue Apr 01, 2014 5:55 am

misscats wrote:My data is in irregular sample period. I read so many discussions here but no matter how I tried I still got errors:

I really do not have anything new or different to say other than my previous posts under similar threads. For example, I instantly noticed that:

1) You do not define the sample object "ss" anywhere in the code or workfile,
2) Dependent variable y1 have missing values until 10/31/2005.

Unless you successfully estimate the model, you'll keep getting those error messages...


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 4 guests