VAR(1)- GARCH(1,1) in mean with assymetry

Discussions of ARCH, GARCH, and related models
amcqeen
Posts: 17
Joined: Wed Jan 14, 2009 6:42 am

VAR(1)- GARCH(1,1) in mean with assymetry

Unread post by amcqeen »

Hi, i estimate my usual trivariate VAR(1)-GARCH(1,1) as i mentioned before with the BEKK representation and i restrict the matrices in var-covar matrices to be an upper triangular (kind of). I have the code which was modified mostly by Tom a couple of weeks ago. Now i want to estimate GARCH in mean (with squared variance, squared root of Ht) and i also want to add asymetry in the variance equation Ht = C΄C + α΄ et-1 e΄t-1 a + β΄ H΄t-1β + d'ξt' ξtd where ξ is the assymetry. [i am replicating a paper's model] .I read from the manual that i can add the word assymetry in the garch (..) line instead of doing it manualy (as i saw in an older threat). Also in order to add the garch-in mean like the manual says i have to plan ahead and define the hhs symmetruc matrix and add the hhs in the mean equations. But since i use maximize all these do not seem to work, assymetry and adding hhs in the mean equations and i cant find the error. My clean original code without assymetry and garch in mean is the following.

Thank you in advance
your help was very usefull in the last two moths and has helped me a lot since i am a new user in Rats


Maria


The code:

Code: Select all

open data kor.xls
data(format=xls,org=columns) 1 284 lmr fxr mmr
*
*
* Estimation using MAXIMIZE
* The initial few lines of this set the estimation range, which needs to be done
* explicitly, and the number of variables. Then, vectors for the dependent
* variables, residuals and residuals formulas are set up. The SET instructions
* copy the dependent variables over into the slots in the vector of series.
*
compute gstart=2,gend=284
compute n=3
dec vect[series] y(n) u(n)
dec vect[frml] resid(n)
set y(1) = lmr
set y(2) = fxr
set y(3) = mmr

*
* This is specific to a mean-only model. It sets up the formulas (the &i are
* needed in the formula definitions when the FRML is defined in a loop), and
* estimates them using NLSYSTEM. This both initializes the mean parameters, and
* computes the unconditional covariance matrix. If you want more general mean
* equations, the simplest way to do that would be to define each FRML separately.
*
dec vect b(n) o(n) w(n) k(n) 
nonlin(parmset=meanparms) b o(1) o(2) w(1) w(2)  k   

frml lmreq lmr = b(1) + o(1)*lmr{1} + w(1)*fxr{1} + k(1)*mmr{1} + u(1)
frml  fxreq fxr = b(2) + o(2)*lmr{1} + w(2)*fxr{1} + k(2)*mmr{1} + u(2)
frml  mmreq mmr= b(3) + k(3)*mmr{1} + u(3)
frml resid(1) = (lmr-b(1)-o(1)*lmr{1}-w(1)*fxr{1}-k(1)*mmr{1})
frml resid(2) = (fxr-b(2)-o(2)*lmr{1}-w(2)*fxr{1}-k(2)*mmr{1})
frml resid(3) = (mmr-b(3)-k(3)*mmr{1})

* the third equation is an AR(1) BUT the first two a VAR(1)

nlsystem(parmset=meanparms,resids=u) gstart gend resid
compute rr=%sigma
*
* The paths of the covariance matrices and uu' are saved in the SERIES[SYMM] names
* H and UU. UX and HX are used to pull in residuals 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)
*
* These are used to initialize pre-sample variances.
*
gset h  * gend = rr
gset uu * gend = rr
*
* This is a standard (normal) log likelihood formula for any multivariate GARCH
* model. The difference among these will be in the definitions of HF and RESID.
* The function %XT pulls information out of a matrix of SERIES.
*
declare frml[symm] hf
*
frml logl = $
    hx = hf(t) , $
    %do(i,1,n,u(i)=resid(i)) , $
    ux = %xt(u,t), $
    h(t)=hx, uu(t)=%outerxx(ux), $
    %logdensity(hx,ux)
*****************************************************
*
* Positive definite parameterization (BEKK,EK)
* This enforces a positive definite covariance matrix by writing the covariance
* matrix evolution as
*
*   V(t) = C'C + A'u(t)u(t)'A + B'V(t-1)B
*
* Note that the parameters are not globally identified: changing the signs of all
* members of C, A or B will have no effect on the function value. Using
* PMETHOD=SIMPLEX to begin is quite important with this setup, to pull the
* estimates away from zero before starting the derivative-based methods.
*
dec rect   var(n,n) vbr(n,n)
dec packed vcr(n,n)
nonlin(parmset=garchparms) vcr var vbr
nonlin(parmset=restrictions) var(3,1)=var(3,2)=0.0 vbr(3,1)=vbr(3,2)=0.0

frml hf = $
  hx=h{1},uux=uu{1},$
  %ltouterxx(vcr)+%mqform(uux,var)+%mqform(hx,vbr)
*
*  Initialize c's from the decomp of the covariance matrix
*
compute vcr = %decomp(rr)
compute var = %mscalar(.05) , vbr = %mscalar(.05)
*
maximize(parmset=meanparms+garchparms+restrictions,pmethod=simplex,piters=100,method=bfgs,robust,iters=1500) logl gstart gend
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: VAR(1)- GARCH(1,1) in mean with assymetry

Unread post by TomDoan »

This does a VARMA(1,1) mean model (so it includes lags of all the residuals) with square root of the (own) variance as an additional regressor in each equation. To get rid of the MA in the mean equation, drop the MA matrix and its term from the residv formula and the meanparms parmset, and the u(1){1} etc. regressors from the second set of LINREGS.

Code: Select all

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})
*
compute n=3
compute gstart=3,gend=6237
*
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)
*
* These will be the parameters for the mean equations. These are adjusted to add
* variance or covariance terms as needed.
*
dec vect b(n)
dec rect ar(n,n) ma(n,n) gm(n,n)
nonlin(parmset=meanparms) b ar ma gm
*
* Mean model = VARMA(1,1) with sqrt(h) "M" term
*
frml residv = yv-b-ar*yv{1}-ma*%xt(u,t-1)-gm*%sqrt(%xdiag(h))
*
gset yv = ||xjpn,xfra,xsui||
*
* Run preliminary VAR(4) to get estimates of residuals
*
linreg xjpn / u(1)
# constant xjpn{1 to 4} xfra{1 to 4} xsui{1 to 4}
linreg xfra / u(2)
# constant xjpn{1 to 4} xfra{1 to 4} xsui{1 to 4}
linreg xsui / u(3)
# constant xjpn{1 to 4} xfra{1 to 4} xsui{1 to 4}
*
linreg xjpn
# constant xjpn{1} xfra{1} xsui{1} u(1){1} u(2){1} u(3){1}
compute b(1)=%beta(1),ar(1,1)=%beta(2),ar(1,2)=%beta(3),ar(1,3)=%beta(4),$
                      ma(1,1)=%beta(5),ma(1,2)=%beta(6),ma(1,3)=%beta(7)
linreg xfra
# constant xjpn{1} xfra{1} xsui{1} u(1){1} u(2){1} u(3){1}
compute b(2)=%beta(1),ar(2,1)=%beta(2),ar(2,2)=%beta(3),ar(2,3)=%beta(4),$
                      ma(2,1)=%beta(5),ma(2,2)=%beta(6),ma(2,3)=%beta(7)
linreg xsui
# constant xjpn{1} xfra{1} xsui{1} u(1){1} u(2){1} u(3){1}
compute b(3)=%beta(1),ar(3,1)=%beta(2),ar(3,2)=%beta(3),ar(3,3)=%beta(4),$
                      ma(3,1)=%beta(5),ma(3,2)=%beta(6),ma(3,3)=%beta(7)

vcv(matrix=rr,noprint)
# u
*
* These are used to initialize pre-sample variances.
*
gset h  * gend = rr
gset uu * gend = rr
set u(1) = 0.0
set u(2) = 0.0
set u(3) = 0.0
*
declare frml[symm] hf
*
frml logl = $
    hx    = hf(t) , $
    h(t)  = hx, $
    ux    = residv , $
    uu(t) = %outerxx(ux), $
    %pt(u,t,ux),$
    %logdensity(hx,ux)
*
* This does a simple GARCH(1,1) model for the variance.
*
dec symm vcs(n,n) vas(n,n) vbs(n,n)
compute vcs=rr,vbs=%const(0.50),vas=%const(0.05)
nonlin(parmset=garchparms) vcs vas vbs
frml hf = vcs+vbs.*h{1}+vas.*uu{1}
maximize(trace,parmset=meanparms+garchparms,pmethod=simplex,piters=10,method=bfgs,iters=400) logl gstart gend
*
* This does a BEKK model for the variance
*
dec rect vab(n,n) vbb(n,n)
compute vab=.05*%identity(n),vbb=.50*%identity(n)
nonlin(parmset=garchparms) vcs vab vbb
compute vcs=%decomp(rr)
frml hf = vcs*tr(vcs)+vbb*h{1}*tr(vbb)+vab*uu{1}*tr(vab)
maximize(trace,parmset=meanparms+garchparms,pmethod=simplex,piters=10,method=bfgs,iters=400) logl gstart gend
amcqeen
Posts: 17
Joined: Wed Jan 14, 2009 6:42 am

Re: VAR(1)- GARCH(1,1) in mean with assymetry

Unread post by amcqeen »

Hi, is there an assymetry in this code ? If no how can i add teh asymmetry in the conditional variance ?

Maria
Post Reply