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)