Variations on BEKK

Discussions of ARCH, GARCH, and related models

Variations on BEKK

Postby TomDoan » Wed Dec 02, 2009 3:53 pm

The code below provides modernized calculations for standard, diagonal and triangular BEKK models. The standard BEKK, can, of course, be done with GARCH directly. The code using MAXIMIZE can be used as the base if you want some additional features that aren't currently included. This uses the same data set as the garchmv.prg example.

Code: Select all
*
* Variations on BEKK models
*
all 6237
open data g10xrate.xls
data(format=xls,org=columns) / usxjpn usxfra usxsui
*
set xjpn = 100.0*log(usxjpn/usxjpn{1})
set xfra = 100.0*log(usxfra/usxfra{1})
set xsui = 100.0*log(usxsui/usxsui{1})
*
* Standard BEKK with GARCH instruction
*
compute gstart=3,gend=6237
garch(p=1,q=1,mv=bekk,pmethod=simplex,piters=5) gstart gend xjpn xfra xsui
*
* General setup for GARCH with MAXIMIZE
*
compute n=3
*
dec series[vect] yv
dec frml[vect]   residv
dec vect[series] u(n)
*
* The paths of the covariance matrices and uu' are saved in the
* SERIES[SYMM] named H and UU. UX and HX are used for the current values
* of the residual vector and H matrices
*
declare series[symm] h uu
*
* ux is used when extracting a u vector
*
declare symm hx(n,n)
declare vect ux(n)
declare frml[symm] hf
*
* Mean parameters
*
dec vect mu(n)
nonlin(parmset=meanparms) mu
*
* Define residuals
*
frml residv = yv-mu
*
* Define vector of dependent variables
*
gset yv = ||xjpn,xfra,xsui||
*
* Run preliminary regression to get estimates of residuals and means.
*
nlsystem(frmlvector=residv,parmset=meanparms,resids=u) gstart gend
compute rr=%sigma
*
* These are used to initialize pre-sample variances.
*
gset h  * gend = rr
gset uu * gend = rr
*
frml logl = $
    hx    = h(t) = hf(t) , $
    ux    = residv       , $
    uu(t) = %outerxx(ux) , $
    %pt(u,t,ux)          , $
    %logdensity(hx,ux)
******************************************************************
*
* Standard BEKK. Should be the same as above (just much slower)
*
dec rect    var(n,n) vbr(n,n)
dec packed   vct(n,n)
dec symm    vcs
*
compute var=sqrt(.05)*%identity(n),vbr=sqrt(.45)*%identity(n)
compute vct=%decomp(rr)
nonlin(parmset=bekkparms) vct var vbr
FUNCTION %%BEKKInit
compute vcs=%ltouterxx(vct)
END
frml hf = vcs+%mqform(h{1},vbr)+%mqform(uu{1},var)
maximize(title="Standard BEKK Model",start=%%BEKKInit(),parmset=meanparms+bekkparms,$
  method=bfgs,iters=400,pmethod=simplex,piters=5) logl gstart gend
******************************************************************
*
* Diagonal BEKK
*
dec vect   vav(n) vbv(n)
dec packed vct(n,n)
dec symm   vcs vbs vas
*
compute vav=%fill(n,1,sqrt(.05)),vbv=%fill(n,1,sqrt(.45))
compute vct=%decomp(rr)
nonlin(parmset=dbekkparms) vct vav vbv
FUNCTION %%DBEKKInit
compute vcs=%ltouterxx(vct)
compute vbs=%outerxx(vbv)
compute vas=%outerxx(vav)
END
*
frml hf = vcs+vbs.*h{1}+vas.*uu{1}
maximize(title="Diagonal BEKK Model",start=%%DBEKKInit(),parmset=meanparms+dbekkparms,$
 method=bfgs,iters=400,pmethod=simplex,piters=5) logl gstart gend
******************************************************************
*
* Triangular BEKK. This is written assuming the "causality" flows from
* the first to the last series, which means that the A' matrix in A'HA
* needs to be lower triangular. Because of the convention used in
* defining "packed" matrices, the output will show A and B as lower
* triangular, so this is actually doing AHA' rather than A'HA.
*
dec packed vat(n,n) vbt(n,n)
dec packed vct(n,n)
dec rect   var(n,n) vbr(n,n)
compute vat=sqrt(.05)*%identity(n),vbt=sqrt(.45)*%identity(n)
compute vct=%decomp(rr)
nonlin(parmset=tbekkparms) vct vat vbt
FUNCTION %%TBEKKInit
local integer i j
compute vcs=%ltouterxx(vct)
ewise vbr(i,j)=%if(j>=i,vbt(i,j),0.0)
ewise var(i,j)=%if(j>=i,vat(i,j),0.0)
END
frml hf = vcs+%mqform(h{1},vbr)+%mqform(uu{1},var)
maximize(title="Triangular BEKK",start=%%TBEKKInit(),parmset=meanparms+tbekkparms,$
  method=bfgs,iters=400,pmethod=simplex,piters=5) logl gstart gend
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Variations on BEKK

Postby hashem » Mon Jan 24, 2011 11:53 am

Dear Tom,

How can i alter the mean equations so it could become a lower triangular var. so the mean spillover is restricted from country one to two and not from two to one.

regards
Hashem
hashem
 
Posts: 17
Joined: Sun Dec 12, 2010 11:11 am

Re: Variations on BEKK

Postby AndresT » Fri Apr 01, 2011 4:16 pm

Dear Tom,
Is it possible to extend the BEKK Triangular model to include assymetry?
Doing either one with the code you provided is easy, but together I haven't been able to figure it out.
AndresT
 
Posts: 5
Joined: Fri Apr 01, 2011 1:37 pm

Re: Variations on BEKK

Postby TomDoan » Sat Apr 02, 2011 8:26 am

Andres wrote:Dear Tom,
Is it possible to extend the BEKK Triangular model to include assymetry?
Doing either one with the code you provided is easy, but together I haven't been able to figure it out.


Yes, but, because of the forced p.s.d. nature of the calculation, the asymmetry in a BEKK gives you a (fundamentally) different model depending upon which sign you choose to use in the calculation. This is unlike the situation with most other asymmetric GARCH models where the coefficient sign can be negative to counteract a different choice for + or - shocks. This uses a function called VTSign to pick a particular signed version of the residual vector. The SIGNS vector for this is the set of + or -1's which will be the type of residual which is assumed to increase variance; in this case, all positive.

Code: Select all
*
* Asymmetric triangular BEKK. This is written assuming the "causality"
* flows from the first to the last series, which means that the A'
* matrix in A'HA needs to be lower triangular. Because of the convention
* used in defining "packed" matrices, the output will show A and B as
* lower triangular, so this is actually doing AHA' rather than A'HA.
*
function VTSign v s
type vector v s VTSign
*
local integer i
*
dim VTSign(%rows(v))
ewise VTSign(i)=%if(%sign(v(i))==s(i),v(i),0.0)
end
*
compute signs=||1.0,1.0,1.0||
declare series[symm] uus
gset uus * gend = %zeros(n,n)
*
frml alogl = $
    hx    = h(t) = hf(t) , $
    ux    = residv       , $
    uu(t) = %outerxx(ux) , $
    uus(t)= %outerxx(VTSign(ux,signs)), $
    %pt(u,t,ux)          , $
    %logdensity(hx,ux)
dec packed vat(n,n) vbt(n,n) vdt(n,n)
dec packed vct(n,n)
dec rect   var(n,n) vbr(n,n) vdr(n,n)
compute vat=sqrt(.05)*%identity(n),vbt=sqrt(.85)*%identity(n),vdt=%zeros(n,n)
compute vct=%decomp(rr)
nonlin(parmset=atbekkparms) vct vat vbt vdt
FUNCTION %%ATBEKKInit
local integer i j
compute vcs=%ltouterxx(vct)
ewise vbr(i,j)=%if(j>=i,vbt(i,j),0.0)
ewise var(i,j)=%if(j>=i,vat(i,j),0.0)
ewise vdr(i,j)=%if(j>=i,vdt(i,j),0.0)
END
frml hf = vcs+%mqform(h{1},vbr)+%mqform(uu{1},var)+%mqform(uus{1},vdr)
maximize(title="Asymmetric Triangular BEKK",start=%%ATBEKKInit(),parmset=meanparms+atbekkparms,$
  method=bfgs,iters=400,trace,pmethod=simplex,piters=5) alogl gstart gend
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Variations on BEKK

Postby AndresT » Mon Apr 04, 2011 1:28 am

Dear Tom,

Thanks for your quick reply.

I have two further questions.
When we add the asymmetric option to the garch function for the full bekk. i.e.
garch(p=1,q=1,mv=bekk,asymmetric,...,pmethod=simplex,piters=5,...) / xjpn, xfra (or any other variable)

Then which version are we getting the positive or the negative sign?

In finance, generally bear markets tend to exhibit more return volatility. In your previous code how may I include the negative sign?

Thank you very much

Andres
AndresT
 
Posts: 5
Joined: Fri Apr 01, 2011 1:37 pm

Re: Variations on BEKK

Postby TomDoan » Mon Apr 04, 2011 11:42 am

Andres wrote:Dear Tom,

Thanks for your quick reply.

I have two further questions.
When we add the asymmetric option to the garch function for the full bekk. i.e.
garch(p=1,q=1,mv=bekk,asymmetric,...,pmethod=simplex,piters=5,...) / xjpn, xfra (or any other variable)

Then which version are we getting the positive or the negative sign?

In finance, generally bear markets tend to exhibit more return volatility. In your previous code how may I include the negative sign?

Thank you very much

Andres


I believe that's explained in the comments in that last post. If negative shocks are the ones which are assumed to increase the variance, you would want:

compute signs=||-1.0,-1.0,-1.0||

rather than

compute signs=||1.0,1.0,1.0||
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to ARCH and GARCH Models

Who is online

Users browsing this forum: No registered users and 2 guests