I have been using the Tse code (older version updated 08/04 for version 6) and trying to estimate a model with parameters in the mean equation including garch-in-mean for Canadian money and output to test is money or output volatility affects growth. I have a further complication of a nonlinear set up in the mean equation where a garch in mean variable is multiplied by recession and expansion dummy variables (to proxy business cycle phases). I have set up my program to estimate the variance first in a M-GARCH-M using the RATS wizard and then use the already estimated conditional variance variable for the nonlinear set-up. Ideally I would like to estimate this model simultaneously to perform the Tse test. I will copy my code below and would welcome any suggestions. Thank you Marianne
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 1961 2 12
all 0 2006:10
* Added this as .txt file
open data cndata3.wks
data(format=wks,org=obs) / dlCNIP dlCNM1x CNREC
*
SET CNEXP = 1-CNREC
*
COMPUTE GSTART=1962:3, GEND=2006:10
*RATS WIZARD
declare symm[series] hhs(2,2)
do i=1,2
do j=1,i
set hhs(i,j) gstart gend = 0.0
end do j
end do i
equation M1eq dlCNM1x
# constant dlCNM1x{1 3 5 9 12} dlCNIP{9 11} hhs(1,1) hhs(2,2)
equation IPeq dlCNIP
# constant dlCNIP{1 3 4 5 8 12} dlCNM1x{2 4 12} hhs(1,1) hhs(2,2)
*
group garchm M1eq IPeq
garch(model=garchm,p=1,q=1,mv=cc,mvhseries=hhs,robust) gstart gend
*
*Tse prg part
compute n=2
*
dec vect[series] y(n) u(n)
dec vect[frml] resid(n)
set y(1) = dlCNM1x
set y(2) = dlCNIP
*
*
clear u
*
* Do initial regression. Copy initial values for regression parameters
*
LINREG Y(1) GSTART GEND u(1)
# CONSTANT Y(1){1 3 5 9 12} Y(2){9 11}
COMPUTE B0 = %BETA(1)
COMPUTE B1 = %BETA(2)
COMPUTE B2 = %BETA(3)
COMPUTE B3 = %BETA(4)
COMPUTE B4 = %BETA(5)
COMPUTE B5 = %BETA(6)
COMPUTE B6 = %BETA(7)
COMPUTE B7 = %BETA(8)
*COMPUTE B8 = %BETA(9)
*COMPUTE B9 = %BETA(10)
*COMPUTE B10 = %BETA(11)
* USREC
LINREG Y(2) GSTART GEND u(2)
# CONSTANT Y(2){1 3 4 5 8 12} Y(1){2 4 12}
COMPUTE B15 = %BETA(1)
COMPUTE B16 = %BETA(2)
COMPUTE B17 = %BETA(3)
COMPUTE B18 = %BETA(4)
COMPUTE B19 = %BETA(5)
COMPUTE B20 = %BETA(6)
COMPUTE B21 = %BETA(7)
COMPUTE B22 = %BETA(8)
COMPUTE B23 = %BETA(9)
COMPUTE B24 = %BETA(10)
*
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
frml resid(1) = (Y(1)-B0-B1*Y(1){1}-B2*Y(1){3}-B3*Y(1){5}-B4*Y(1){9}-B5*Y(1){12} $
-B6*Y(2){9}-B7*Y(2){11}-B8*hhs(1,1)-B9*hhs(2,2))
FRML RESID(2) = (Y(2)-B15-B16*Y(2){1}-B17*Y(2){3}-B18*Y(2){4}-B19*Y(2){5}-B20*Y(2){8} $
-B21*Y(2){12}-B22*Y(1){2}-B23*Y(1){4}-B24*Y(1){12}-B25*CNREC*hhs(1,1)-B26*CNEXP*hhs(1,1)-B27*hhs(2,2))
*
* 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
*
* This is a standard log likelihood formula for any bivariate
* ARCH, GARCH, ARCH-M,... The difference among these will be in
* the definitions of HF and RESID.
*
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-1 x n-1 "symmetric" matrix
* to hold the subdiagonal of the correlation matrix)
*
dec symm qc(n-1,n-1)
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,i-1,hx(i,j)=qc(i-1,j)*sqrt(hx(j,j)*hx(i,i))),hx
ewise qc(i,j)=rr(i-1,j)/sqrt(rr(i-1,i-1)*rr(j,j))
compute vcv=%xdiag(rr),vbv=%const(0.05),vav=%const(0.05)
maximize(parmset=meanparms+garchparms,pmethod=simplex,piters=5,method=bfgs,robust,iters=100,derives=ccderives) logl gstart gend
*
declare real %aic %sbc
compute %aic = -2.0*%logl/%nobs+2.0*%nreg/%nobs
compute %sbc = -2.0*%logl/%nobs+log(%nobs)*%nreg/%nobs
*
disp 'AIC' @20 %aic
disp 'SBC' @20 %sbc
*
display ' ';
display ' *===============================================================================================';
display ' * Test of significance of money coefficients in output equation';
display ' *===============================================================================================';
test(zeros)
# 18 19 20
*
* This has to follow estimation of a constant correlation model. The maximize instruction
* above gets the derivatives of the log likelihood with respect to the CC model parameters
* as the vector[series] ccderives. We now need the derivatives with respect to the "delta"
* parameters in the extended model rho(i,j)(t)=rho(i,j)+delta(i,j)*e(i)(t)e(j)(t) at delta=0,
* which will be the CC estimates.
*
dec symm[series] xd(n-1,n-1)
dec symm qcinv(n,n)
ewise qcinv(i,j)=%if(i==j,1,qc(i-1,j))
compute qcinv=inv(qcinv)
*
* It makes sense to loop the calculations of the derivatives over time first, since much
* of the calculation depends only upon t.
*
dec vector ihu
do time=2,548
compute ux=%xt(u,time),uux=uu(time-1),hx=h(time),ihu=%diag(%sqrt(%xdiag(hx)))*inv(hx)*ux
do i=1,n-1
do j=1,i
set xd(i,j) time time = -qcinv(i+1,j)*uux(i+1,j)+uux(i+1,j)*ihu(i+1)*ihu(j)
end do j
end do i
end do time
*
* The t-stat on the xd is the LM statistic
*
set ones gstart gend = 1.0
linreg ones
# ccderives xd
cdf(title='Tse Test chi-squared(1)') chisqr %trsq 1
M-GARCH in mean model with Tse test
M-GARCH in mean model with Tse test
- Attachments
-
- cndata3.txt
- (18.09 KiB) Downloaded 1197 times
Re: M-GARCH in mean model with Tse test
That looks fine. The Tse test has pretty much the same form regardless of the mean model.