R 1 R R R tseries fseries 1 tseries fseries R Japan(Tokyo) R library(tseries) library(fseries) 2 t r t t 1 Ω t 1 E[r t Ω t 1 ] ɛ t r t = E[r t Ω t 1 ] + ɛ t ɛ t 2 iid (independently, identically distributed) ɛ t = σ t z t, σ t > 0, z t iid N (0, 1) R Ver241 a-matsumo@osipposaka-uacjp 1 fseries tseries fseries GARCH garchfit 2 [2000] z t z t z t 1
σ t σ t σt 2 225 nikkei HP nikkei4csv H R nikkei4<-readcsv("h:=y=ynikkei4csv",header=t) (1) nikkei header=t nikkei4csv 4 4 nikkei nikkei4<-dataframe(nikkei4) (2) nikkei<-nikkei4[,4] (3) dnikkei dnikkei <-diff(log(nikkei)) (4) dnikkei 21 ARCH(q) ARCH(:Auto-regressive Conditional Heteroskedasticity) σt 2 ɛ 2 t 1, ɛ 2 t 2, ARCH(q) : σ 2 t = ω + q α j ɛ 2 t j, ω > 0, j α j 0 j=1 tseries ARCH garch ARCH(2) arch2 arch2<-garch(dnikkei, order=c(0,2)) (5) summary(arch2) 3 3 ***** ESTIMATION WITH ANALYTICAL GRADIENT ***** Warning: 2
Call: garch(x = dnikkei, order = c(0, 2)) Model: GARCH(0,2) Residuals: Min 1Q Median 3Q Max -755848-054383 001040 056867 609377 Coefficient(s): Estimate Std Error t value Pr(> t ) a0 1366e-04 2783e-06 49077 < 2e-16 *** a1 1157e-01 1452e-02 7971 155e-15 *** a2 8335e-02 1487e-02 5606 207e-08 *** --- Signif codes: 0 *** 0001 ** 001 * 005 01 1 Diagnostic Tests: Jarque Bera Test data: Residuals X-squared = 1611481, df = 2, p-value < 22e-16 Box-Ljung test data: SquaredResiduals X-squared = 11212, df = 1, p-value = 02897 ARCH(2) σ 2 t = 1366 10 4 + 01157ɛ 2 t 1 + 008335ɛ 2 t 2, Std Error: (2783 10 6 ) (001452) (001487) 22 GARCH(p, q) GARCH(:Generalized Auto-regressive Conditional Heteroskedasticity) σt 2 ɛ 2 t 1, ɛ 2 t 2, σt 1, 2 σt 2, 2 GARCH(p, q) : σ 2 t = ω + p β i σt 1 2 + i=1 q α j ɛ 2 t j, ω > 0, i β i 0, j α j 0 j=1 GARCH garch GARCH(1,1) garch11 garch11<-garch(dnikkei, order=c(1,1)) (6) summary(garch11) Call: garch(x = dnikkei, order = c(1, 1)) Model: GARCH(1,1) Residuals: Min 1Q Median 3Q Max -898948-058079 001014 059228 588422 Coefficient(s): Estimate Std Error t value Pr(> t ) a0 3886e-06 4801e-07 8094 666e-16 *** 3
a1 6483e-02 4907e-03 13212 2e-16 *** b1 9134e-01 6331e-03 144286 < 2e-16 *** --- Signif codes: 0 *** 0001 ** 001 * 005 01 1 Diagnostic Tests: Jarque Bera Test data: Residuals X-squared = 2179503, df = 2, p-value < 22e-16 Box-Ljung test data: SquaredResiduals X-squared = 10566, df = 1, p-value = 0304 GARCH(1,1) σ 2 t = 3886 10 6 + 006483ɛ 2 t 1 + 09134σ 2 t 1, Std Error: (4801 10 7 ) (00049) (0006331) 23 ARCH,GARCH GARCH(1,1) summary(garch11) GARCH(1,1) Diagnostic Tests: Jarque Bera Test data: Residuals X-squared = 2179503, df = 2, p-value < 22e-16 Box-Ljung test data: SquaredResiduals X-squared = 10566, df = 1, p-value = 0304 tseries GARCH Jarque Bera Test: p Ljung-Box Test: 1 4 p 5 n<-length(dnikkei) nparam<-length(coef(garch11))-1 L<-30 garchbox<-rep(0,l) garchboxsq<-rep(0,l) for(i in 1:L){ box<-boxtest(garch11$resid,lag=i,type="ljung-box") boxsq<-boxtest(garch11$resid^2,lag=i,type="ljung-box") garchbox[i]<-box$pvalue 4 GARCH ɛ t 5 HP acf pacf plot=false 4
garchboxsq[i]<-boxsq$pvalue } par(mfrow=c(3,4),mar=c(4,4,4,05),las=1) plot(garch11$resid,type="l",main="residual") plot(garchbox,type="b",ylim=c(0,1),main="ljung-box p-value") abline(h=005,lty=2,col="red") abline(v=25) acf(garch11$resid[nparam:n],main="acf") pacf(garch11$resid[nparam:n],main="pacf") cpgram(garch11$resid,main="cumulative Periodgram") qqnorm(garch11$resid,main="normal QQ plot") qqline(garch11$resid) plot(garch11$resid,type="n",bty="n",xlab="",ylab="",xaxt="n",yaxt="n") plot(garch11$resid^2,type="l",main="residual Square") plot(garchboxsq,type="b",ylim=c(0,1),main="ljung-box p-value") abline(h=005,lty=2,col="red") abline(v=25) acf(garch11$resid[nparam:n]^2,main="acf") pacf(garch11$resid[nparam:n]^2,main="pacf") 1 1 1 2 Ljung-Box p (30 ) p p 1 3 ACF 35 ) 5% 0 1 4 PACF( 35 2 1 2 2 QQ 2 4 3 1 Ljung-Box p 30 p 3 2 ACF 35 ) 3 3 PACF 35 5
3 31 EGARCH(p, q) GJR(p, q) ARCH GARCH ARCH GARCH EGARCH GJR GJR(p, q) : GJR(p, q) ɛ t 1 1 0 6
D t 1 σ 2 t = ω + p β i σt i 2 + i=1 q (α j ɛ 2 t j + γ j D t j ɛ2 t j), ω > 0, i, j β i, α j, γ j 0, j=1 EGARCH(p, q) : σt 2 ɛ 2 t j EGARCH ɛ t j σ t j z t j := ɛ t j /σ t j ln(σ 2 t ) = ω + p β i ln(σt i) 2 + i=1 q { α j θzt j + γ( z t j E z t j ) } j=1 R fseries garchoxinterface fseries garchoxinterface Step1: Ox Ox ( PC ) H:=YOxMetrics4=YOx OxMetrics Ox H:=YOx 6 : http://wwweu-tokyoacjp/ omori/ox/indexhtm Step2: Ox Ox G@RCHVer42 H:=YOx=Ypackages http://wwwcoreuclacbe/ laurent/g@rch/site/indexhtml Step3 : GarchOxModelingox Modified GarchOxModelling file H:=YOx=Ylib http://facultychicagogsbedu/rueytsay/teaching/bs41202/sp2007/ Step4 : Step3 A corrected version of the garchoxfit function Modified GarchOxModelling file txt garchoxfit Rtxt 6 H:=YOx 7
R 7 16 command = "C:=Y=YOx=Y=Ybin =Y=Yoxlexe C:=Y=YOx=Y=Ylib=Y=YGarchOxModellingox" C:=Y H:=Y Ox H R source("garchoxfit Rtxt") : garchoxinterface ARMA ARMA(1,0) AR(1) GJR(1,1) m1 m1<-garchoxfit(formulamean= arma(1,0), formulavar= gjr(1,1),series=dif) (7) 8 ******************** ** SPECIFICATIONS ** ******************** Dependent variable : X Mean Equation : ARMA (1, 0) model No regressor in the mean Variance Equation : GJR(1, 1) model No regressor in the variance The distribution is a Gauss distribution Strong convergence using numerical derivatives Log-likelihood = 116989 Maximum Likelihood Estimation (StdErrors based on Second derivatives) Coefficient StdError t-value t-prob Cst(M) 0000101 000021415 04725 06366 AR(1) 0150090 0017042 8807 00000 Cst(V) 0040843 00080254 5089 00000 ARCH(Alpha1) 0068120 00074708 9118 00000 GARCH(Beta1) 0908588 00099891 9096 00000 GHR(Gamma1) 0090895 00336651 2700 00071 No Observations : 3920 No Parameters : 6 Mean (Y) : -000010 Variance (Y) : 000017 Skewness (Y) : -016499 Kurtosis (Y) : 599703 Log Likelihood : 11698930 Alpha[1]+Beta[1]: 097651 Warning : To avoid numerical problems, the estimated parameter Cst(V), and its stderror have been multiplied by 10^4 The sample mean of squared residuals was used to start recursion The positivity constraint for the GARCH (1,1) is observed This constraint is alpha[l]/[1 - beta(l)] >= 0 7 R garchoxfit Rtxt R R C Program Files garchoxfit 8 GARCH CPU 15GHz 512MB PC 8
The unconditional variance is 0000173863 The conditions are alpha[0] > 0, alpha[l] + beta[l] < 1 and alpha[i] + beta[i] >= 0 => See Doornik & Ooms (2001) for more details The condition for existence of the fourth moment of the GARCH is observed The constraint equals 0962849 and should be < 1 => See Ling & McAleer (2001) for details Estimated Parameters Vector : 0000101; 0150090; 0000004; 0068120; 0908588 *************** ** FORECASTS ** *************** Number of Forecasts: 15 Horizon Mean Variance 1 0002854 00001076 2 00005144 0000105 3 00001632 00001026 4 00001105 00001002 5 00001026 978e-005 6 00001014 955e-005 7 00001012 9326e-005 8 00001012 9107e-005 9 00001012 8893e-005 10 00001012 8684e-005 11 00001012 848e-005 12 00001012 8281e-005 13 00001012 8087e-005 14 00001012 7897e-005 15 00001012 7711e-005 Forecasts errors measures cannot be computed because there are not enough out-of-sample observations) Elapsed Time : 4031 seconds (or 00671833 minutes) *********** ** TESTS ** *********** Statistic t-test P-Value Skewness -038815 99251 32391e-023 Excess Kurtosis 35788 45767 000000 Jarque-Bera 21903 NaN 000000 Information Criterium (to be minimized) Akaike -5966291 Shibata -5966294 Schwarz -5958288 Hannan-Quinn -5963451 Q-Statistics on Standardized Residuals --> P-values adjusted by 1 degree(s) of freedom Q( 10) = 869102 [04662708] Q( 15) = 166551 [02750242] Q( 20) = 259216 [01323881] H0 : No serial correlation ==> Accept H0 when prob is High [Q < Chisq(lag)] -------------- Q-Statistics on Squared Standardized Residuals --> P-values adjusted by 2 degree(s) of freedom Q( 10) = 663530 [05764419] Q( 15) = 815385 [08334345] Q( 20) = 110363 [08928108] H0 : No serial correlation ==> Accept H0 when prob is High [Q < Chisq(lag)] -------------- ARCH 1-2 test: F(2,3913)= 086756 [04201] ARCH 1-5 test: F(5,3907)= 074896 [05868] ARCH 1-10 test: F(10,3897)= 057124 [08387] -------------- Diagnostic test based on the news impact curve (EGARCH vs GARCH) Test P-value Sign Bias t-test 073704 046110 Negative Size Bias t-test 014646 088356 Positive Size Bias t-test 125593 020914 Joint Test for the Three Effects 164696 064879 9
Joint Statistic of the Nyblom test of stability: 27826 Individual Nyblom Statistics: Cst(M) 012959 AR(1) 046767 Cst(V) 2091820 ARCH(Alpha1) 2598398 GARCH(Beta1) 2227730 GJR(Gamma1) 2011231 Rem: Asymptotic 1% critical value for individual statistics = 075 Asymptotic 5% critical value for individual statistics = 047 Adjusted Pearson Chi-square Goodness-of-fit test # Cells(g) Statistic P-Value(g-1) P-Value(g-k-1) 40 1285306 0000000 0000000 50 1459184 0000000 0000000 60 1618061 0000000 0000000 Rem: k = 5 = # estimated parameters r t = 0000101 + 015009r t 1 + ɛ t, Std Error: (0000214) (0017042), σ 2 t = 0040843 + 0908588σ 2 t 1 + (006812 + 0090895D t 1 )ɛ2 t 1, Std Error: (000802) (000998) (00076) (00336) AR(1) EGARCH(1,1) m2 m2<-garchoxfit(formulamean= arma(1,0), formulavar= egarch(1,1),series=dif) 32 AIC AIC garch AIC AIC AIC := 2 log L + 2n log L n GARCH(p, q) n = p + q + 1 9 for(p in 1:3){ for(q in 1:3){ tmp<-garch(dif,order=c(p,q)) likelihood<-tmp$nlikeli 9 HP 10
nparam<-length(coef(tmp)) aic<- -2*likelihood+2*nparam cat("order1",p,"order2",q,"aic",aic, "\n")}} 9 AIC 4 Doornik, JA (2002), Object-Oriented Matrix Programming Using Ox, 3rd ed London: Timberlake Consultants Press and Oxford: wwwdoornikcom (2004),, tseries fseries http://cranr-projectorg/src/contrib/descriptions/tserieshtml http://cranr-projectorg/src/contrib/descriptions/fserieshtml Ox garchoxfit http://facultychicagogsbedu/rueytsay/teaching/bs41202/sp2007/ 11