Lower triangular Trivariate BEKK GARCH model

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

nicktz
Posts: 18
Joined: Thu Mar 28, 2013 1:41 am

Lower triangular Trivariate BEKK GARCH model

Postby nicktz » Wed Nov 13, 2013 3:46 am

Can someone please help me with the following code:
Tv-garch_lowertriangle 5 - C uppertriangle.docx
(21.6 KiB) Downloaded 725 times
On the following data set:
Data.WF1
(122.91 KiB) Downloaded 559 times
I want to run a lower triangular TV-BEKK model on the attached data file, but it keeps failing.

Is my coding correct or did I make an error?

Please advise. Thank you! Nic

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

Re: Lower triangular Trivariate BEKK GARCH model

Postby trubador » Mon Nov 18, 2013 4:25 am

Check your determinant specification (i.e. deth), which has to be positive. It seems to be the source of the problem.

nicktz
Posts: 18
Joined: Thu Mar 28, 2013 1:41 am

Re: Lower triangular Trivariate BEKK GARCH model

Postby nicktz » Wed Nov 20, 2013 4:03 am

The deth is correctly specified from theory - but it seems that the covariance factors (cov_y1y2, etc) and the variance factors converge after a few periods - probably causing the deth to show NA.

Do you have any idea why the var and cov factors converge to a number?

thanks! ~N

nicktz
Posts: 18
Joined: Thu Mar 28, 2013 1:41 am

Re: Lower triangular Trivariate BEKK GARCH model

Postby nicktz » Wed Nov 20, 2013 4:15 am

Ah wait I think you're right- specifying the deth as vary1*vary2*vary3 shows some results - and it seems that the converged cov and var variables were as a result of the NA deth...

But doing so the results are somewhat suspect.. could this be as a result of the invh specifications for a lower triangular bekk model that changed? How would you specify the invh elements now?

Thanks!

N
Attachments
Tv-garch_lowertriangle 5 - C uppertriangle edited.docx
(24.18 KiB) Downloaded 688 times

Jayaraj
Posts: 2
Joined: Sat Sep 06, 2014 5:55 am

four-variate BEKK GARCH model

Postby Jayaraj » Sun Jun 28, 2015 10:39 pm

Dear trubador,

I have tried four variate garch. But I am not able to get output. Pls let me know where I am wrong?

' dependent variables of all series must be continues
series y1 = dlog(us_dollar)
series y2 = dlog(euro)
series y3 = dlog(pound_sterling)
series y4 = dlog(japanese_yen)

' set sample
' first observation of s1 need to be one or two periods after
' the first observation of s0
sample s0 1/4/1999 6/12/2015
sample s1 1/6/1999 6/12/2015

' 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
equation eq4.arch(m=100,c=1e-5) y4 c

' declare coef vectors to use in GARCH model
coef(4) lambda

lambda (1) = eq1.c(1)
lambda (2) = eq2.c(1)
lambda (3) = eq3.c(1)
lambda (4) = eq4.c(1)

coef(4) mu

mu(1) = eq1.c(1)
mu(2) = eq2.c(1)
mu(3) = eq3.c(1)
mu(4) = eq4.c(1)

coef(10) omega
omega(1) = (eq1.c(2))^.5
omega(2) = 0
omega(3) = 0
omega(4) = 0
omega(5) = eq2.c(2)^.5
omega(6) = 0
omega(7) = 0
omega(8) = eq3.c(2)^.5
omega(9) = 0
omega(10) = eq4.c(2)^.5

coef(4) alpha
alpha(1) = (eq1.c(3))^.5
alpha(2) = (eq2.c(3))^.5
alpha(3) = (eq3.c(3))^.5
alpha(4) = (eq4.c(3))^.5

coef(4) beta
beta(1) = (eq1.c(4))^.5
beta(2) = (eq2.c(4))^.5
beta(3) = (eq3.c(4))^.5
beta(4) = (eq4.c(4))^.5

' 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_y1y4 = @cov(y1-mu(1), y4-mu(4))
series cov_y2y3 = @cov(y2-mu(2), y3-mu(3))
series cov_y2y4 = @cov(y2-mu(2), y4-mu(4))
series cov_y3y4 = @cov(y3-mu(3), y4-mu(4))

series var_y1 = @var(y1)
series var_y2 = @var(y2)
series var_y3 = @var(y3)
series var_y4 = @var(y4)

series sqres1 = (y1-mu(1))^2
series sqres2 = (y2-mu(2))^2
series sqres3 = (y3-mu(3))^2
series sqres4 = (y4-mu(4))^2

series res1res2 = (y1-mu(1))*(y2-mu(2))
series res1res3 = (y1-mu(1))*(y3-mu(3))
series res1res4 = (y1-mu(1))*(y4-mu(4))
series res2res3 = (y2-mu(2))*(y3-mu(3))
series res2res4 = (y2-mu(2))*(y4-mu(4))
series res3res4 = (y3-mu(3))*(y4-mu(4))
' constant adjustment for log likelihood
!mlog2pi = 4*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 fvgarch

' squared errors and cross errors
fvgarch.append @logl logl
fvgarch.append sqres1 = (y1-mu(1))^2
fvgarch.append sqres2 = (y2-mu(2))^2
fvgarch.append sqres3 = (y3-mu(3))^2
fvgarch.append sqres4 = (y4-mu(4))^2

fvgarch.append res1res2 = (y1-mu(1))*(y2-mu(2))
fvgarch.append res1res3 = (y1-mu(1))*(y3-mu(3))
fvgarch.append res1res4 = (y1-mu(1))*(y4-mu(4))
fvgarch.append res2res3 = (y2-mu(2))*(y3-mu(3))
fvgarch.append res2res4 = (y2-mu(2))*(y4-mu(4))
fvgarch.append res3res4 = (y3-mu(3))*(y4-mu(4))

' variance and covariance series
fvgarch.append var_y1 = omega(1)^2 + beta(1)^2*var_y1(-1) + alpha(1)^2*sqres1(-1)
fvgarch.append var_y2 = omega(2)^2+omega(5)^2 + beta(2)^2*var_y2(-1) + alpha(2)^2*sqres2(-1)
fvgarch.append var_y3 = omega(3)^2+omega(6)^2+omega(8)^2 + beta(3)^2*var_y3(-1) + alpha(3)^2*sqres3(-1)
fvgarch.append var_y4 = omega(4)^2+omega(7)^2+omega(9)^2 +omega(10)^2+ beta(4)^2*var_y4(-1) + alpha(4)^2*sqres4(-1)

fvgarch.append cov_y1y2 = omega(1)*omega(2)* + beta(2)*beta(1)*cov_y1y2(-1) + alpha(2)*alpha(1)*res1res2(-1)
fvgarch.append cov_y1y3 = omega(1)*omega(3) + beta(3)*beta(1)*cov_y1y3(-1) + alpha(3)*alpha(1)*res1res3(-1)
fvgarch.append cov_y1y4 = omega(1)*omega(4) + beta(4)*beta(1)*cov_y1y4(-1) + alpha(4)*alpha(1)*res1res4(-1)
fvgarch.append cov_y2y3 = omega(2)*omega(3) + omega(4)*omega(5) + beta(3)*beta(2)*cov_y2y3(-1) + alpha(3)*alpha(2)*res2res3(-1)
fvgarch.append cov_y2y4 = omega(2)*omega(4) + omega(5)*omega(6) + beta(4)*beta(2)*cov_y2y4(-1) + alpha(4)*alpha(2)*res2res4(-1)
fvgarch.append cov_y3y4 = omega(3)*omega(5) + omega(6)*omega(7) + beta(3)*beta(4)*cov_y3y4(-1) + alpha(3)*alpha(4)*res3res4(-1)

' determinant of the variance-covariance matrix

fvgarch.append deth = var_y1*var_y2*var_y3*var_y4-var_y1*cov_y3y4*cov_y2y3^2-cov_y1y2^2*var_y4+2*cov_y2y3*cov_y3y4*cov_y1y4-cov_y1y4^2*
var_y3+2*cov_y1y2*cov_y2y3*cov_y1y3*cov_y2y4-cov_y2y4^2*cov_y2y3*cov_y1y2*cov_y1y4*cov_y3y4-cov_y3y4^2*var_y2


' calculate the elements of the inverse of var_cov (H) matrix
' numbered as vech(inv(H))

fvgarch.append invh1 = (var_y3*var_y4-cov_y3y4^2)/deth
fvgarch.append invh2 = -(cov_y1y2*var_y4- cov_y1y3*cov_y1y4* cov_y2y3* cov_y2y4*cov_y3y4*)/deth
fvgarch.append invh3 = (cov_y1y2*cov_y2y3*cov_y1y3* cov_y2y4*cov_y3y4-cov_y1y4*var_y3)/deth
fvgarch.append invh4 = (var_y1*var_y4-cov_y1y4^2)/deth
fvgarch.append invh5 = -(var_y1*cov_y2y3-cov_y1y2*cov_y1y3 * cov_y2y4*cov_y3y4*cov_y1y4)/deth
fvgarch.append invh6= (var_y2*var_y4-cov_y2y4^2)/deth
fvgarch.append invh7 = (cov_y1y2*cov_y2y3*cov_y1y4* cov_y2y4*cov_y3y4-cov_y1y3*var_y2)/deth
fvgarch.append invh8= (var_y1*var_y2-cov_y1y2^2)/deth
fvgarch.append invh9= (var_y1*var_y3-cov_y1y3^2)/deth
fvgarch.append invh10 = (var_y2*var_y3-cov_y2y3^2)/deth
fvgarch.append invh11 = (cov_y1y2*cov_y2y3*cov_y1y3* cov_y1y4*cov_y3y4-cov_y2y4*var_y3)/deth
fvgarch.append invh12 = -(var_y1*cov_y3y4-cov_y1y2*cov_y1y3 * cov_y2y3*cov_y2y4*cov_y1y4)/deth

' log-likelihood series
tvgarch.append logl = -0.5*(!mlog2pi + (invh1*sqres1+invh4*sqres2+invh6*sqres3 ++invh8*sqres4 +invh9*sqres5 + invh10*sqres6 +2*invh2*res1res2 +2*invh3*res1res4+2*invh5*res2res3) + 2*invh7*res1res3)+2*invh11*res2res4)+ 2*invh12*res1res3)+log(deth))


' remove some of the intermediary series
'tvgarch.append @temp invh1 invh2 invh3 invh4 invh5 invh6 invh7 invh8 invh9 invh10 invh11 invh12 sqres1 sqres2 sqres3 sqres4 res1res2 res1res3 res2res3 deth

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

' change below to display different output
show tvgarch.output
graph var.line var_y1 var_y2 var_y3 var_y4
graph cov.line cov_y1y2 cov_y1y3 cov_y2y3 cov_y1y4 cov_y2y4 cov_y3y4
show var
show cov

' LR statistic for univariate vs trivariate
scalar lr = -2*(eq1.@logl + eq2.@logl + eq3.@logl + eq4.@logl - fvgarch.@logl)
scalar lr_pval = 1 - @cchisq(lr,4)

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

Re: Lower triangular Trivariate BEKK GARCH model

Postby trubador » Mon Jun 29, 2015 5:47 am



Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests