GARCH Model with Day of Week Dummies
Re: The diagnostics tests for multivariate GARCH
Switch to METHOD=BFGS. (That's generally superior to BHHH---the original paper uses BHHH, but it may be a better-behaved data set).
You have only 3254 data points, not 3255. (There are 3255 rows, but one row is the labels).
You have only 3254 data points, not 3255. (There are 3255 rows, but one row is the labels).
Re: The diagnostics tests for multivariate GARCH
I did those steps, but it didn’t converge. Here is result:
Code: Select all
MAXIMIZE - Estimation by BFGS
NO CONVERGENCE IN 47 ITERATIONS. FINAL NORMED GRADIENT 0.20463
ESTIMATION POSSIBLY HAS STALLED OR MACHINE ROUNDOFF IS MAKING FURTHER PROGRESS DIFFICULT
TRY DIFFERENT SETTING FOR EXACTLINE, DERIVES OR ALPHA ON NLPAR
RESTARTING ESTIMATION FROM LAST ESTIMATES OR DIFFERENT INITIAL GUESSES/PMETHOD OPTION MIGHT ALSO WORK
Usable Observations 3251
Function Value -3400.1645
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. B0 0.392044744 0.015311012 25.60541 0.00000000
2. B1 0.033797151 0.020644514 1.63710 0.10160940
3. B2 -0.078834171 0.017698086 -4.45439 0.00000841
4. B3 0.064691553 0.016176078 3.99921 0.00006355
5. B4 0.061559302 0.018073991 3.40596 0.00065932
6. B5 0.067709720 0.013656368 4.95811 0.00000071
7. W1 3.855376045 0.020445646 188.56709 0.00000000
8. W2 3.770226524 0.011883274 317.27171 0.00000000
9. W3 3.754657948 0.010795293 347.80511 0.00000000
10. W4 3.764295221 0.012284852 306.41764 0.00000000
11. W5 3.754595802 0.011469702 327.34903 0.00000000
12. W6 -0.003595986 0.011690666 -0.30759 0.75839082
13. W7 0.003676594 0.011898396 0.30900 0.75732219
14. ALPHA1 0.163425026 0.014391228 11.35588 0.00000000
15. BETA1 0.834769915 0.014709968 56.74859 0.00000000
16. RNU 0.180742894 0.011195424 16.14435 0.00000000Re: The diagnostics tests for multivariate GARCH
I've even made other changes randomly to the program, but it still doesn't converge.
Re: The diagnostics tests for multivariate GARCH
With your data, the GARCH model is borderline I-GARCH (the GARCH coefficients sum to .998). When those sum to 1, the level of the W's becomes unidentified (you can add a constant to each of the W1 to W5 and get the same fit) so that's interfering with convergence.
I've attached a recoding of the original paper which handles the W's differently (an overall level W0 then W1 to W5 which sum to zero). There will still be a potential issue with W0 not being fully identified, but the day-of-week shifts will be, which is what you really need.
I've attached a recoding of the original paper which handles the W's differently (an overall level W0 then W1 to W5 which sum to zero). There will still be a potential issue with W0 not being fully identified, but the day-of-week shifts will be, which is what you really need.
Re: The diagnostics tests for multivariate GARCH
I really appreciate your kind help and guide.
I edited it for one variable and run it. It still does not converge for my data:
I edited it for one variable and run it. It still does not converge for my data:
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 3254 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 1 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=-(b1+b2+b3+b4)
nonlin(parmset=garchshifts) w0 w1 w2 w3 w4 w5=-(w1+w2+w3+w4) w6 w7
nonlin(parmset=garchparms) alpha1 beta1 rnu
declare series uu h u
frml varf = w0+w1*dd(1)+w2*dd(2)+w3*dd(3)+w4*dd(4)+w5*dd(5)+w6*skip+w7*skip{1}
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)
* Create two parallel reports, one for the model estimates, one for the summary statistics
*
report(action=define,use=garchestimates)
report(action=define,use=garchsummary,hlabels=||"","Stock"||)
report(use=garchsummary,atrow=1,atcol=1,fillby=columns) "$Log L$" "$Q(15)$" "$Q^2(15)$" "$m_3$" "$m_4$" $
"$3(\hat \nu - 2)(\hat \nu - 4)^{ - 1}$"
dofor s = sto
set dx = 100.0*(s{0}-s{1})
*
* * Get preliminary guess values for the mean parameters estimating just the mean model
*
nlls(parmset=meanparms,frml=meanf) dx
* Use the variance of the estimation to initialize the uu and h series
compute hinit=%seesq
*
set uu = %resids^2
set h = hinit
set u = %resids
*
* * Estimation of the full GARCH model will use 1 less data point than
* the mean model.
compute gstart=%regstart()+1,gend=%regend()
*
* Use base guess values for the variance mean function to avoid
* problems with negative variances.
*
compute w0=hinit,w1=w2=w3=w4=w5=w6=w7=0.0
*
* Set initial guess values for the reciprocal degrees of freedom, and
* the GARCH parameters.
compute rnu=.10
compute alpha1=.1,beta1=.8
*
maximize(parmset=meanparms+garchshifts+garchparms,pmethod=simplex,piter=10,method=bhhh) logl gstart gend
report(use=garchestimates,regressors,extra=stderrs)
report(use=garchsummary,col=new,atrow=1) %funcval
stats u gstart gend
set ustd gstart gend = u/sqrt(h)
corr(print,qstats,number=15,method=yule) ustd gstart gend
report(use=garchsummary,col=current,atrow=2) %qstat
set usqr gstart gend = ustd^2
corr(print,qstats,number=15,method=yule) usqr gstart gend
report(use=garchsummary,col=current,atrow=3) %qstat
stats(noprint) ustd
report(use=garchsummary,col=current,atrow=4) %skewness
report(use=garchsummary,col=current,atrow=5) %kurtosis
report(use=garchsummary,col=current,atrow=6) 3.0*(1.0/rnu-2.0)/(1.0/rnu-4.0)
end dofor
report(action=define,use=Table3,title="Table 3 Daily GARCH Models",$
hlabels=||"","Stock"||)
*
- Attachments
-
- Tom1.xlsx
- (57.88 KiB) Downloaded 593 times
Re: The diagnostics tests for multivariate GARCH
In adding the AR(1), you lost the overall intercept (the original B0) in the mean model.
Switch to BFGS.
Switch to BFGS.
Re: The diagnostics tests for multivariate GARCH
I did it. It converge now but there are some weird results for Ws and one error too:
Code: Select all
he Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B0 Has Not Been Initialized. Trying 0
The Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B1 Has Not Been Initialized. Trying 0
The Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B2 Has Not Been Initialized. Trying 0
The Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B3 Has Not Been Initialized. Trying 0
The Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B4 Has Not Been Initialized. Trying 0
Nonlinear Least Squares - Estimation by Gauss-Newton
Convergence in 2 Iterations. Final criterion was 0.0000000 <= 0.0000100
Dependent Variable DX
Usable Observations 3252
Degrees of Freedom 3247
Skipped/Missing (from 3253) 1
Centered R^2 0.1457618
R-Bar^2 0.1447095
Uncentered R^2 0.1647480
Mean of Dependent Variable 0.1580648655
Std Error of Dependent Variable 1.0485568659
Standard Error of Estimate 0.9697255177
Sum of Squared Residuals 3053.3735313
Log Likelihood -4511.9125
Durbin-Watson Statistic 1.9721
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. B0 0.403171477 0.016074203 25.08189 0.00000000
2. B1 0.041176919 0.034167888 1.20514 0.22823900
3. B2 -0.127392876 0.033930989 -3.75447 0.00017675
4. B3 0.054322923 0.034001676 1.59765 0.11021724
5. B4 -0.038554483 0.034077121 -1.13139 0.25797492
MAXIMIZE - Estimation by BFGS
Convergence in 88 Iterations. Final criterion was 0.0000000 <= 0.0000100
Usable Observations 3252
Function Value -4089.9545
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. B0 0.341042560 0.016168294 21.09329 0.00000000
2. B1 -0.026224815 0.022630254 -1.15884 0.24652192
3. B2 -0.124552279 0.020565957 -6.05624 0.00000000
4. B3 0.049541654 0.020310555 2.43921 0.01471952
5. B4 0.051752399 0.019595823 2.64099 0.00826638
6. W0 9.907488251 9.796774087 1.01130 0.31187235
7. W1 3.515555966 3.631915604 0.96796 0.33306339
8. W2 0.709487698 1.105051581 0.64204 0.52084699
9. W3 -0.626615566 0.865447793 -0.72404 0.46904349
10. W4 -1.280058279 1.374920884 -0.93101 0.35185095
11. W6 3.170326275 3.917629793 0.80925 0.41837366
12. W7 0.724226904 1.783292734 0.40612 0.68465606
13. ALPHA1 0.135829128 0.000000000 0.00000 0.00000000
14. BETA1 1.575463881 0.000000000 0.00000 0.00000000
15. RNU 0.487274709 0.012874001 37.84952 0.00000000
Statistics on Series U
Observations 3252
Sample Mean 0.104336 Variance 0.935307
Standard Error 0.967113 SE of Sample Mean 0.016959
t-Statistic (Mean=0) 6.152238 Signif Level (Mean=0) 0.000000
Skewness 0.164057 Signif Level (Sk=0) 0.000135
Kurtosis (excess) 4.234114 Signif Level (Ku=0) 0.000000
Jarque-Bera 2443.793706 Signif Level (JB=0) 0.000000
Correlations of Series USTD
Autocorrelations
1 2 3 4 5 6 7 8 9 10
0.06224 -0.07544 0.12648 0.05636 0.05543 0.05358 0.03993 0.01975 0.03293 0.06766
11 12 13 14 15
-0.00124 0.07337 0.10935 0.04824 -0.02630
Ljung-Box Q-Statistics
Lags Statistic Signif Lvl
15 204.438 0.000000
Correlations of Series USQR
Autocorrelations
1 2 3 4 5 6 7 8 9 10
0.263570 0.272336 0.262070 0.293715 0.275650 0.263236 0.248842 0.225105 0.242704 0.199915
11 12 13 14 15
0.231811 0.173454 0.269518 0.171193 0.202813
Ljung-Box Q-Statistics
Lags Statistic Signif Lvl
15 2877.059 0.000000
Re: GARCH Model with Day of Week Dummies
Add the option reject=(alpha1+beta1)>1.02 to your MAXIMIZE instruction.
Re: GARCH Model with Day of Week Dummies
Thank you very much for your valuable guidance. There is only one issue here. When I open the WINRATS software and run the program, I receive an unusual estimation for the Ws. However, if I don't close the software and run the program again, I get a different result that is entirely inconsistent with the initial results. Nevertheless, in both cases, there seems to be a high correlation between the squared errors. Now, I don't know which result to consider as valid. I am sharing the results of both scenarios here:
First results:
Second results:
Correlations:
First results:
Code: Select all
MAXIMIZE - Estimation by BFGS
Convergence in 91 Iterations. Final criterion was 0.0000000 <= 0.0000100
Usable Observations 3252
Function Value -4089.9545
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. B0 0.341036632 0.015302880 22.28578 0.00000000
2. B1 -0.026227732 0.023087069 -1.13604 0.25594167
3. B2 -0.124548860 0.020772646 -5.99581 0.00000000
4. B3 0.049539334 0.018720660 2.64624 0.00813924
5. B4 0.051756212 0.020772103 2.49162 0.01271616
6. W0 9.953862589 6.603007798 1.50747 0.13168920
7. W1 3.532046029 2.529144511 1.39654 0.16255259
8. W2 0.712729598 0.798797611 0.89225 0.37225732
9. W3 -0.629041271 0.668342208 -0.94120 0.34660423
10. W4 -1.286429101 1.226923771 -1.04850 0.29440848
11. W6 3.184191841 2.883113082 1.10443 0.26940737
12. W7 0.727386091 1.082084821 0.67221 0.50145128
13. ALPHA1 0.129100986 0.000000000 0.00000 0.00000000
14. BETA1 0.783594385 0.000000000 0.00000 0.00000000
15. RNU 0.487335104 0.008525695 57.16075 0.00000000
Code: Select all
MAXIMIZE - Estimation by BFGS
Convergence in 21 Iterations. Final criterion was 0.0000088 <= 0.0000100
Usable Observations 3252
Function Value 3924.1427
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. B0 0.362020821 0.012651769 28.61425 0.00000000
2. B1 -0.001639036 0.002074886 -0.78994 0.42956273
3. B2 -0.011791114 0.001606696 -7.33874 0.00000000
4. B3 0.004651487 0.001716587 2.70973 0.00673379
5. B4 0.003955735 0.001839582 2.15035 0.03152793
6. W0 0.010338456 0.001673940 6.17612 0.00000000
7. W1 0.003310409 0.000973790 3.39951 0.00067506
8. W2 0.000658084 0.000418136 1.57385 0.11552222
9. W3 -0.000692358 0.000473082 -1.46351 0.14332906
10. W4 -0.000972662 0.000640953 -1.51752 0.12913434
11. W6 0.003721021 0.002014078 1.84751 0.06467377
12. W7 0.000708294 0.001250341 0.56648 0.57106740
13. ALPHA1 0.151416931 0.000000000 0.00000 0.00000000
14. BETA1 0.834916582 0.000000000 0.00000 0.00000000
15. RNU 0.390878811 0.022053321 17.72426 0.00000000Code: Select all
orrelations of Series USQR
Autocorrelations
1 2 3 4 5 6 7 8 9 10
0.248439 0.213612 0.204320 0.214314 0.198324 0.192530 0.188234 0.159589 0.169366 0.132010
11 12 13 14 15
0.164228 0.113017 0.184067 0.104515 0.132029
Ljung-Box Q-Statistics
Lags Statistic Signif Lvl
15 1566.369 0.000000Re: GARCH Model with Day of Week Dummies
Do File---Clear Memory (or the wiping rag toolbar icon) before doing a re-run. The LABELS instruction (which is a holdover from the original coding of this) interferes with DATA instruction if the memory isn't clear.
Re: GARCH Model with Day of Week Dummies
I still get weird results for Ws.
Code: Select all
The Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B0 Has Not Been Initialized. Trying 0
The Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B1 Has Not Been Initialized. Trying 0
The Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B2 Has Not Been Initialized. Trying 0
The Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B3 Has Not Been Initialized. Trying 0
The Error Occurred At Location 141, Line 7 of loop/block
## NL6. NONLIN Parameter B4 Has Not Been Initialized. Trying 0
Nonlinear Least Squares - Estimation by Gauss-Newton
Convergence in 2 Iterations. Final criterion was 0.0000000 <= 0.0000100
Dependent Variable DX
Usable Observations 3252
Degrees of Freedom 3247
Skipped/Missing (from 3253) 1
Centered R^2 0.1457618
R-Bar^2 0.1447095
Uncentered R^2 0.1647480
Mean of Dependent Variable 0.1580648655
Std Error of Dependent Variable 1.0485568659
Standard Error of Estimate 0.9697255177
Sum of Squared Residuals 3053.3735313
Log Likelihood -4511.9125
Durbin-Watson Statistic 1.9721
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. B0 0.403171477 0.016074203 25.08189 0.00000000
2. B1 0.041176919 0.034167888 1.20514 0.22823900
3. B2 -0.127392876 0.033930989 -3.75447 0.00017675
4. B3 0.054322923 0.034001676 1.59765 0.11021724
5. B4 -0.038554483 0.034077121 -1.13139 0.25797492
MAXIMIZE - Estimation by BFGS
Convergence in 91 Iterations. Final criterion was 0.0000000 <= 0.0000100
Usable Observations 3252
Function Value -4089.9545
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. B0 0.341036632 0.015302880 22.28578 0.00000000
2. B1 -0.026227732 0.023087069 -1.13604 0.25594167
3. B2 -0.124548860 0.020772646 -5.99581 0.00000000
4. B3 0.049539334 0.018720660 2.64624 0.00813924
5. B4 0.051756212 0.020772103 2.49162 0.01271616
6. W0 9.953862589 6.603007798 1.50747 0.13168920
7. W1 3.532046029 2.529144511 1.39654 0.16255259
8. W2 0.712729598 0.798797611 0.89225 0.37225732
9. W3 -0.629041271 0.668342208 -0.94120 0.34660423
10. W4 -1.286429101 1.226923771 -1.04850 0.29440848
11. W6 3.184191841 2.883113082 1.10443 0.26940737
12. W7 0.727386091 1.082084821 0.67221 0.50145128
13. ALPHA1 0.129100986 0.000000000 0.00000 0.00000000
14. BETA1 0.783594385 0.000000000 0.00000 0.00000000
15. RNU 0.487335104 0.008525695 57.16075 0.00000000
Statistics on Series U
Observations 3252
Sample Mean 0.104337 Variance 0.935308
Standard Error 0.967113 SE of Sample Mean 0.016959
t-Statistic (Mean=0) 6.152290 Signif Level (Mean=0) 0.000000
Skewness 0.164056 Signif Level (Sk=0) 0.000135
Kurtosis (excess) 4.234107 Signif Level (Ku=0) 0.000000
Jarque-Bera 2443.785838 Signif Level (JB=0) 0.000000
Correlations of Series USTD
Autocorrelations
1 2 3 4 5 6 7 8 9 10
0.06225 -0.07543 0.12648 0.05637 0.05544 0.05358 0.03993 0.01975 0.03293 0.06766
11 12 13 14 15
-0.00125 0.07337 0.10935 0.04824 -0.02630
Ljung-Box Q-Statistics
Lags Statistic Signif Lvl
15 204.440 0.000000
Correlations of Series USQR
Autocorrelations
1 2 3 4 5 6 7 8 9 10
0.263566 0.272332 0.262065 0.293708 0.275646 0.263230 0.248839 0.225104 0.242696 0.199913
11 12 13 14 15
0.231807 0.173450 0.269514 0.171187 0.202811
Ljung-Box Q-Statistics
Lags Statistic Signif Lvl
15 2876.955 0.000000
Re: GARCH Model with Day of Week Dummies
You would need to re-post your current program, but I don't think you adapted the revised program correctly. The new code has an HMEANF which has the shifted means for the variance, and then a VARF which uses that to get the variance. Your VARF above just does the mean.
Re: GARCH Model with Day of Week Dummies
Appreciate your help:
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 Wednsday. 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)
*
Re: GARCH Model with Day of Week Dummies
That looks like an old copy of your program.
Re: GARCH Model with Day of Week Dummies
So sorry, I edited it, still have the error:
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 3254 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 1 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=-(b1+b2+b3+b4)
nonlin(parmset=garchshifts) w0 w1 w2 w3 w4 w5=-(w1+w2+w3+w4) w6 w7
nonlin(parmset=garchparms) alpha1 beta1 rnu
declare series uu h u
frml varf = w0+w1*dd(1)+w2*dd(2)+w3*dd(3)+w4*dd(4)+w5*dd(5)+w6*skip+w7*skip{1}
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)
* Create two parallel reports, one for the model estimates, one for the summary statistics
*
report(action=define,use=garchestimates)
report(action=define,use=garchsummary,hlabels=||"","Stock"||)
report(use=garchsummary,atrow=1,atcol=1,fillby=columns) "$Log L$" "$Q(15)$" "$Q^2(15)$" "$m_3$" "$m_4$" $
"$3(\hat \nu - 2)(\hat \nu - 4)^{ - 1}$"
dofor s = sto
set dx = 100.0*(s{0}-s{1})
*
* * Get preliminary guess values for the mean parameters estimating just the mean model
*
nlls(parmset=meanparms,frml=meanf) dx
* Use the variance of the estimation to initialize the uu and h series
compute hinit=%seesq
*
set uu = %resids^2
set h = hinit
set u = %resids
*
* * Estimation of the full GARCH model will use 1 less data point than
* the mean model.
compute gstart=%regstart()+1,gend=%regend()
*
* Use base guess values for the variance mean function to avoid
* problems with negative variances.
*
compute w0=hinit,w1=w2=w3=w4=w5=w6=w7=0.0
*
* Set initial guess values for the reciprocal degrees of freedom, and
* the GARCH parameters.
compute rnu=.10
compute alpha1=.1,beta1=.8
*
maximize(parmset=meanparms+garchshifts+garchparms,pmethod=simplex,piter=10,method=bfgs,reject=(alpha1+beta1)>1.02) logl gstart gend
report(use=garchestimates,regressors,extra=stderrs)
report(use=garchsummary,col=new,atrow=1) %funcval
stats u gstart gend
set ustd gstart gend = u/sqrt(h)
corr(print,qstats,number=15,method=yule) ustd gstart gend
report(use=garchsummary,col=current,atrow=2) %qstat
set usqr gstart gend = ustd^2
corr(print,qstats,number=15,method=yule) usqr gstart gend
report(use=garchsummary,col=current,atrow=3) %qstat
stats(noprint) ustd
report(use=garchsummary,col=current,atrow=4) %skewness
report(use=garchsummary,col=current,atrow=5) %kurtosis
report(use=garchsummary,col=current,atrow=6) 3.0*(1.0/rnu-2.0)/(1.0/rnu-4.0)
end dofor
report(action=define,use=Table3,title="Table 3 Daily GARCH Models",$
hlabels=||"","Stock"||)
*