M-GARCH ESTIMATION ERROR
M-GARCH ESTIMATION ERROR
I'm using the Tse code with up to six variables and wondering if you can help me with this error:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*display ' *===============================================================================================';
*display ' * TseCN.prg: Estimates a CC-GARCH model for Canada & perfroms TSE test in RATS 6.3 28/9/09 ';
*display ' * Money and Output with recession dummy split in two ';
*display ' *===============================================================================================';
*
* Tse LM test for constant correlation.
* Tse, Y. K. (2000), “A Test for Constant Correlations in a Multivariate GARCH Model,”
* Journal of Econometrics 98, 107-127.
*
* Updated 08/04 for version 6
*
cal 1960 4 12
all 0 2007:12
open data testweb.xls
data(format=xls,org=obs) / x1 x2 x3 x4 x5 x6
*
*
COMPUTE GSTART=1960:5, GEND=2007:12
*RATS WIZARD
declare symm[series] hhs(6,6)
do i=1,6
do j=1,i
set hhs(i,j) gstart gend = 0.0
end do j
end do i
equation eq1 x1
# constant x2 x3 x4 x5 x6
equation eq2 x2
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
equation eq3 x3
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
equation eq4 x4
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
equation eq5 x5
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
equation eq6 x6
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
*
group garchm eq1 eq2 eq3 eq4 eq5 eq6
garch(model=garchm,p=1,q=1,mv=cc,mvhseries=hhs,pmethod=simplex,piters=50,method=bfgs,robust,iters=100) gstart gend
*Tse prg part
compute n=6
*
dec vect[series] y(n) u(n)
dec vect[frml] resid(n)
set y(1) = x1
set y(2) = x2
set y(3) = x3
set y(4) = x4
set y(5) = x5
set y(6) = x6
*
*
clear u
*
* Do initial regression. Copy initial values for regression parameters
*
LINREG Y(1) GSTART GEND u(1)
# CONSTANT Y(1){1}
COMPUTE B0 = 1.0
COMPUTE B1 = 0.0
COMPUTE B2 = 0.0
COMPUTE B3 = 0.0
COMPUTE B4 = 0.0
* USREC
LINREG Y(2) GSTART GEND u(2)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B5 = %BETA(1)
COMPUTE B6 = %BETA(2)
COMPUTE B7 = %BETA(3)
COMPUTE B8 = %BETA(4)
COMPUTE B9 = %BETA(5)
COMPUTE B10 = %BETA(6)
LINREG Y(3) GSTART GEND u(3)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B11 = %BETA(1)
COMPUTE B12 = %BETA(2)
COMPUTE B13 = %BETA(3)
COMPUTE B14 = %BETA(4)
COMPUTE B15 = %BETA(5)
COMPUTE B16 = %BETA(6)
LINREG Y(4) GSTART GEND u(4)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B17 = %BETA(1)
COMPUTE B18 = %BETA(2)
COMPUTE B19 = %BETA(3)
COMPUTE B20 = %BETA(4)
COMPUTE B21 = %BETA(5)
COMPUTE B22 = %BETA(6)
LINREG Y(5) GSTART GEND u(5)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B23 = %BETA(1)
COMPUTE B24 = %BETA(2)
COMPUTE B25 = %BETA(3)
COMPUTE B26 = %BETA(4)
COMPUTE B27 = %BETA(5)
COMPUTE B28 = %BETA(6)
LINREG Y(6) GSTART GEND u(6)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B29 = %BETA(1)
COMPUTE B30 = %BETA(2)
COMPUTE B31 = %BETA(3)
COMPUTE B32 = %BETA(4)
COMPUTE B33 = %BETA(5)
COMPUTE B34 = %BETA(6)
*
NONLIN(parmset=meanparms) B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 B15 B16 B17 B18 $
B19 B20 B21 B22 B23 B24 B25 B26 B27 B28 B29 B30 B31 B32 B33 B34
frml resid(1) = (Y(1)+hhs(1,1)/2-B0*hhs(1,2)-B1*hhs(1,3)-B2*hhs(1,4)-B3*hhs(1,5)-B4*hhs(1,6))
FRML resid(2) = (Y(2)-B5-B6*Y(2){1}-B7*Y(3){1}-B8*Y(4){1}-B9*Y(5){1}-B10*Y(6){1})
FRML resid(3) = (Y(2)-B11-B12*Y(2){1}-B13*Y(3){1}-B14*Y(4){1}-B15*Y(5){1}-B16*Y(6){1})
FRML resid(4) = (Y(2)-B17-B18*Y(2){1}-B19*Y(3){1}-B20*Y(4){1}-B21*Y(5){1}-B22*Y(6){1})
FRML resid(5) = (Y(2)-B23-B24*Y(2){1}-B25*Y(3){1}-B26*Y(4){1}-B27*Y(5){1}-B28*Y(6){1})
FRML resid(6) = (Y(2)-B29-B30*Y(2){1}-B31*Y(3){1}-B32*Y(4){1}-B33*Y(5){1}-B34*Y(6){1})
*print / u
*
* Get the covariance matrix of the residuals.
*
vcv(matrix=rr,print)
# u
*
* h will have the sequence of variance estimates
* uu will have the sequence of uu' matrices
*
dec series[symm] h uu
*
* hx and uux are used when extracting elements from h and uu.
* ux is used when extracting a u vector
*
declare symm hx(n,n) uux(n,n)
declare vect ux(n)
*
* This is used to initialize pre-sample variances.
*
gset h = rr
gset uu = rr
*
*
declare frml[symm] hf
*
frml logl = $
%do(i,1,n,u(i)=resid(i)),$
hx = hf(t) , $
ux = %xt(u,t) , uux = %outerxx(ux),$
h(t) = hx , uu(t) = uux,$
%logdensity(hx,ux)
*
* Constant correlation (reparameterized to use an n x n "symmetric" matrix
* to hold the subdiagonal of the correlation matrix)
*
dec symm qc(n,n)
dec vect vcv(n) vbv(n) vav(n)
nonlin(parmset=garchparms) vcv vbv vav qc
frml hf = %do(i,1,n,%(hx(i,i)=vcv(i)+vav(i)*h{1}(i,i)+vbv(i)*uu{1}(i,i))),$
%do(j,1,n,hx(i,j)=%if(i==j,hx(i,i),qc(i,j)*sqrt(hx(j,j)*hx(i,i)))),hx
ewise qc(i,j)=rr(i,j)/sqrt(rr(i,i)*rr(j,j))
compute vcv=%xdiag(rr),vbv=%const(0.05),vav=%const(0.75)
maximize(parmset=meanparms+garchparms,pmethod=simplex,piters=1,method=bfgs,robusterrors,iters=100,derives=ccderives) logl gstart gend
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
got : ## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points
Thanks in advance for your kind help.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*display ' *===============================================================================================';
*display ' * TseCN.prg: Estimates a CC-GARCH model for Canada & perfroms TSE test in RATS 6.3 28/9/09 ';
*display ' * Money and Output with recession dummy split in two ';
*display ' *===============================================================================================';
*
* Tse LM test for constant correlation.
* Tse, Y. K. (2000), “A Test for Constant Correlations in a Multivariate GARCH Model,”
* Journal of Econometrics 98, 107-127.
*
* Updated 08/04 for version 6
*
cal 1960 4 12
all 0 2007:12
open data testweb.xls
data(format=xls,org=obs) / x1 x2 x3 x4 x5 x6
*
*
COMPUTE GSTART=1960:5, GEND=2007:12
*RATS WIZARD
declare symm[series] hhs(6,6)
do i=1,6
do j=1,i
set hhs(i,j) gstart gend = 0.0
end do j
end do i
equation eq1 x1
# constant x2 x3 x4 x5 x6
equation eq2 x2
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
equation eq3 x3
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
equation eq4 x4
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
equation eq5 x5
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
equation eq6 x6
# constant x2{1} x3{1} x4{1} x5{1} x6{1}
*
group garchm eq1 eq2 eq3 eq4 eq5 eq6
garch(model=garchm,p=1,q=1,mv=cc,mvhseries=hhs,pmethod=simplex,piters=50,method=bfgs,robust,iters=100) gstart gend
*Tse prg part
compute n=6
*
dec vect[series] y(n) u(n)
dec vect[frml] resid(n)
set y(1) = x1
set y(2) = x2
set y(3) = x3
set y(4) = x4
set y(5) = x5
set y(6) = x6
*
*
clear u
*
* Do initial regression. Copy initial values for regression parameters
*
LINREG Y(1) GSTART GEND u(1)
# CONSTANT Y(1){1}
COMPUTE B0 = 1.0
COMPUTE B1 = 0.0
COMPUTE B2 = 0.0
COMPUTE B3 = 0.0
COMPUTE B4 = 0.0
* USREC
LINREG Y(2) GSTART GEND u(2)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B5 = %BETA(1)
COMPUTE B6 = %BETA(2)
COMPUTE B7 = %BETA(3)
COMPUTE B8 = %BETA(4)
COMPUTE B9 = %BETA(5)
COMPUTE B10 = %BETA(6)
LINREG Y(3) GSTART GEND u(3)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B11 = %BETA(1)
COMPUTE B12 = %BETA(2)
COMPUTE B13 = %BETA(3)
COMPUTE B14 = %BETA(4)
COMPUTE B15 = %BETA(5)
COMPUTE B16 = %BETA(6)
LINREG Y(4) GSTART GEND u(4)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B17 = %BETA(1)
COMPUTE B18 = %BETA(2)
COMPUTE B19 = %BETA(3)
COMPUTE B20 = %BETA(4)
COMPUTE B21 = %BETA(5)
COMPUTE B22 = %BETA(6)
LINREG Y(5) GSTART GEND u(5)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B23 = %BETA(1)
COMPUTE B24 = %BETA(2)
COMPUTE B25 = %BETA(3)
COMPUTE B26 = %BETA(4)
COMPUTE B27 = %BETA(5)
COMPUTE B28 = %BETA(6)
LINREG Y(6) GSTART GEND u(6)
# CONSTANT Y(2){1} Y(3){1} Y(4){1} Y(5){1} Y(6){1}
COMPUTE B29 = %BETA(1)
COMPUTE B30 = %BETA(2)
COMPUTE B31 = %BETA(3)
COMPUTE B32 = %BETA(4)
COMPUTE B33 = %BETA(5)
COMPUTE B34 = %BETA(6)
*
NONLIN(parmset=meanparms) B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 B15 B16 B17 B18 $
B19 B20 B21 B22 B23 B24 B25 B26 B27 B28 B29 B30 B31 B32 B33 B34
frml resid(1) = (Y(1)+hhs(1,1)/2-B0*hhs(1,2)-B1*hhs(1,3)-B2*hhs(1,4)-B3*hhs(1,5)-B4*hhs(1,6))
FRML resid(2) = (Y(2)-B5-B6*Y(2){1}-B7*Y(3){1}-B8*Y(4){1}-B9*Y(5){1}-B10*Y(6){1})
FRML resid(3) = (Y(2)-B11-B12*Y(2){1}-B13*Y(3){1}-B14*Y(4){1}-B15*Y(5){1}-B16*Y(6){1})
FRML resid(4) = (Y(2)-B17-B18*Y(2){1}-B19*Y(3){1}-B20*Y(4){1}-B21*Y(5){1}-B22*Y(6){1})
FRML resid(5) = (Y(2)-B23-B24*Y(2){1}-B25*Y(3){1}-B26*Y(4){1}-B27*Y(5){1}-B28*Y(6){1})
FRML resid(6) = (Y(2)-B29-B30*Y(2){1}-B31*Y(3){1}-B32*Y(4){1}-B33*Y(5){1}-B34*Y(6){1})
*print / u
*
* Get the covariance matrix of the residuals.
*
vcv(matrix=rr,print)
# u
*
* h will have the sequence of variance estimates
* uu will have the sequence of uu' matrices
*
dec series[symm] h uu
*
* hx and uux are used when extracting elements from h and uu.
* ux is used when extracting a u vector
*
declare symm hx(n,n) uux(n,n)
declare vect ux(n)
*
* This is used to initialize pre-sample variances.
*
gset h = rr
gset uu = rr
*
*
declare frml[symm] hf
*
frml logl = $
%do(i,1,n,u(i)=resid(i)),$
hx = hf(t) , $
ux = %xt(u,t) , uux = %outerxx(ux),$
h(t) = hx , uu(t) = uux,$
%logdensity(hx,ux)
*
* Constant correlation (reparameterized to use an n x n "symmetric" matrix
* to hold the subdiagonal of the correlation matrix)
*
dec symm qc(n,n)
dec vect vcv(n) vbv(n) vav(n)
nonlin(parmset=garchparms) vcv vbv vav qc
frml hf = %do(i,1,n,%(hx(i,i)=vcv(i)+vav(i)*h{1}(i,i)+vbv(i)*uu{1}(i,i))),$
%do(j,1,n,hx(i,j)=%if(i==j,hx(i,i),qc(i,j)*sqrt(hx(j,j)*hx(i,i)))),hx
ewise qc(i,j)=rr(i,j)/sqrt(rr(i,i)*rr(j,j))
compute vcv=%xdiag(rr),vbv=%const(0.05),vav=%const(0.75)
maximize(parmset=meanparms+garchparms,pmethod=simplex,piters=1,method=bfgs,robusterrors,iters=100,derives=ccderives) logl gstart gend
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
got : ## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points
Thanks in advance for your kind help.
- Attachments
-
- testweb.xls
- (103 KiB) Downloaded 790 times
Re: M-GARCH ESTIMATION ERROR
That's quite an old version of the Tse test; you might want to get the newer one from the web site. At any rate, the nesting on the definition of HF isn't quite right. It needs to be:
The %do(j,....) has to be inside the %do(i,1,n,%(....))
Code: Select all
frml hf = %do(i,1,n,%($
hx(i,i)=vcv(i)+vav(i)*h{1}(i,i)+vbv(i)*uu{1}(i,i),$
%do(j,1,i,hx(i,j)=%if(i==j,hx(i,i),qc(i,j)*sqrt(hx(j,j)*hx(i,i))))$
)),hxRe: M-GARCH ESTIMATION ERROR
Thanks a lot Tom,
Yes the code is quite old but I'm mainly interested in the estimation part, since BEKK cannot be used with more than 4 var and I have 6 I tried tse code. Maybe there is a better code !!!
Yes the code is quite old but I'm mainly interested in the estimation part, since BEKK cannot be used with more than 4 var and I have 6 I tried tse code. Maybe there is a better code !!!
Re: M-GARCH ESTIMATION ERROR
Hi Tom,
When I try to run the program with the suggested change I got this error:
and a close check show that this error is due to the suggested changes at:
Thanks again for your kind help.
Sam
When I try to run the program with the suggested change I got this error:
Code: Select all
Can't Find Match for %(REAL,INTEGER). Closest Match is %(Any)
## SX27. Illegal Combination of Data Types for Operation
>>>> )<<<<Code: Select all
frml hf = %do(i,1,n,%($
hx(i,i)=vcv(i)+vav(i)*h{1}(i,i)+vbv(i)*uu{1}(i,i),$
%do(j,1,i,hx(i,j)=%if(i==j,hx(i,i),qc(i,j)*sqrt(hx(j,j)*hx(i,i))))$
)),hxSam
Re: M-GARCH ESTIMATION ERROR
What version of RATS are you using? I don't get that, and I've tried several older versions as well.
Re: M-GARCH ESTIMATION ERROR
Hi Tom,
I'm using version 6.3. Is it a version compatibility ?
I'm using version 6.3. Is it a version compatibility ?
Re: M-GARCH ESTIMATION ERROR
Thanks for your help.
Sam.
Sam.
Re: M-GARCH ESTIMATION ERROR
Hi Tom,
I'M trying to estimate the above model with the wrong covariance matrix. I'm wondering if there is any way of changing the code to account for an off-diag matrix [qc] and diag with ones (cc model):
dec symm qcc(n,n)
dec symm qc(n,n)
dec vect vcv(n) vbv(n) vav(n)
nonlin(parmset=garchparms) vcv vbv vav qc
frml hf = %do(i,1,n,%($
hx(i,i)=vcv(i)+vav(i)*h{1}(i,i)+vbv(i)*uu{1}(i,i),qcc(i,i)=1.0,$
%do(j,1,i,hx(i,j)=%if(i==j,hx(i,i),qcc(i,j)*sqrt(hx(j,j)*hx(i,i) ) ),qcc(i,j)=qc(i,j)/sqrt(qc(i,i)*qc(j,j)))$
)),hx
ewise qc(i,j)=rr(i,j)/sqrt(rr(i,i)*rr(j,j))
ewise qcc(i,j)=qc(i,j)/sqrt(qc(i,i)*qc(j,j))
but the program is not working I believe the qcc part is not working properly.
Thanks for your help.
Sam.
I'M trying to estimate the above model with the wrong covariance matrix. I'm wondering if there is any way of changing the code to account for an off-diag matrix [qc] and diag with ones (cc model):
dec symm qcc(n,n)
dec symm qc(n,n)
dec vect vcv(n) vbv(n) vav(n)
nonlin(parmset=garchparms) vcv vbv vav qc
frml hf = %do(i,1,n,%($
hx(i,i)=vcv(i)+vav(i)*h{1}(i,i)+vbv(i)*uu{1}(i,i),qcc(i,i)=1.0,$
%do(j,1,i,hx(i,j)=%if(i==j,hx(i,i),qcc(i,j)*sqrt(hx(j,j)*hx(i,i) ) ),qcc(i,j)=qc(i,j)/sqrt(qc(i,i)*qc(j,j)))$
)),hx
ewise qc(i,j)=rr(i,j)/sqrt(rr(i,i)*rr(j,j))
ewise qcc(i,j)=qc(i,j)/sqrt(qc(i,i)*qc(j,j))
but the program is not working I believe the qcc part is not working properly.
Thanks for your help.
Sam.
Re: M-GARCH ESTIMATION ERROR
I'm not 100% sure of what you're trying to do but
has what's basically a circular definition of qcc(i,j)---it's using qcc(i,j) in the %do(j,...) segment, then defines qcc(i,j) as the correlation after that.
Code: Select all
frml hf = %do(i,1,n,%($
hx(i,i)=vcv(i)+vav(i)*h{1}(i,i)+vbv(i)*uu{1}(i,i),qcc(i,i)=1.0,$
%do(j,1,i,hx(i,j)=%if(i==j,hx(i,i),qcc(i,j)*sqrt(hx(j,j)*hx(i,i) ) ),qcc(i,j)=qc(i,j)/sqrt(qc(i,i)*qc(j,j)))$
)),hxRe: M-GARCH ESTIMATION ERROR
Thanks Tom for you reply.
Sam
Sam