GARCH Model with Day of Week Dummies
Posted: Fri Nov 17, 2023 8:21 am
I attached the data. It is daily returns of stock market index. I don't know how to interoperate results and which estimation is correct.
A Forum for RATS Software and Econometrics Discussions
https://estima.com/forum/
Code: Select all
*
* Replication file for Baillie and Bollerslev, "The Message in Daily
* Exchange Rates: A Conditional Variance Tale", JBES 1989, vol 7, pp
* 297-305
*
open data bbjbes1989.xls
data(format=xls,org=columns) 1 1245 uk dow
*
labels uk
# "U.K."
log uk
*
* Unit root tests
* Table 1
*
source ppunit.src
report(action=define)
dofor s = uk
report(col=new,atrow=1) %l(s)
@ppunit(lags=22,det=trend) s
report(col=current,atrow=2) %cdstat
@ppunit(lags=22) s
report(col=current,atrow=3) %cdstat
end dofor
report(action=format,picture="*.###")
report(action=show)
*
* Table 2 estimates
*
report(action=define)
dofor s = uk
report(col=new,atrow=1) %l(s)
set dx = 100.0*(s{0}-s{1})
linreg(noprint) dx
# constant dx{1}
report(col=curr,atrow=2) %beta(1)
report(col=curr,atrow=3,special=parens) %stderrs(1)
report(col=curr,atrow=4) %sigmasq
report(col=curr,atrow=5) %logl
set ustd = %resids/sqrt(%seesq)
corr(print,qstats,number=15,method=yule) ustd
report(col=curr,atrow=6) %qstat
set usqr = ustd^2
corr(print,qstats,number=15,method=yule) usqr
report(col=curr,atrow=7) %qstat
stats(noprint) %resids
report(col=curr,atrow=8) %skewness
report(col=curr,atrow=9) %kurtosis
end dofor s
report(action=format,picture="*.###",align=decimal)
report(action=show)
*
* Table 3
*
* The DOW series is 2 for Monday,...,6 for Friday. Create dummies for
* each day of the week.
*
dec vect[series] dd(5)
do i=1,5
set dd(i) = dow==(i+1)
end do i
*
*
* SKIP is a dummy variable which will be 1 if and only if there is a
* skipped weekday.
*
set(first=1.0) skip = .not.(dow{1}+1==dow.or.(dow{1}==6.and.dow==2))
*
nonlin(parmset=meanparms) b0 b1 b2 b3 b4 b5
nonlin(parmset=garchshifts) w1 w2 w3 w4 w5 w6 w7
nonlin(parmset=garchparms) alpha1 beta1 rnu
declare series uu h u
frml varf = alpha1*uu{1}+beta1*h{1}+$
w1*dd(1)+w2*dd(2)+w3*dd(3)+w4*dd(4)+w5*dd(5)+w6*skip+w7*skip{1}-$
(alpha1+beta1)*(w1*dd(1){1}+w2*dd(2){1}+w3*dd(3){1}+w4*dd(4){1}+w5*dd(5){1}+w6*skip{1}+w7*skip{2})
frml meanf = b0*dx{1}+b1*dd(1)+b2*dd(2)+b3*dd(3)+b4*dd(4)+b5*dd(5)
frml logl = (u=dx-meanf),(uu(t)=u^2),(h(t)=varf(t)),%logtdensity(h,u,1./rnu)
*
report(action=define,hlabels=||"","U.K."||)
dofor s = uk
set dx = 100.0*(s{0}-s{1})
*
* Get preliminary guess values for the mean parameters off an OLS
* regression on the mean dummies.
*
linreg(noprint) dx
# dd dx{1}
compute hinit=%seesq
*
set uu = %resids^2
set h = hinit
set u = %resids
*
* Poke those into the meanparms.
*
compute %parmspoke(meanparms,%beta)
*
* Get preliminary guess values for the dummy terms in the variance
* equation by an OLS regression of the squared residuals on the
* dummies.
*
linreg uu
# dd skip skip{1}
*
* Poke those into the shift parameters
*
compute %parmspoke(garchshifts,%beta)
*
* Set initial guess values for the reciprocal degrees of freedom, and
* the GARCH parameters.
*
compute rnu=.10
compute alpha1=.1,beta1=.8
*
set test 3 * = logl(t)
sstats 3 * .not.%valid(test)>>nmiss
if nmiss>0.0
compute w1=w2=w3=w4=w5=hinit,w6=w7=0.0
maximize(parmset=meanparms+garchshifts+garchparms,pmethod=simplex,piter=10,method=bhhh) logl 3 *
report(regressors,extra=stderrs)
report(col=current,atrow=2*%nreg+2) %funcval
stats u 3 *
set ustd 3 * = u/sqrt(h)
corr(print,qstats,number=15,method=yule) ustd 3 *
report(col=current,atrow=2*%nreg+3) %qstat
set usqr 3 * = ustd^2
corr(print,qstats,number=15,method=yule) usqr 3 *
report(col=current,atrow=2*%nreg+4) %qstat
stats(noprint) ustd
report(col=current,atrow=2*%nreg+5) %skewness
report(col=current,atrow=2*%nreg+6) %kurtosis
report(col=current,atrow=2*%nreg+7) 3.0*(1.0/rnu-2.0)/(1.0/rnu-4.0)
end dofor
report(action=show)
*
* Table 4
*
*
* Table 5
*
set pullweds = dow==4.or.dow==5.and.dow{1}==3
dofor s = uk
sample(smpl=pullweds) s / wx
clear dx
set dx = 100.0*(wx-wx{1})
garch(p=1,q=1) / dx
end dofor s
*
* Table 6
*
dofor s = uk
sample(smpl=pullweds) s / wx
sample(smpl=%clock(t,2)==1) wx / w2x
clear dx
set dx = 100.0*(w2x-w2x{1})
garch(q=1) / dx
end dofor s
*
* Table 7
*
dofor s = uk
sample(smpl=pullweds) s / wx
sample(smpl=%clock(t,4)==1) wx / w4x
clear dx
set dx = 100.0*(w4x-w4x{1})
garch(q=0,p=0) / dx
end dofor s
Code: Select all
*
* Replication file for Baillie and Bollerslev, "The Message in Daily
* Exchange Rates: A Conditional Variance Tale", JBES 1989, vol 7, pp
* 297-305
*
open data bbjbes1989.xls
data(format=xls,org=columns) 1 1245 uk dow
*
labels uk
# "U.K."
log uk
*
* Unit root tests
* Table 1
*
source ppunit.src
report(action=define)
dofor s = uk
report(col=new,atrow=1) %l(s)
@ppunit(lags=22,det=trend) s
report(col=current,atrow=2) %cdstat
@ppunit(lags=22) s
report(col=current,atrow=3) %cdstat
end dofor
report(action=format,picture="*.###")
report(action=show)
*
* Table 2 estimates
*
report(action=define)
dofor s = uk
report(col=new,atrow=1) %l(s)
set dx = 100.0*(s{0}-s{1})
linreg(noprint) dx
# constant dx{1}
report(col=curr,atrow=2) %beta(1)
report(col=curr,atrow=3,special=parens) %stderrs(1)
report(col=curr,atrow=4) %sigmasq
report(col=curr,atrow=5) %logl
set ustd = %resids/sqrt(%seesq)
corr(print,qstats,number=15,method=yule) ustd
report(col=curr,atrow=6) %qstat
set usqr = ustd^2
corr(print,qstats,number=15,method=yule) usqr
report(col=curr,atrow=7) %qstat
stats(noprint) %resids
report(col=curr,atrow=8) %skewness
report(col=curr,atrow=9) %kurtosis
end dofor s
report(action=format,picture="*.###",align=decimal)
report(action=show)
*
* Table 3
*
* The DOW series is 2 for Monday,...,6 for Friday. Create dummies for
* each day of the week.
*
dec vect[series] dd(5)
do i=1,5
set dd(i) = dow==(i+1)
end do i
*
*
* SKIP is a dummy variable which will be 1 if and only if there is a
* skipped weekday.
*
set(first=1.0) skip = .not.(dow{1}+1==dow.or.(dow{1}==6.and.dow==2))
*
nonlin(parmset=meanparms) b0 b1 b2 b3 b4 b5
nonlin(parmset=garchshifts) w1 w2 w3 w4 w5 w6 w7
nonlin(parmset=garchparms) alpha1 beta1 rnu
declare series uu h u
frml varf = alpha1*uu{1}+beta1*h{1}+$
w1*dd(1)+w2*dd(2)+w3*dd(3)+w4*dd(4)+w5*dd(5)+w6*skip+w7*skip{1}-$
(alpha1+beta1)*(w1*dd(1){1}+w2*dd(2){1}+w3*dd(3){1}+w4*dd(4){1}+w5*dd(5){1}+w6*skip{1}+w7*skip{2})
frml meanf = b0*dx{1}+b1*dd(1)+b2*dd(2)+b3*dd(3)+b4*dd(4)+b5*dd(5)
frml logl = (u=dx-meanf),(uu(t)=u^2),(h(t)=varf(t)),%logtdensity(h,u,1./rnu)
*
report(action=define,hlabels=||"","U.K."||)
dofor s = uk
set dx = 100.0*(s{0}-s{1})
*
* Get preliminary guess values for the mean parameters off an OLS
* regression on the mean dummies.
*
linreg(noprint) dx
# dd dx{1}
compute hinit=%seesq
*
set uu = %resids^2
set h = hinit
set u = %resids
*
* Poke those into the meanparms.
*
compute %parmspoke(meanparms,%beta)
*
* Get preliminary guess values for the dummy terms in the variance
* equation by an OLS regression of the squared residuals on the
* dummies.
*
linreg uu
# dd skip skip{1}
*
* Poke those into the shift parameters
*
compute %parmspoke(garchshifts,%beta)
*
* Set initial guess values for the reciprocal degrees of freedom, and
* the GARCH parameters.
*
compute rnu=.10
compute alpha1=.1,beta1=.8
*
set test 4 * = logl(t)
sstats 4 * .not.%valid(test)>>nmiss
if nmiss>0.0
compute w1=w2=w3=w4=w5=hinit,w6=w7=0.0
maximize(parmset=meanparms+garchshifts+garchparms,pmethod=simplex,piter=10,method=bhhh) logl 4 *
report(regressors,extra=stderrs)
report(col=current,atrow=2*%nreg+2) %funcval
stats u 4 *
set ustd 4 * = u/sqrt(h)
corr(print,qstats,number=15,method=yule) ustd 4 *
report(col=current,atrow=2*%nreg+3) %qstat
set usqr 4 * = ustd^2
corr(print,qstats,number=15,method=yule) usqr 4 *
report(col=current,atrow=2*%nreg+4) %qstat
stats(noprint) ustd
report(col=current,atrow=2*%nreg+5) %skewness
report(col=current,atrow=2*%nreg+6) %kurtosis
report(col=current,atrow=2*%nreg+7) 3.0*(1.0/rnu-2.0)/(1.0/rnu-4.0)
end dofor
report(action=show)
*
* Table 4
*
*
* Table 5
*
set pullweds = dow==4.or.dow==5.and.dow{1}==3
dofor s = uk
sample(smpl=pullweds) s / wx
clear dx
set dx = 100.0*(wx-wx{1})
garch(p=1,q=1) / dx
end dofor s
*
* Table 6
*
dofor s = uk
sample(smpl=pullweds) s / wx
sample(smpl=%clock(t,2)==1) wx / w2x
clear dx
set dx = 100.0*(w2x-w2x{1})
garch(q=1) / dx
end dofor s
*
* Table 7
*
dofor s = uk
sample(smpl=pullweds) s / wx
sample(smpl=%clock(t,4)==1) wx / w4x
clear dx
set dx = 100.0*(w4x-w4x{1})
garch(q=0,p=0) / dx
end dofor s
Code: Select all
MAXIMIZE - Estimation by BHHH
Convergence in 10 Iterations. Final criterion was 0.0000095 <= 0.0000100
Usable Observations 1242
Function Value -1165.2391
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. B0 0.013012346 0.028466351 0.45711 0.64758966
2. B1 -0.064075841 0.042711632 -1.50020 0.13356351
3. B2 -0.057499564 0.039170838 -1.46792 0.14212660
4. B3 0.026512784 0.034124198 0.77695 0.43718847
5. B4 -0.064163143 0.033148627 -1.93562 0.05291427
6. B5 -0.058204904 0.035690080 -1.63084 0.10292353
7. W1 0.480607704 0.088004104 5.46120 0.00000005
8. W2 0.456222675 0.083076870 5.49157 0.00000004
9. W3 0.374530021 0.077960194 4.80412 0.00000155
10. W4 0.354630814 0.074017381 4.79118 0.00000166
11. W5 0.400586574 0.076987014 5.20330 0.00000020
12. W6 0.349708358 0.214236268 1.63235 0.10260599
13. W7 0.217122833 0.165195760 1.31434 0.18873295
14. ALPHA1 0.057109064 0.016432176 3.47544 0.00051001
15. BETA1 0.917314515 0.024434478 37.54181 0.00000000
16. RNU 0.111191440 0.021623818 5.14208 0.00000027
Code: Select all
*
* Replication file for Baillie and Bollerslev, "The Message in Daily
* Exchange Rates: A Conditional Variance Tale", JBES 1989, vol 7, pp
* 297-305
*
open data tom1.xlsx
data(format=xlsx,org=columns) 1 3255 sto dow
*
labels sto
# "Stock"
log sto
*
* Unit root tests
* Table 1
*
source ppunit.src
report(action=define)
dofor s = sto
report(col=new,atrow=1) %l(s)
@ppunit(lags=22,det=trend) s
report(col=current,atrow=2) %cdstat
@ppunit(lags=22) s
report(col=current,atrow=3) %cdstat
end dofor
report(action=format,picture="*.###")
report(action=show)
*
* Table 2 estimates
*
report(action=define)
dofor s = sto
report(col=new,atrow=1) %l(s)
set dx = 100.0*(s{0}-s{1})
linreg(noprint) dx
# constant dx{1}
report(col=curr,atrow=2) %beta(1)
report(col=curr,atrow=3,special=parens) %stderrs(1)
report(col=curr,atrow=4) %sigmasq
report(col=curr,atrow=5) %logl
set ustd = %resids/sqrt(%seesq)
corr(print,qstats,number=15,method=yule) ustd
report(col=curr,atrow=6) %qstat
set usqr = ustd^2
corr(print,qstats,number=15,method=yule) usqr
report(col=curr,atrow=7) %qstat
stats(noprint) %resids
report(col=curr,atrow=8) %skewness
report(col=curr,atrow=9) %kurtosis
end dofor s
report(action=format,picture="*.###",align=decimal)
report(action=show)
*
* Table 3
*
* The DOW series is 2 for Saturday,...,5 for Wednesday. Create dummies for
* each day of the week.
*
dec vect[series] dd(5)
do i=1,5
set dd(i) = dow==(i)
end do i
*
*
* SKIP is a dummy variable which will be 1 if and only if there is a
* skipped weekday.
*
set(first=1.0) skip = .not.(dow{1}+1==dow.or.(dow{1}==5.and.dow==1))
*
nonlin(parmset=meanparms) b0 b1 b2 b3 b4 b5
nonlin(parmset=garchshifts) w1 w2 w3 w4 w5 w6 w7
nonlin(parmset=garchparms) alpha1 beta1 rnu
declare series uu h u
frml varf = alpha1*uu{1}+beta1*h{1}+$
w1*dd(1)+w2*dd(2)+w3*dd(3)+w4*dd(4)+w5*dd(5)+w6*skip+w7*skip{1}-$
(alpha1+beta1)*(w1*dd(1){1}+w2*dd(2){1}+w3*dd(3){1}+w4*dd(4){1}+w5*dd(5){1}+w6*skip{1}+w7*skip{2})
frml meanf = b0*dx{1}+b1*dd(1)+b2*dd(2)+b3*dd(3)+b4*dd(4)+b5*dd(5)
frml logl = (u=dx-meanf),(uu(t)=u^2),(h(t)=varf(t)),%logtdensity(h,u,1./rnu)
*
report(action=define,hlabels=||"","Stock"||)
dofor s = sto
set dx = 100.0*(s{0}-s{1})
*
* Get preliminary guess values for the mean parameters off an OLS
* regression on the mean dummies.
*
linreg(noprint) dx
# dd dx{1}
compute hinit=%seesq
*
set uu = %resids^2
set h = hinit
set u = %resids
*
* Poke those into the meanparms.
*
compute %parmspoke(meanparms,%beta)
*
* Get preliminary guess values for the dummy terms in the variance
* equation by an OLS regression of the squared residuals on the
* dummies.
*
linreg uu
# dd skip skip{1}
*
* Poke those into the shift parameters
*
compute %parmspoke(garchshifts,%beta)
*
* Set initial guess values for the reciprocal degrees of freedom, and
* the GARCH parameters.
*
compute rnu=.10
compute alpha1=.1,beta1=.8
*
set test 4 * = logl(t)
sstats 4 * .not.%valid(test)>>nmiss
if nmiss>0.0
compute w1=w2=w3=w4=w5=hinit,w6=w7=0.0
maximize(parmset=meanparms+garchshifts+garchparms,pmethod=simplex,piter=10,method=bhhh) logl 4 *
report(regressors,extra=stderrs)
report(col=current,atrow=2*%nreg+2) %funcval
stats u 4 *
set ustd 4 * = u/sqrt(h)
corr(print,qstats,number=15,method=yule) ustd 4 *
report(col=current,atrow=2*%nreg+3) %qstat
set usqr 4 * = ustd^2
corr(print,qstats,number=15,method=yule) usqr 4 *
report(col=current,atrow=2*%nreg+4) %qstat
stats(noprint) ustd
report(col=current,atrow=2*%nreg+5) %skewness
report(col=current,atrow=2*%nreg+6) %kurtosis
report(col=current,atrow=2*%nreg+7) 3.0*(1.0/rnu-2.0)/(1.0/rnu-4.0)
end dofor
report(action=show)
*