************************************
**FOUR DIMENSIONAL EGARCH PROGRAM
**WITH MEAN AND ASYMMETRIC VOLATILITY SPILLOVERS
**BY GREGORY KOUTMOS
**
**FAIRFIELD UNIVERSITY SCHOOL OF BUSINESS
**FAIRFIELD CT 06430
*** EMAIL: GKOUTMOS@FAIRFIELD.EDU
***NOTE: For more info on the multivariate EGARCH Model
***see Koutmos G. (1996) "Modeling the Dynamic Interdependence of
***Major European Stock Markets", Journal of Business Finance and Accounting,
***1996, Vol. 23, pp. 975-988.
**
**Revised 12/2009 by Tom Doan, Estima.
**
****************************************

cal(d) 2003:1:2
all 2007:06:29
open data period1.xls
data(format=xls, org=obs) / nasdaq idx xr
*
compute n=3
*
* Define the return series
*
dec vect[series] r(n)
compute start=2003:1:2, end=2007:06:29
set r(1) = 100*log(nasdaq/nasdaq{1})
set r(2) = 100*log(idx/idx{1})
set r(3) = 100*log(xr/xr{1})
*
* Template for mean equation. This is a VAR(2)
*
equation meaneq *
# constant r(1){1} r(1){2} r(2){1} r(2){2} r(3){1} r(3){2}
*
table
*
dec vect[series] u(n)          ;* Residuals
dec vect[series] v(n)          ;* Variances
dec vect[frml]   e(n)          ;* Model for mean
dec vect[frml]   z(n)          ;* EGARCH indexes
dec vect         d(n)          ;* Asymmetry coefficients in EGARCH
dec vect         g(n)          ;* Lagged variance coefficients in EGARCH
*
* Subdiagonal for correlation matrix
*
dec symm         rr(n-1,n-1)
*
* Coefficient vectors for the VAR (b) and the EGARCH with spillover (a).
* The variance for equation i takes the form:
*
* log h(i) = a(i)(1)+sum_j a(i)(j+1) z(j){1} + g(i) log h(i){-1}
*
* z(i) = abs(u(i)/sqrt(h(i))) - sqrt(2/pi) + d(i)*u(i)/sqrt(h(i))
*
dec vect[vect] b(n)
dec vect[vect] a(n)
*
* Set up the formulas for the mean and for calculating the "z"
*
do i=1,n
   frml(equation=meaneq,vector=b(i)) e(i)
   frml z(i) = abs(u(&i){0})/sqrt(v(&i){0})-sqrt(2/%pi)+d(&i)*u(&i){0}/sqrt(v(&i){0})
end do i
*
dec symm sigma
*
* Do calculations at time <<t>> for the residuals (u), variances (v) and
* full covariance matrix (return value for function).
*
function EGARCHSpillover t
type symmetric EGARCHSpillover
type integer   t
*
local integer i j
local real    hlog
*
do i=1,n
   compute hlog=a(i)(1)+g(i)*log(v(i)(t-1))
   do j=1,n
      compute hlog=hlog+a(i)(j+1)*z(j)(t-1)
   end do j
   compute v(i)(t) = exp(hlog)
   compute u(i)(t) = r(i)(t)-e(i)(t)
end do i
dim EGARCHSpillover(n,n)
ewise EGARCHSpillover(i,j)=%if(i==j,v(i)(t),rr(i-1,j)*sqrt(v(i)(t)*v(j)(t)))
end EGARCHSpillover
*
* Log likelihood
*
frml Lt = sigma=EGARCHSpillover(t),%logdensity(sigma,%xt(u,t))
*
* Initial guess values from running regressions. The b's are the OLS
* estimates, a's, g's and d's are (except for the constant) standard
* guess values.
*
do i=1,n
   linreg(equation=meaneq,noprint) r(i)
   set u(i) = %if(%valid(%resids),%resids,0.0)
   compute b(i) = %beta
   compute a(i) = %zeros(n+1,1)
   compute a(i)(1)=log(%seesq),a(i)(i+1)=.25
   compute g(i)=.80,d(i)=0.0
   set v(i) = %seesq
end do i
*
compute rr=%zeros(n-1,n-1)
*
nonlin b a d g rr
maximize(pmethod=simplex,piters=2,method=bfgs,trace,iters=200) Lt start+1 end
## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points



