library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.2     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(rugarch)
## Warning: package 'rugarch' was built under R version 4.3.1
## Loading required package: parallel
## 
## Attaching package: 'rugarch'
## 
## The following object is masked from 'package:purrr':
## 
##     reduce
## 
## The following object is masked from 'package:stats':
## 
##     sigma
library(VineCopula)
## Warning: package 'VineCopula' was built under R version 4.3.1
library(goftest)
data1 <- read_excel('C:/Users/Thanh Lan/Documents/data.xlsx')
SGX <- ts(data1$SGX)
VNI <- ts(data1$VNI)

1 MÔ HÌNH ARMA

autoarfima(SGX, 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|)
## mu      8.39610    0.217640  38.5779 0.000000
## ar1     0.36230    0.099668   3.6351 0.000278
## ar2     0.62158    0.101224   6.1407 0.000000
## ma1    -0.17601    0.083789  -2.1006 0.035672
## ma2    -0.70333    0.080850  -8.6992 0.000000
## sigma   0.95587    0.021133  45.2320 0.000000
## 
## Robust Standard Errors:
##        Estimate  Std. Error  t value Pr(>|t|)
## mu      8.39610    0.403169  20.8252 0.000000
## ar1     0.36230    0.127025   2.8522 0.004342
## ar2     0.62158    0.117146   5.3061 0.000000
## ma1    -0.17601    0.114555  -1.5365 0.124422
## ma2    -0.70333    0.089977  -7.8167 0.000000
## sigma   0.95587    0.035565  26.8764 0.000000
## 
## LogLikelihood : -1377.929 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.7596
## Bayes        2.7890
## Shibata      2.7595
## Hannan-Quinn 2.7707
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                       5.535 0.01864
## Lag[2*(p+q)+(p+q)-1][11]    50.099 0.00000
## Lag[4*(p+q)+(p+q)-1][19]    62.169 0.00000
## 
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      1.829 1.763e-01
## Lag[2*(p+q)+(p+q)-1][2]     9.684 2.317e-03
## Lag[4*(p+q)+(p+q)-1][5]    49.607 8.205e-14
## 
## 
## ARCH LM Tests
## ------------------------------------
##              Statistic DoF  P-Value
## ARCH Lag[2]      17.07   2 0.000197
## ARCH Lag[5]      93.58   5 0.000000
## ARCH Lag[10]    116.09  10 0.000000
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  24.6936
## Individual Statistics:           
## mu    1.158
## ar1   5.374
## ar2   5.478
## ma1   4.486
## ma2   5.075
## sigma 8.944
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.49 1.68 2.12
## Individual Statistic:     0.35 0.47 0.75
## 
## 
## Elapsed time : 0.110553 
## 
## 
## $rank.matrix
##    ar1 ar2 ma1 ma2 im arf      AIC converged
## 1    1   1   1   1  1   0 2.759580         1
## 2    1   1   0   1  1   0 2.762269         1
## 3    1   0   1   1  1   0 2.782004         1
## 4    0   1   1   1  1   0 2.782286         1
## 5    0   1   0   1  1   0 2.819140         1
## 6    1   1   1   0  1   0 2.945636         1
## 7    1   0   1   0  1   0 2.947436         1
## 8    0   0   1   0  1   0 2.947875         1
## 9    1   0   0   1  1   0 2.948337         1
## 10   0   0   1   1  1   0 2.948859         1
## 11   0   1   1   0  1   0 2.950354         1
## 12   1   0   0   0  1   0 2.952667         1
## 13   1   1   0   0  1   0 2.955422         1
## 14   0   1   0   0  1   0 3.031075         1
## 15   0   0   0   1  1   0 3.034308         1
## 16   0   0   0   0  1   0 3.038043         1
## 17   1   0   1   1  0   0 3.074446         1
## 18   1   0   1   0  0   0 3.077150         1
## 19   1   1   0   1  0   0 3.089679         1
## 20   1   1   1   1  0   0 3.090444         1
## 21   0   1   1   1  0   0 3.135866         1
## 22   0   1   0   1  0   0 3.277547         1
## 23   1   1   0   0  0   0 3.318641         1
## 24   1   0   0   1  0   0 3.341739         1
## 25   1   0   0   0  0   0 3.414841         1
## 26   0   1   1   0  0   0 3.561762         1
## 27   0   1   0   0  0   0 3.671486         1
## 28   0   0   1   1  0   0 5.299032         1
## 29   0   0   1   0  0   0 6.025187         1
## 30   0   0   0   1  0   0 6.144198         1
## 31   1   1   1   0  0   0       NA         0
autoarfima(VNI, 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|)
## mu    1067.84393   36.769312  29.0417 0.000000
## ar1      0.41026    0.081371   5.0418 0.000000
## ar2      0.57410    0.080181   7.1600 0.000000
## ma1     -0.23411    0.070331  -3.3287 0.000872
## ma2     -0.64951    0.063788 -10.1823 0.000000
## sigma  177.87816    3.972033  44.7826 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu    1067.84393   37.817783  28.2366    0e+00
## ar1      0.41026    0.055441   7.3999    0e+00
## ar2      0.57410    0.056684  10.1281    0e+00
## ma1     -0.23411    0.051844  -4.5157    6e-06
## ma2     -0.64951    0.050201 -12.9381    0e+00
## sigma  177.87816    5.673102  31.3547    0e+00
## 
## LogLikelihood : -6619.806 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       13.212
## Bayes        13.241
## Shibata      13.212
## Hannan-Quinn 13.223
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                       5.185 0.02278
## Lag[2*(p+q)+(p+q)-1][11]    33.608 0.00000
## Lag[4*(p+q)+(p+q)-1][19]    45.447 0.00000
## 
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                     0.7747 3.788e-01
## Lag[2*(p+q)+(p+q)-1][2]    1.0065 4.961e-01
## Lag[4*(p+q)+(p+q)-1][5]   21.8838 5.861e-06
## 
## 
## ARCH LM Tests
## ------------------------------------
##              Statistic DoF   P-Value
## ARCH Lag[2]      1.186   2 5.526e-01
## ARCH Lag[5]     58.116   5 2.977e-11
## ARCH Lag[10]    86.505  10 2.631e-14
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  11.9009
## Individual Statistics:            
## mu    0.1983
## ar1   2.0868
## ar2   1.4282
## ma1   4.9852
## ma2   3.5469
## sigma 7.2946
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.49 1.68 2.12
## Individual Statistic:     0.35 0.47 0.75
## 
## 
## Elapsed time : 0.08170295 
## 
## 
## $rank.matrix
##    ar1 ar2 ma1 ma2 im arf       AIC converged
## 1    1   1   1   1  1   0  13.21198         1
## 2    1   1   0   1  1   0  13.22486         1
## 3    0   1   1   1  1   0  13.22728         1
## 4    0   1   0   1  1   0  13.26008         1
## 5    1   1   1   0  1   0  13.35782         1
## 6    1   0   1   0  1   0  13.35832         1
## 7    1   0   1   1  1   0  13.35918         1
## 8    0   0   1   0  1   0  13.36044         1
## 9    0   0   1   1  1   0  13.36098         1
## 10   1   0   0   1  1   0  13.36225         1
## 11   0   1   1   0  1   0  13.36255         1
## 12   1   0   0   0  1   0  13.36414         1
## 13   1   1   0   0  1   0  13.36623         1
## 14   0   0   0   1  1   0  13.42126         1
## 15   0   0   0   0  1   0  13.42131         1
## 16   0   1   0   0  1   0  13.42334         1
## 17   1   0   1   1  0   0  13.43562         1
## 18   1   0   1   0  0   0  13.43597         1
## 19   1   1   0   1  0   0  13.43893         1
## 20   1   1   1   1  0   0  13.44069         1
## 21   0   1   1   1  0   0  13.46510         1
## 22   0   1   0   1  0   0  13.58601         1
## 23   1   1   0   0  0   0  13.71900         1
## 24   1   0   0   1  0   0  13.78596         1
## 25   1   0   0   0  0   0  13.84300         1
## 26   0   1   1   0  0   0  13.92197         1
## 27   0   1   0   0  0   0  14.06833         1
## 28   0   0   1   1  0   0  15.24073         1
## 29   0   0   1   0  0   0  15.80210         1
## 30   0   0   0   1  0   0  15.91548         1
## 31   1   1   1   0  0   0 150.89782         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, SGX)

# 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, SGX)

# 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, SGX)

# 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, SGX)

# 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, SGX)

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, SGX)

# 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, SGX)

# 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, SGX)

# 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, SGX)

# 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, SGX)

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, SGX)

# 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, SGX)

# 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, SGX)

# 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, SGX)

# 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, SGX)

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, SGX)

# 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, SGX)

# 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, SGX)

# 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, SGX)

# 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, SGX)

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, VNI)

# 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, VNI)

# 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, VNI)

# 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, VNI)

# 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, VNI)

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, VNI)

# 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, VNI)

# 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, VNI)

# 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, VNI)

# 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, VNI)

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, VNI)

# 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, VNI)

# 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, VNI)

# 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, VNI)

# 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, VNI)

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, VNI)

# 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, VNI)

# 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, VNI)

# 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, VNI)

# 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, VNI)

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, 
                        garch12std = sgx12std,
                        garch12sstd = sgx12sstd,
                        garch12ged = sgx12ged,
                        garch12sged = sgx12sged,
                        
                        garch21n = sgx21n, 
                        garch21std = sgx21std,
                        garch21sstd = sgx21sstd,
                        garch21ged = sgx21ged,
                        garch21sged = sgx21sged,
                        
                        garch22n = sgx22n, 
                        garch22std = sgx22std,
                        garch22sstd = sgx22sstd,
                        garch22ged = sgx22ged,
                        garch22sged = sgx22sged)

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.526233   2.528161    2.529850   2.528179    2.529741 2.528227
## Bayes        2.570298   2.577122    2.583707   2.577140    2.583597 2.577188
## Shibata      2.526074   2.527965    2.529613   2.527983    2.529504 2.528031
## Hannan-Quinn 2.542978   2.546767    2.550317   2.546785    2.550207 2.546833
##              garch12std garch12sstd garch12ged garch12sged garch21n garch21std
## Akaike         2.530165    2.531844   2.530173    2.531735 2.512831   2.519675
## Bayes          2.584022    2.590597   2.584030    2.590487 2.566688   2.578428
## Shibata        2.529928    2.531562   2.529936    2.531453 2.512594   2.519393
## Hannan-Quinn   2.550632    2.554171   2.550639    2.554062 2.533298   2.542002
##              garch21sstd garch21ged garch21sged garch22n garch22std garch22sstd
## Akaike          2.521248   2.519586    2.520872 2.519587   2.521734    2.517290
## Bayes           2.584897   2.578339    2.584520 2.578340   2.585383    2.585835
## Shibata         2.520918   2.519304    2.520541 2.519305   2.521403    2.516908
## Hannan-Quinn    2.545436   2.541913    2.545059 2.541914   2.545921    2.543338
##              garch22ged garch22sged
## Akaike         2.521580    2.522865
## Bayes          2.585229    2.591410
## Shibata        2.521250    2.522483
## Hannan-Quinn   2.545768    2.548913
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] "garch21n"
sgx21n
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(2,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error     t value Pr(>|t|)
## mu      7.409277    0.135438  5.4706e+01  0.00000
## ar1     0.457257    0.010445  4.3776e+01  0.00000
## ar2     0.540432    0.004878  1.1080e+02  0.00000
## ma1    -0.242441    0.040632 -5.9668e+00  0.00000
## ma2    -0.623333    0.078023 -7.9890e+00  0.00000
## omega   0.007952    0.000298  2.6687e+01  0.00000
## alpha1  0.090683    0.002847  3.1856e+01  0.00000
## alpha2  0.000000    0.011334  1.7000e-05  0.99999
## beta1   0.882426    0.000050  1.7488e+04  0.00000
## gamma1 -0.209070    0.018021 -1.1601e+01  0.00000
## gamma2  0.259791    0.021214  1.2246e+01  0.00000
## 
## Robust Standard Errors:
##         Estimate  Std. Error     t value Pr(>|t|)
## mu      7.409277    0.482333   15.361336 0.000000
## ar1     0.457257    0.043226   10.578202 0.000000
## ar2     0.540432    0.023382   23.113535 0.000000
## ma1    -0.242441    0.180528   -1.342955 0.179286
## ma2    -0.623333    0.314488   -1.982055 0.047473
## omega   0.007952    0.003611    2.202075 0.027660
## alpha1  0.090683    0.033331    2.720655 0.006515
## alpha2  0.000000    0.038743    0.000005 0.999996
## beta1   0.882426    0.000117 7511.282693 0.000000
## gamma1 -0.209070    0.020212  -10.343891 0.000000
## gamma2  0.259791    0.036047    7.207023 0.000000
## 
## LogLikelihood : -1249.185 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.5128
## Bayes        2.5667
## Shibata      2.5126
## Hannan-Quinn 2.5333
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                       0.904 3.417e-01
## Lag[2*(p+q)+(p+q)-1][11]    24.385 0.000e+00
## Lag[4*(p+q)+(p+q)-1][19]    33.963 4.131e-11
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                       1.559 0.21184
## Lag[2*(p+q)+(p+q)-1][8]     10.729 0.02372
## Lag[4*(p+q)+(p+q)-1][14]    15.664 0.01834
## d.o.f=3
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale  P-Value
## ARCH Lag[4]     8.739 0.500 2.000 0.003115
## ARCH Lag[6]     9.248 1.461 1.711 0.011920
## ARCH Lag[8]    12.296 2.368 1.583 0.006816
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  6.8514
## Individual Statistics:              
## mu     0.03081
## ar1    0.29252
## ar2    0.25877
## ma1    3.46303
## ma2    3.63152
## omega  0.28628
## alpha1 0.06594
## alpha2 0.16258
## beta1  0.35314
## gamma1 0.12787
## gamma2 0.23233
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.49 2.75 3.27
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value   prob sig
## Sign Bias           1.6171 0.1062    
## Negative Sign Bias  0.7976 0.4253    
## Positive Sign Bias  0.2712 0.7863    
## Joint Effect        3.2480 0.3549    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     93.65    7.434e-12
## 2    30     85.11    2.023e-07
## 3    40    112.89    4.125e-09
## 4    50    124.27    1.813e-08
## 
## 
## Elapsed time : 0.5167799

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,
                        garch11sged = vni11sged,
                        
                        garch12n = vni12n, 
                        garch12std = vni12std,
                        garch12sstd = vni12sstd,
                        garch12ged = vni12ged,
                        garch12sged = vni12sged,
                        
                        garch21n = vni21n, 
                        garch21std = vni21std,
                        garch21sstd = vni21sstd,
                        garch21ged = vni21ged,
                        garch21sged = vni21sged,
                        
                        garch22n = vni22n, 
                        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 garch11sged garch12n
## Akaike       13.02755   13.01303    12.94429   13.02502    12.93589 13.02846
## Bayes        13.07162   13.06199    12.99815   13.07398    12.98974 13.07743
## Shibata      13.02739   13.01283    12.94405   13.02483    12.93565 13.02827
## Hannan-Quinn 13.04430   13.03164    12.96476   13.04363    12.95635 13.04707
##              garch12std garch12sstd garch12ged garch12sged garch21n garch21std
## Akaike         13.01454    12.94555   13.02614    12.93788 13.02936   13.01585
## Bayes          13.06840    13.00430   13.08000    12.99663 13.08321   13.07460
## Shibata        13.01431    12.94527   13.02590    12.93760 13.02912   13.01557
## Hannan-Quinn   13.03501    12.96788   13.04661    12.96021 13.04982   13.03818
##              garch21sstd garch21ged garch21sged garch22n garch22std garch22sstd
## Akaike          12.94778   13.02720    12.93938 13.03135   13.01425    12.94554
## Bayes           13.01143   13.08595    13.00303 13.09010   13.07790    13.01409
## Shibata         12.94745   13.02692    12.93905 13.03107   13.01392    12.94516
## Hannan-Quinn    12.97197   13.04952    12.96357 13.05368   13.03843    12.97159
##              garch22ged garch22sged
## Akaike         13.02580    12.93650
## Bayes          13.08945    13.00505
## Shibata        13.02547    12.93612
## Hannan-Quinn   13.04998    12.96255
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] "garch11sged"
vni11sged
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : sged 
## 
## Optimal Parameters
## ------------------------------------
##           Estimate  Std. Error  t value Pr(>|t|)
## mu     1056.618112   28.346113  37.2756 0.000000
## ar1       0.483453    0.006557  73.7353 0.000000
## ar2       0.494958    0.006391  77.4428 0.000000
## ma1      -0.327051    0.019355 -16.8975 0.000000
## ma2      -0.537719    0.016398 -32.7921 0.000000
## omega   187.559395   77.345887   2.4249 0.015311
## alpha1    0.099859    0.013429   7.4362 0.000000
## beta1     0.918762    0.010053  91.3899 0.000000
## gamma1   -0.033359    0.019245  -1.7334 0.083018
## skew      1.509278    0.054210  27.8412 0.000000
## shape     1.165975    0.090351  12.9049 0.000000
## 
## Robust Standard Errors:
##           Estimate  Std. Error  t value Pr(>|t|)
## mu     1056.618112   47.737836  22.1338 0.000000
## ar1       0.483453    0.004539 106.5169 0.000000
## ar2       0.494958    0.004143 119.4810 0.000000
## ma1      -0.327051    0.025636 -12.7574 0.000000
## ma2      -0.537719    0.011916 -45.1262 0.000000
## omega   187.559395  145.396434   1.2900 0.197055
## alpha1    0.099859    0.010265   9.7277 0.000000
## beta1     0.918762    0.007234 127.0147 0.000000
## gamma1   -0.033359    0.012068  -2.7644 0.005704
## skew      1.509278    0.080204  18.8180 0.000000
## shape     1.165975    0.180441   6.4618 0.000000
## 
## LogLikelihood : -6476.347 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       12.936
## Bayes        12.990
## Shibata      12.936
## Hannan-Quinn 12.956
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                      0.1979 6.564e-01
## Lag[2*(p+q)+(p+q)-1][11]   25.4648 0.000e+00
## Lag[4*(p+q)+(p+q)-1][19]   36.8230 1.003e-12
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      0.144 0.70434
## Lag[2*(p+q)+(p+q)-1][5]     4.502 0.19778
## Lag[4*(p+q)+(p+q)-1][9]    10.073 0.04839
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]     1.671 0.500 2.000 0.19608
## ARCH Lag[5]     3.166 1.440 1.667 0.26661
## ARCH Lag[7]     8.770 2.315 1.543 0.03526
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  9.7862
## Individual Statistics:              
## mu     0.07939
## ar1    0.44657
## ar2    0.31978
## ma1    2.24638
## ma2    1.51758
## omega  0.06789
## alpha1 0.08952
## beta1  0.25788
## gamma1 0.11160
## skew   1.81608
## shape  0.33855
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.49 2.75 3.27
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value     prob sig
## Sign Bias            2.049 0.040706  **
## Negative Sign Bias   0.214 0.830614    
## Positive Sign Bias   2.860 0.004322 ***
## Joint Effect         8.720 0.033262  **
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     48.55    2.139e-04
## 2    30     81.88    6.137e-07
## 3    40    105.47    4.945e-08
## 4    50    119.68    7.587e-08
## 
## 
## Elapsed time : 3.323833

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(sgx21n)/sigma(sgx21n)

fitdist(distribution = 'norm' , sgx.res, control = list())$pars
##         mu      sigma 
## 0.04993222 0.99128476
s <- pdist(distribution = 'norm' , q = sgx.res, mu = 0.04993222 , sigma = 0.99128476)

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

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

fitdist(distribution = 'sged' , vni.res, control = list())$pars
##           mu        sigma         skew        shape 
## 0.0001526608 0.9957763523 1.5076768019 1.1732611271
v <- pdist(distribution = 'sged' , q = vni.res, mu = 0.0001526608 , sigma = 0.9957763523, skew = 1.5076768019, shape = 1.1732611271)

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 = 2.0949, p-value = 0.08151
ad.test(v, 'punif')
## 
##  Anderson-Darling test of goodness-of-fit
##  Null hypothesis: uniform distribution
##  Parameters assumed to be fixed
## 
## data:  v
## An = 2.0199, p-value = 0.08957
# 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 = 0.23188, p-value = 0.2134
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.2657, p-value = 0.1694
# Kiểm định ks-test
ks.test(s, 'punif')
## 
##  Asymptotic one-sample Kolmogorov-Smirnov test
## 
## data:  s
## D = 0.95922, p-value < 2.2e-16
## alternative hypothesis: two-sided
ks.test(v, 'punif')
## 
##  Asymptotic one-sample Kolmogorov-Smirnov test
## 
## data:  v
## D = 0.034205, p-value = 0.1911
## alternative hypothesis: two-sided

5 CHẠY COPULA

BiCopSelect(s, v, familyset = 1:9, selectioncrit = 'AIC', indeptest = FALSE, level = 0.05)
## Bivariate copula: Frank (par = 3.26, tau = 0.33)
Stu <- BiCopEst(s, v, family = 5, method = 'mle', se = T, max.df = 10)
summary(Stu)
## Family
## ------ 
## No:    5
## Name:  Frank
## 
## Parameter(s)
## ------------
## par:  3.26  (SE = 0.21)
## 
## Dependence measures
## -------------------
## Kendall's tau:    0.33 (empirical = 0.33, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  130.26 
## AIC:    -258.53 
## BIC:    -253.62