library(ggplot2)
library(tidyverse)
library(readxl)
library(rugarch)
library(VineCopula)
library(goftest)
library(readxl)
library(readxl)
data <- read_excel("~/2121001544_Ngoen/E/DATA.xlsx", 
    col_types = c("date", "numeric", "numeric", 
        "numeric", "numeric"))
data <- na.omit(data)

1 MÔ HÌNH ARMA

autoarfima(data$TSVN,ar.max = 2, ma.max = 2,criterion = "AIC", method = "full")
## $fit
## 
## *----------------------------------*
## *          ARFIMA Model Fit        *
## *----------------------------------*
## Mean Model   : ARFIMA(2,0,2)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##        Estimate  Std. Error  t value Pr(>|t|)
## ar1    0.000000          NA       NA       NA
## ar2    0.389644    0.035621   10.939        0
## ma1   -0.264015    0.023403  -11.281        0
## ma2   -0.640934    0.027486  -23.318        0
## sigma  0.059514    0.001142   52.096        0
## 
## Robust Standard Errors:
##        Estimate  Std. Error  t value Pr(>|t|)
## ar1    0.000000          NA       NA       NA
## ar2    0.389644    0.054377   7.1656        0
## ma1   -0.264015    0.031669  -8.3367        0
## ma2   -0.640934    0.034141 -18.7731        0
## sigma  0.059514    0.002328  25.5645        0
## 
## LogLikelihood : 1903.342 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -2.7993
## Bayes        -2.7840
## Shibata      -2.7993
## Hannan-Quinn -2.7936
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic  p-value
## Lag[1]                    0.009706 0.921520
## Lag[2*(p+q)+(p+q)-1][11] 12.983259 0.000000
## Lag[4*(p+q)+(p+q)-1][19] 18.865011 0.001139
## 
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      14.39 1.486e-04
## Lag[2*(p+q)+(p+q)-1][2]     26.39 9.350e-08
## Lag[4*(p+q)+(p+q)-1][5]     35.43 9.205e-10
## 
## 
## ARCH LM Tests
## ------------------------------------
##              Statistic DoF   P-Value
## ARCH Lag[2]      34.87   2 2.681e-08
## ARCH Lag[5]      38.69   5 2.743e-07
## ARCH Lag[10]     53.24  10 6.714e-08
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  2.9799
## Individual Statistics:            
## ar2   0.1309
## ma1   0.2417
## ma2   0.2695
## sigma 0.7662
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.07 1.24 1.6
## Individual Statistic:     0.35 0.47 0.75
## 
## 
## Elapsed time : 0.1357851 
## 
## 
## $rank.matrix
##    ar1 ar2 ma1 ma2 im arf       AIC converged
## 1    0   1   1   1  0   0 -2.799324         1
## 2    1   1   1   1  0   0 -2.797877         1
## 3    0   1   1   1  1   0 -2.797864         1
## 4    1   1   0   1  0   0 -2.797544         1
## 5    1   0   1   1  0   0 -2.796635         1
## 6    1   1   1   1  1   0 -2.796417         1
## 7    1   1   1   0  0   0 -2.796178         1
## 8    1   1   0   1  1   0 -2.796085         1
## 9    1   0   1   0  0   0 -2.795563         1
## 10   1   0   1   1  1   0 -2.795163         1
## 11   1   1   1   0  1   0 -2.794730         1
## 12   1   0   1   0  1   0 -2.794091         1
## 13   0   0   1   1  0   0 -2.725380         1
## 14   0   0   1   1  1   0 -2.723907         1
## 15   1   0   0   1  0   0 -2.715285         1
## 16   1   0   0   1  1   0 -2.713812         1
## 17   0   1   1   0  0   0 -2.707612         1
## 18   0   1   1   0  1   0 -2.706139         1
## 19   1   1   0   0  0   0 -2.705019         1
## 20   1   1   0   0  1   0 -2.703546         1
## 21   0   1   0   1  0   0 -2.690361         1
## 22   0   1   0   1  1   0 -2.688887         1
## 23   0   0   0   1  0   0 -2.685072         1
## 24   0   0   1   0  0   0 -2.683755         1
## 25   0   0   0   1  1   0 -2.683599         1
## 26   0   0   1   0  1   0 -2.682281         1
## 27   0   1   0   0  0   0 -2.681442         1
## 28   0   1   0   0  1   0 -2.679968         1
## 29   1   0   0   0  0   0 -2.674534         1
## 30   1   0   0   0  1   0 -2.673061         1
## 31   0   0   0   0  1   0 -2.656880         1
autoarfima(data$TSX, ar.max = 2, ma.max = 2, criterion = "AIC", method = "full")
## $fit
## 
## *----------------------------------*
## *          ARFIMA Model Fit        *
## *----------------------------------*
## Mean Model   : ARFIMA(2,0,2)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##        Estimate  Std. Error     t value Pr(>|t|)
## ar1    1.805416    0.012940     139.526        0
## ar2   -0.879916    0.012948     -67.956        0
## ma1   -1.891028    0.000005 -345238.116        0
## ma2    0.917323    0.000024   37634.324        0
## sigma  0.060364    0.001157      52.155        0
## 
## Robust Standard Errors:
##        Estimate  Std. Error     t value Pr(>|t|)
## ar1    1.805416    0.010399     173.617        0
## ar2   -0.879916    0.008276    -106.327        0
## ma1   -1.891028    0.000002 -858459.194        0
## ma2    0.917323    0.000027   33774.792        0
## sigma  0.060364    0.002554      23.635        0
## 
## LogLikelihood : 1884.091 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -2.7695
## Bayes        -2.7503
## Shibata      -2.7695
## Hannan-Quinn -2.7623
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                       4.727 0.02969
## Lag[2*(p+q)+(p+q)-1][11]    23.144 0.00000
## Lag[4*(p+q)+(p+q)-1][19]    60.396 0.00000
## 
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      2.285 0.13061
## Lag[2*(p+q)+(p+q)-1][2]     3.521 0.10147
## Lag[4*(p+q)+(p+q)-1][5]     6.471 0.06955
## 
## 
## ARCH LM Tests
## ------------------------------------
##              Statistic DoF   P-Value
## ARCH Lag[2]      4.948   2 8.423e-02
## ARCH Lag[5]     11.815   5 3.742e-02
## ARCH Lag[10]    48.425  10 5.190e-07
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  5.8486
## Individual Statistics:             
## ar1   0.05215
## ar2   0.06194
## ma1   0.09364
## ma2   0.07360
## sigma 1.59544
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.28 1.47 1.88
## Individual Statistic:     0.35 0.47 0.75
## 
## 
## Elapsed time : 0.06224179 
## 
## 
## $rank.matrix
##    ar1 ar2 ma1 ma2 im arf        AIC converged
## 1    1   1   1   1  0   0  -2.769479         1
## 2    1   1   1   1  1   0  -2.768007         1
## 3    1   1   1   0  0   0  -2.709054         1
## 4    1   0   1   1  0   0  -2.707904         1
## 5    1   1   1   0  1   0  -2.707842         1
## 6    1   0   1   1  1   0  -2.706704         1
## 7    0   1   0   1  0   0  -2.641478         1
## 8    1   1   0   1  0   0  -2.640023         1
## 9    0   1   0   1  1   0  -2.640006         1
## 10   1   1   0   1  1   0  -2.638551         1
## 11   0   0   0   1  0   0  -2.638400         1
## 12   0   1   0   0  0   0  -2.638356         1
## 13   0   0   1   0  0   0  -2.638001         1
## 14   1   0   0   0  0   0  -2.637993         1
## 15   0   0   0   0  1   0  -2.637942         1
## 16   0   0   1   1  0   0  -2.637006         1
## 17   1   0   0   1  0   0  -2.636993         1
## 18   0   1   1   0  0   0  -2.636951         1
## 19   1   1   0   0  0   0  -2.636942         1
## 20   0   0   0   1  1   0  -2.636928         1
## 21   0   1   0   0  1   0  -2.636884         1
## 22   0   0   1   0  1   0  -2.636529         1
## 23   1   0   1   0  0   0  -2.636524         1
## 24   1   0   0   0  1   0  -2.636521         1
## 25   0   0   1   1  1   0  -2.635534         1
## 26   0   1   1   0  1   0  -2.635479         1
## 27   1   1   0   0  1   0  -2.635471         1
## 28   1   0   0   1  1   0  -2.635187         1
## 29   1   0   1   0  1   0  -2.635052         1
## 30   0   1   1   1  1   0  98.500995         1
## 31   0   1   1   1  0   0 101.886440         1

2 MÔ HÌNH GJR-GARCH

2.1 CÁC DẠNG MÔ HÌNH CHO CHUỖI LỢI SUẤT SGX

2.1.1 GJR-GARCH(11)SGX

# PHÂN PHỐI CHUẨN
sgx11n.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'norm')

sgx11n <- ugarchfit(spec = sgx11n.spec, data$TSX)

# PHÂN PHỐI STUDENT
sgx11std.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'std')

sgx11std <- ugarchfit(sgx11std.spec, data$TSX)

# PHÂN PHỐI ĐỐI XỨNG
sgx11sstd.spec <- ugarchspec(variance.model = list( model = 'gjrGARCH', garchOrder = c(1,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sstd')

sgx11sstd <- ugarchfit(sgx11sstd.spec, data$TSX)

# PHÂN PHỐI PHÂN PHỐI Generalized Error Distribution 
sgx11ged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")

sgx11ged <- ugarchfit(sgx11ged.spec, data$TSX)

# PHÂN PHỐI Generalized Error Distribution đối xứng (sged)
sgx11sged.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sged')

sgx11sged <- ugarchfit(sgx11sged.spec, data$TSX)

2.1.2 GJR-GARCH(12)SGX

# PHÂN PHỐI CHUẨN
sgx12n.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'norm')

sgx12n <- ugarchfit(spec = sgx12n.spec, data$TSX)


# PHÂN PHỐI STUDENT
sgx12std.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'std')

sgx12std <- ugarchfit(sgx12std.spec, data$TSX)


# PHÂN PHỐI ĐỐI XỨNG
sgx12sstd.spec <- ugarchspec(variance.model = list( model = 'gjrGARCH', garchOrder = c(1,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sstd')

sgx12sstd <- ugarchfit(sgx12sstd.spec, data$TSX)

# PHÂN PHỐI PHÂN PHỐI Generalized Error Distribution 
sgx12ged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1,2)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")

sgx12ged <- ugarchfit(sgx12ged.spec, data$TSX)

# PHÂN PHỐI Generalized Error Distribution đối xứng (sged)
sgx12sged.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sged')

sgx12sged <- ugarchfit(sgx12sged.spec, data$TSX)

2.1.3 GJR-GARCH(21)SGX

# PHÂN PHỐI CHUẨN
sgx21n.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'norm')

sgx21n <- ugarchfit(spec = sgx21n.spec, data$TSX)

# PHÂN PHỐI STUDENT
sgx21std.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'std')

sgx21std <- ugarchfit(sgx21std.spec, data$TSX)

# PHÂN PHỐI ĐỐI XỨNG
sgx21sstd.spec <- ugarchspec(variance.model = list( model = 'gjrGARCH', garchOrder = c(2,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sstd')

sgx21sstd <- ugarchfit(sgx21sstd.spec, data$TSX)

# PHÂN PHỐI PHÂN PHỐI Generalized Error Distribution 
sgx21ged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2,1)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")

sgx21ged <- ugarchfit(sgx21ged.spec, data$TSX)

# PHÂN PHỐI Generalized Error Distribution đối xứng (sged)
sgx21sged.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sged')

sgx21sged <- ugarchfit(sgx21sged.spec, data$TSX)

2.1.4 GJR_GARCH(22)SGX

# PHÂN PHỐI CHUẨN
sgx22n.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'norm')

sgx22n <- ugarchfit(spec = sgx22n.spec, data$TSX)

# PHÂN PHỐI STUDENT
sgx22std.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'std')

sgx22std <- ugarchfit(sgx22std.spec, data$TSX)

# PHÂN PHỐI ĐỐI XỨNG
sgx22sstd.spec <- ugarchspec(variance.model = list( model = 'gjrGARCH', garchOrder = c(2,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sstd')

sgx22sstd <- ugarchfit(sgx22sstd.spec, data$TSX)

# PHÂN PHỐI PHÂN PHỐI Generalized Error Distribution 
sgx22ged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2,2)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")

sgx22ged <- ugarchfit(sgx22ged.spec, data$TSX)

# PHÂN PHỐI Generalized Error Distribution đối xứng (sged)
sgx22sged.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sged')

sgx22sged <- ugarchfit(sgx22sged.spec, data$TSX)

2.2 CÁC DẠNG MÔ HÌNH CHO CHUỖI LỢI SUẤT VNI

2.2.1 GJR-GARCH(11)VNI

# PHÂN PHỐI CHUẨN
vni11n.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'norm')

vni11n <- ugarchfit(spec = vni11n.spec, data$TSVN)

# PHÂN PHỐI STUDENT
vni11std.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'std')

vni11std <- ugarchfit(vni11std.spec, data$TSVN)

# PHÂN PHỐI ĐỐI XỨNG
vni11sstd.spec <- ugarchspec(variance.model = list( model = 'gjrGARCH', garchOrder = c(1,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sstd')

vni11sstd <- ugarchfit(vni11sstd.spec, data$TSVN)

# PHÂN PHỐI PHÂN PHỐI Generalized Error Distribution 
vni11ged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")

vni11ged <- ugarchfit(vni11ged.spec, data$TSVN)

# PHÂN PHỐI Generalized Error Distribution đối xứng (sged)
vni11sged.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sged')

vni11sged <- ugarchfit(vni11sged.spec, data$TSVN)

2.2.2 GJR-GARCH(12)VNI

# PHÂN PHỐI CHUẨN
vni12n.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'norm')

vni12n <- ugarchfit(spec = vni12n.spec, data$TSVN)

# PHÂN PHỐI STUDENT
vni12std.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'std')

vni12std <- ugarchfit(vni12std.spec, data$TSVN)

# PHÂN PHỐI ĐỐI XỨNG
vni12sstd.spec <- ugarchspec(variance.model = list( model = 'gjrGARCH', garchOrder = c(1,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sstd')

vni12sstd <- ugarchfit(vni12sstd.spec, data$TSVN)

# PHÂN PHỐI PHÂN PHỐI Generalized Error Distribution 
vni12ged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1,2)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")

vni12ged <- ugarchfit(vni12ged.spec, data$TSVN)

# PHÂN PHỐI Generalized Error Distribution đối xứng (sged)
vni12sged.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(1,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sged')

vni12sged <- ugarchfit(vni12sged.spec, data$TSVN)

2.2.3 GJR-GARCH(21)VNI

# PHÂN PHỐI CHUẨN
vni21n.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'norm')

vni21n <- ugarchfit(spec = vni21n.spec, data$TSVN)

# PHÂN PHỐI STUDENT
vni21std.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'std')

vni21std <- ugarchfit(vni21std.spec, data$TSVN)

# PHÂN PHỐI ĐỐI XỨNG
vni21sstd.spec <- ugarchspec(variance.model = list( model = 'gjrGARCH', garchOrder = c(2,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sstd')

vni21sstd <- ugarchfit(vni21sstd.spec, data$TSVN)

# PHÂN PHỐI PHÂN PHỐI Generalized Error Distribution 
vni21ged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2,1)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")

vni21ged <- ugarchfit(vni21ged.spec, data$TSVN)

# PHÂN PHỐI Generalized Error Distribution đối xứng (sged)
vni21sged.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,1)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sged')

vni21sged <- ugarchfit(vni21sged.spec, data$TSVN)

2.2.4 GJR_GARCH(22)VNI

# PHÂN PHỐI CHUẨN
vni22n.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'norm')

vni22n <- ugarchfit(spec = vni22n.spec, data$TSVN)

# PHÂN PHỐI STUDENT
vni22std.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'std')

vni22std <- ugarchfit(vni22std.spec, data$TSVN)

# PHÂN PHỐI ĐỐI XỨNG
vni22sstd.spec <- ugarchspec(variance.model = list( model = 'gjrGARCH', garchOrder = c(2,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sstd')

vni22sstd <- ugarchfit(vni22sstd.spec, data$TSVN)

# PHÂN PHỐI PHÂN PHỐI Generalized Error Distribution 
vni22ged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2,2)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")

vni22ged <- ugarchfit(vni22ged.spec, data$TSVN)

# PHÂN PHỐI Generalized Error Distribution đối xứng (sged)
vni22sged.spec <- ugarchspec(variance.model = list(model = 'gjrGARCH', garchOrder = c(2,2)), mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = 'sged')

vni22sged <- ugarchfit(vni22sged.spec, data$TSVN)

3 LỰA CHỌN MÔ HÌNH GJR-GARCH

3.1 LỰA CHỌN MÔ HÌNH BIÊN PHÙ HỢP NHẤT CHO CHUỖI SGX

sgx.model.list <- list(garch11n = sgx11n, 
                        garch11std = sgx11std,
                        garch11sstd = sgx11sstd,
                        garch11ged = sgx11ged,
                        garch11sged = sgx11sged,
                        
                        garch12n = sgx12n, 
                        
                        garch12ged = sgx12ged,
                        
                        
                        garch21n = sgx21n, 
                        garch21std = sgx21std,
                        
                       
                        garch21sged = sgx21sged,
                        
                        garch22n = sgx22n) 

sgx.info.mat <- sapply(sgx.model.list, infocriteria)

rownames(sgx.info.mat) <- rownames(infocriteria(sgx11n))

sgx.info.mat
##               garch11n garch11std garch11sstd garch11ged garch11sged  garch12n
## Akaike       -2.844147  -4.130698   -4.143537  -4.197696   -4.113922 -2.842674
## Bayes        -2.809573  -4.092282   -4.101280  -4.159280   -4.071665 -2.804258
## Shibata      -2.844235  -4.130806   -4.143667  -4.197804   -4.114052 -2.842781
## Hannan-Quinn -2.831203  -4.116315   -4.127716  -4.183313   -4.098101 -2.828290
##              garch12ged  garch21n garch21std garch21sged  garch22n
## Akaike        -4.115692 -2.853725  -4.127735   -4.095916 -2.873255
## Bayes         -4.073435 -2.811468  -4.081636   -4.045975 -2.827156
## Shibata       -4.115822 -2.853855  -4.127889   -4.096097 -2.873410
## Hannan-Quinn  -4.099871 -2.837904  -4.110475   -4.077218 -2.855995
sgx.inds <- which(sgx.info.mat == min(sgx.info.mat), arr.ind = TRUE)

model.sgx <- colnames(sgx.info.mat)[sgx.inds[,2]]

model.sgx
## [1] "garch11ged"
garch11ged = sgx11ged

3.2 LỰA CHỌN MÔ HÌNH BIÊN PHÙ HỢP NHẤT CHO VNI

vni.model.list <- list(garch11n = vni11n, 
                        garch11std = vni11std,
                        garch11sstd = vni11sstd,
                        garch11ged = vni11ged,
                        
                        
                       
                        garch12std = vni12std,
                        garch12sstd = vni12sstd,
                        garch12ged = vni12ged,
                       
                        
                        garch21n = vni21n, 
                        garch21std = vni21std,
                        garch21sstd = vni21sstd,
                        
                        
                        
                        garch22std = vni22std,
                        garch22sstd = vni22sstd,
                        garch22ged = vni22ged,
                        garch22sged = vni22sged)

vni.info.mat <- sapply(vni.model.list, infocriteria)

rownames(vni.info.mat) <- rownames(infocriteria(vni11n))

vni.info.mat
##               garch11n garch11std garch11sstd garch11ged garch12std garch12sstd
## Akaike       -2.922947  -3.670058   -3.674386  -3.682093  -3.668584   -3.672912
## Bayes        -2.888373  -3.631642   -3.632128  -3.643677  -3.626327   -3.626813
## Shibata      -2.923034  -3.670165   -3.674516  -3.682200  -3.668714   -3.673066
## Hannan-Quinn -2.910002  -3.655675   -3.658564  -3.667710  -3.652763   -3.655652
##              garch12ged  garch21n garch21std garch21sstd garch22std garch22sstd
## Akaike        -3.686118 -2.992916  -3.672295   -3.676397  -3.670850   -3.674932
## Bayes         -3.643861 -2.950659  -3.626196   -3.626457  -3.620909   -3.621149
## Shibata       -3.686249 -2.993046  -3.672449   -3.676578  -3.671031   -3.675142
## Hannan-Quinn  -3.670297 -2.977095  -3.655035   -3.657699  -3.652152   -3.654795
##              garch22ged garch22sged
## Akaike        -3.658456   -3.681944
## Bayes         -3.608516   -3.628162
## Shibata       -3.658637   -3.682154
## Hannan-Quinn  -3.639758   -3.661808
vni.inds <- which(vni.info.mat == min(vni.info.mat), arr.ind = TRUE)

model.vni <- colnames(vni.info.mat)[vni.inds[,2]]

model.vni
## [1] "garch12ged"
garch12ged = vni12ged

4 KIỂM ĐỊNH SỰ PHÙ HỢP CỦA MÔ HÌNH BIÊN

4.1 TRÍCH XUẤT CHUỖI PHẦN DƯ CỦA SGX

sgx.res <- residuals(sgx11ged)/sigma(sgx11ged)

fitdist(distribution = 'ged' , sgx.res, control = list())$pars
##           mu        sigma        shape 
## 4.995720e-06 9.965050e-01 3.814635e-01
s <- pdist(distribution = 'norm' , q = sgx.res, mu = 4.995720e-06 , sigma = 9.965050e-01, shape = 3.814635e-01)

4.2 TRÍCH XUẤT CHUỖI PHẦN DƯ CỦA VNI

vni.res <- residuals(vni12ged)/sigma(vni12ged)

fitdist(distribution = 'ged' , vni.res, control = list())$pars
##          mu       sigma       shape 
## -0.01409621  1.06039972  0.43231559
v <- pdist(distribution = 'sged' , q = vni.res, mu = -0.01409621 , sigma = 1.06039972, shape = 0.43231559)

4.3 CÁC KIỂM ĐỊNH SỰ PHÙ HỢP CỦA MÔ HÌNH BIÊN

# Kiểm định Anderson-Darling
ad.test(s, 'punif')
## 
##  Anderson-Darling test of goodness-of-fit
##  Null hypothesis: uniform distribution
##  Parameters assumed to be fixed
## 
## data:  s
## An = 163.8, p-value = 4.422e-07
ad.test(v, 'punif')
## 
##  Anderson-Darling test of goodness-of-fit
##  Null hypothesis: uniform distribution
##  Parameters assumed to be fixed
## 
## data:  v
## An = 2.5271, p-value = 0.04795
# Kiểm định Cramer-von Mises
cvm.test(s, 'punif')
## 
##  Cramer-von Mises test of goodness-of-fit
##  Null hypothesis: uniform distribution
##  Parameters assumed to be fixed
## 
## data:  s
## omega2 = 31.769, p-value < 2.2e-16
cvm.test(v, 'punif')
## 
##  Cramer-von Mises test of goodness-of-fit
##  Null hypothesis: uniform distribution
##  Parameters assumed to be fixed
## 
## data:  v
## omega2 = 0.33573, p-value = 0.1075
# Kiểm định ks-test
ks.test(s, 'punif')
## 
##  Asymptotic one-sample Kolmogorov-Smirnov test
## 
## data:  s
## D = 0.98305, p-value < 2.2e-16
## alternative hypothesis: two-sided
ks.test(v, 'punif')
## 
##  Asymptotic one-sample Kolmogorov-Smirnov test
## 
## data:  v
## D = 0.033695, p-value = 0.09179
## alternative hypothesis: two-sided

5 CHẠY COPULA

BiCopSelect(s, v, familyset = 1:9, selectioncrit = 'AIC', indeptest = FALSE, level = 0.05)
## Bivariate copula: t (par = 0.01, par2 = 15.67, tau = 0)
Stu <- BiCopEst(s, v, family = 2, method = 'mle', se = T, max.df = 10)
summary(Stu)
## Family
## ------ 
## No:    2
## Name:  t
## 
## Parameter(s)
## ------------
## par:  0  (SE = 0.04)
## par2: 10  (SE = NA)
## Dependence measures
## -------------------
## Kendall's tau:    0 (empirical = -0.01, p value = 0.41)
## Upper TD:         0.01 
## Lower TD:         0.01 
## 
## Fit statistics
## --------------
## logLik:  23.37 
## AIC:    -42.73 
## BIC:    -32.31