Multivariate MS GARCH
Posted: Fri Jun 22, 2012 10:13 am
I am trying to develop a CCC bivariate version of Gray's(1996) MS-GARCH with single-regime mean equations for stock returns. I think the general logic of my code is fine, it draws heavily on the Gray(1996) paper replication example. For some reason however, the following error message pops up during the maximisation (the final line of code):
## MAT15. Subscripts Too Large or Non-Positive
The Error Occurred At Location 196, Line 19 of %MSPROB
I have tried to change the estimation range, but this does not help so far.
The code is as below.
Any help on the possible causes of this error message would be appreciated.
Regards,
Daniel King
## MAT15. Subscripts Too Large or Non-Positive
The Error Occurred At Location 196, Line 19 of %MSPROB
I have tried to change the estimation range, but this does not help so far.
The code is as below.
Any help on the possible causes of this error message would be appreciated.
Regards,
Daniel King
Code: Select all
OPEN DATA "C:\Users\daniel\Desktop\MSCIDaily.xlsx"
CALENDAR(D) 2002:6:3
DATA(FORMAT=XLSX,ORG=COLUMNS,SHEET="Returns") 2002:06:03 2011:12:30 Nigeria SA Kenya Egypt
*Standardise series names for easy changes
set y = sa
set x = egypt
*
@MSSetup(states=4)
*
linreg(robust) y
# constant y{1}
*
*Store initial parameter values for y
compute olsvar1 = %seesq
compute coeff11 = %beta(1)
compute coeff12 = %beta(2)
*
linreg(robust) x
# constant x{1}
*
*Store initial parameter values for x
compute olsvar2 = %seesq
compute coeff21 = %beta(1)
compute coeff22 = %beta(2)
*
* Get some initial values for the MV-GARCH process
garch(p=1,q=1,mv=cc) /y x
*
*
*Declare all variables and assign initial values
* b(coefficient no.,series) - mean equations;
*a(coefficient no., regime, series) and rho – variance equations
nonlin b0y b1y b0x b1x a01y a02y a11y a12y a21y a22y a01x a02x a11x a12x a21x a22x rho1 rho2 p
compute b0y=coeff11, b1y=coeff12, b0x=coeff21, b1x=coeff22
compute a01y=%beta(3),a02y=3*%beta(3), a11y=%beta(5), a12y=3*%beta(5), a21y=%beta(7), a22y=3*%beta(7)
compute a01x=%beta(4), a02x=3*%beta(4), a11x=%beta(6), a12x=3*%beta(6), a21x=%beta(8), a22x=3*%beta(8)
compute rho1=0.5*%beta(9), rho2=2*%beta(9)
compute p=||.8,.1,.0,.0|.1,.8,.1,.1|.1,.1,.8,.1||
*
*Assign initial values to squared residuals and conditional variances
set uu1 = olsvar1
set uu2 = olsvar2
set h1 = olsvar1
set h2 = olsvar2
*
function RegimeGARCHF t
type vector RegimeGARCHF
type integer t
local real h11 h21 cov1 h12 h22 cov2 muy mux
local rectangular HH1(2,2) HH2(2,2) HH3(2,2) HH4(2,2)
local vector U
*
*Define variance-covariance equations for each series, each regime
compute h11= a01y+a11y*uu1(t-1)+a21y*h1(t-1)
compute h12 = a02y+a12y*uu1(t-1)+a22y*h1(t-1)
compute h21 = a01x+a11x*uu2(t-1)+a21x*h2(t-1)
compute h22 = a02x+a12x*uu2(t-1)+a22x*h2(t-1)
compute cov1 = rho1*sqrt(h11)*sqrt(h21)
compute cov2 = rho1*sqrt(h11)*sqrt(h22)
compute cov3 =rho2*sqrt(h12)*sqrt(h21)
compute cov4 =rho2*sqrt(h12)*sqrt(h22)
*
*Define mean equations for each series
compute muy=b0y+b1y*y(t-1)
compute mux=b0x+b1x*x(t-1)
*
*Fill covariance matrices
compute HH1 = ||h11, cov1|cov1,h21||
compute HH2 = ||h11, cov2|cov2,h22||
compute HH3 = ||h12, cov3|cov3,h21||
compute HH4 = ||h12, cov4|cov4,h22||
*
*Fill residuals vector
compute U = ||y(t)-muy,x(t)-mux||
*
*Fill vector of raw density functions
compute RegimeGARCHF=||exp(%logdensity(HH1,U)), exp(%logdensity(HH2,U)), exp(%logdensity(HH3,U)), exp(%logdensity(HH4,U))||
*
*Update variable values
compute uu1(t)= (y(t)-muy)^2
compute uu2(t)= (x(t)-mux)^2
compute h1(t)=(pstar(1)+pstar(2))*(muy^2+h11)+(pstar(3)+pstar(4))*(muy^2+h12)-muy^2
compute h2(t)=(pstar(1)+pstar(3))*(mux^2+h21)+(pstar(2)+pstar(4))*(mux^2+h22)-mux^2
*
end
frml logl = f=RegimeGARCHF(t),fpt=%MSProb(t,f),log(fpt)
nonlin b0y b1y b0x b1x a01y a02y a11y a12y a21y a22y a01x a02x a11x a12x a21x a22x rho1 rho2 p
maximize(start=(pstar=%MSInit()),method=bfgs,iters=100) logl %regstart() %regend()