Dear everyone,
I am working on a M-GARCH with volatility reversion model.
It is based on the paper 'volatility reversion and correlation structure of returns in major international stock markets' The financial review vol.32
no.2 pp. 205-224.
I have modified the ccc-mv-garch code.
*
OPEN DATA D:\study\project2009\vtadcc\RAWData2.XLS
ALL 2306
DATA(FORMAT=XLS,ORG=COLUMNS) / chi mal phill tw hk jp sg aus uk us dummy
*
******************************************
COMPUTE GSTART=4 , GEND=2305
* n = the number of equations:
******************************************
compute n=3
dec vect[series] y(n) u(n) dm(n)
dec vect[frml] resid(n)
dec series cd
set y(1) = SG
set y(2) = JP
set y(3) = HK
set dm(1) = DUMMY
set dm(2) = DUMMY
set dm(3) = DUMMY
dec vect bm(n) d(n)
dec rect ba(n,n)
nonlin(parmset=meanparms) d bm ba
****************************************************************************
*****************
frml ar11 = ba(1,1)*y(1){1}+ba(1,2)*y(2){1}+ba(1,3)*y(3){1}
frml ar12 = ba(2,1)*y(1){1}+ba(2,2)*y(2){1}+ba(2,3)*y(3){1}
frml ar13 = ba(3,1)*y(1){1}+ba(3,2)*y(2){1}+ba(3,3)*y(3){1}
****************************************************************************
*****************
frml resid(1) = y(1)-d(1)-ar11-bm(1)*cd
frml resid(2) = y(2)-d(2)-ar12-bm(2)*cd
frml resid(3) = y(3)-d(3)-ar13-bm(3)*cd
* Initialization
compute bm=%const(0.0)
compute ba=%const(0.0)
compute d=%const(0.0)
do i=1,n
linreg(noprint) y(i) / u(i)
# constant
compute d(i)=%beta(1)
end do i
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 mm
*
* ux is used when extracting a u vector
*
declare symm hx(n,n)
declare symm hhx(n,n)
declare vect ux(n)
declare vect dx(n)
*
* These are used to initialize pre-sample variances.
*
gset h * gend = rr
gset uu * gend = rr
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), $
dx = %xt(dm,t), $
mm(t)=%outerxx(dx), $
%logdensity(hx,ux)
dec symm qc(n-1,n-1) qd(n-1,n-1)
dec vect vcv(n) vbv(n) vav(n) vdv(n)
*
function hfcccgarch time
type symm hfcccgarch
type integer time
do i=1,n
compute
hx(i,i)=vcv(i)+vav(i)*h(time-1)(i,i)+vbv(i)*uu(time-1)(i,i)+vdv(i)*mm(time-1
)(i,i)
do j=1,i-1
compute
hx(i,j)=qc(i-1,j)*sqrt(hx(j,j)*hx(i,i))+qd(i-1,j)*mm(time)(i,i)*sqrt(hx(j,j)
*hx(i,i))
end do j
end do i
compute hfcccgarch=hx
end
*
frml hf = hfcccgarch(t)
nonlin(parmset=garchparms) vcv vbv vav vdv qc qd compute vcv=%decomp(rr),vbv=%const(0.05) compute vav=%const(0.05),vdv=%const(0.05) compute qc=%const(0.05),qd=%const(0.05)
maximize(parmset=meanparms+garchparms,pmethod=simplex,piters=10,method=bfgs)
logl gstart gend
When I run the code, I meet the problem as follows:
## MAT15. Subscripts Too Large or Non-Positive The Error Occurred At Location 0045 of HFCCCGARCH Line 5 of HFCCCGARCH
Can anybody help me to figure out what is the problem with the code?
Thanks very much.
Regards,
Jingran
M-GARCH with volatility reversion
Re: M-GARCH with volatility reversion
You're not defining pre-sample values of MM. You need a
in with the other GSET instructions.
I also noted that the CD series never seems to be defined. You might want to check into that as well.
Code: Select all
GSET MM * gend = something (probably zeros)I also noted that the CD series never seems to be defined. You might want to check into that as well.