Dữ liệu sử dụng trong nghiên cứu là chuỗi dữ liệu thời gian theo ngày của chỉ số đóng cửa thị trường chứng khoán các nước ASEAN-6: Việt Nam (VNI), Thái Lan (SET), Singapore (STI), Indonesia (JCI), Malaysia (KLCI), Philippines (PSE) và giá dầu (WTI). Dữ liệu nghiên cứu được thu thập trong khoảng thời gian từ 11/01/2018 đến 10/2/2023. Dữ dữ liệu chỉ số giá dầu và chỉ số thị trường chứng khoán các nước ASEAN-6 được thu thập từ trang www.investing.com.

library(PerformanceAnalytics)
library(readxl)
data <- read_excel("C:/Users/chaua/OneDrive - UFM/TLHT/Mô hình ngẫu nhiên/data.xlsx")
mydata <- data[,c(2:8)]
head(data,6)
## # A tibble: 6 × 8
##   Ngày    WTI   VNI   JCI   SGX   PSE   SET  KLCI
##   <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 43108  6.78  953. 6033.  7.43  205  1722. 1788.
## 2 43110  9.84 1013. 5945.  7.34  184. 1760. 1792.
## 3 43133  4.35 1105. 6629.  8.16  242. 1827. 1870.
## 4 43134  3.83 1121. 6582.  7.48  246  1812. 1856.
## 5 43135  4.16 1197. 6241.  7.34  238. 1782. 1858.
## 6 43136  6.74 1029. 6012.  7.7   220. 1791. 1852.

Dùng lệnh res() để hiển thị hệ số tương quan giữa các cặp biến. Sau đó dùng round() để làm tròn đến chữ số thập phân thứ 2. Nếu muốn làm tròn đến chữ số thập phân thứ 3, ta có thể thay số 2 thành 3.

res <- cor(mydata)
round(res, 2)
##        WTI   VNI  JCI   SGX   PSE   SET  KLCI
## WTI   1.00  0.02 0.51 -0.39  0.17  0.67  0.35
## VNI   0.02  1.00 0.61  0.60  0.50  0.41 -0.06
## JCI   0.51  0.61 1.00  0.14  0.29  0.72  0.09
## SGX  -0.39  0.60 0.14  1.00 -0.04 -0.27 -0.60
## PSE   0.17  0.50 0.29 -0.04  1.00  0.59  0.45
## SET   0.67  0.41 0.72 -0.27  0.59  1.00  0.64
## KLCI  0.35 -0.06 0.09 -0.60  0.45  0.64  1.00

Nhìn vào kết quả, ta thấy mức độ tương quan giữa WTI và VNI là 0.02 > 0, vậy thì 2 biến này có mối quan hệ thuận, nếu biến WTI tăng thì VNI cũng tăng. Ngược lại ta thấy hệ số tương quan của cặp biến SGX và WTI là -0.39 < 0, thì cặp biến này có quan hệ tương quan nghịch. Tương tự cho các cặp biến còn lại.

Lệnh rcorr() trong package Hmisc tính giá trị p của ma trận hệ số tương quan như Pearson hoặc là Spearman. Kết quả trả về bao gồm ma trận hệ số tương quan và giá trị p Của mối tương quan của các cặp biến tỏng dữ liệu.

Nếu chúng ta chỉ muốn kết quả hiển thị hoặc là hệ số tương quan hoặc là p_value thì có thể làm như sau:

library(Hmisc)
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
res2<-rcorr(as.matrix(data[,2:8]))
res2 
##        WTI   VNI  JCI   SGX   PSE   SET  KLCI
## WTI   1.00  0.02 0.51 -0.39  0.17  0.67  0.35
## VNI   0.02  1.00 0.61  0.60  0.50  0.41 -0.06
## JCI   0.51  0.61 1.00  0.14  0.29  0.72  0.09
## SGX  -0.39  0.60 0.14  1.00 -0.04 -0.27 -0.60
## PSE   0.17  0.50 0.29 -0.04  1.00  0.59  0.45
## SET   0.67  0.41 0.72 -0.27  0.59  1.00  0.64
## KLCI  0.35 -0.06 0.09 -0.60  0.45  0.64  1.00
## 
## n= 1003 
## 
## 
## P
##      WTI    VNI    JCI    SGX    PSE    SET    KLCI  
## WTI         0.4328 0.0000 0.0000 0.0000 0.0000 0.0000
## VNI  0.4328        0.0000 0.0000 0.0000 0.0000 0.0437
## JCI  0.0000 0.0000        0.0000 0.0000 0.0000 0.0067
## SGX  0.0000 0.0000 0.0000        0.1616 0.0000 0.0000
## PSE  0.0000 0.0000 0.0000 0.1616        0.0000 0.0000
## SET  0.0000 0.0000 0.0000 0.0000 0.0000        0.0000
## KLCI 0.0000 0.0437 0.0067 0.0000 0.0000 0.0000
# Hệ số tương quan Pearson
res2$r
##              WTI         VNI        JCI         SGX         PSE        SET
## WTI   1.00000000  0.02479711 0.50870020 -0.39443392  0.17330172  0.6655478
## VNI   0.02479711  1.00000000 0.60779089  0.59544532  0.49819697  0.4081486
## JCI   0.50870020  0.60779089 1.00000000  0.13805585  0.28525385  0.7210100
## SGX  -0.39443392  0.59544532 0.13805585  1.00000000 -0.04423359 -0.2742388
## PSE   0.17330172  0.49819697 0.28525385 -0.04423359  1.00000000  0.5864140
## SET   0.66554784  0.40814859 0.72100997 -0.27423884  0.58641403  1.0000000
## KLCI  0.35320381 -0.06369054 0.08559485 -0.60065647  0.44699997  0.6376735
##             KLCI
## WTI   0.35320381
## VNI  -0.06369054
## JCI   0.08559485
## SGX  -0.60065647
## PSE   0.44699997
## SET   0.63767353
## KLCI  1.00000000
# Tính p_value
res2$P
##               WTI        VNI          JCI          SGX          PSE SET
## WTI            NA 0.43276430 0.000000e+00 0.000000e+00 3.323182e-08   0
## VNI  4.327643e-01         NA 0.000000e+00 0.000000e+00 0.000000e+00   0
## JCI  0.000000e+00 0.00000000           NA 1.144886e-05 0.000000e+00   0
## SGX  0.000000e+00 0.00000000 1.144886e-05           NA 1.615661e-01   0
## PSE  3.323182e-08 0.00000000 0.000000e+00 1.615661e-01           NA   0
## SET  0.000000e+00 0.00000000 0.000000e+00 0.000000e+00 0.000000e+00  NA
## KLCI 0.000000e+00 0.04373486 6.679735e-03 0.000000e+00 0.000000e+00   0
##             KLCI
## WTI  0.000000000
## VNI  0.043734860
## JCI  0.006679735
## SGX  0.000000000
## PSE  0.000000000
## SET  0.000000000
## KLCI          NA

Phần này cung cấp một hàm đơn giản để định dạng ma trận tương quan vào bảng với 4 cột chứa:

Cột 1 : tên hàng

Cột 2 : tên cột

Cột 3 : các hệ số tương quan

Cột 4 : các giá trị p của các tương quan

flattenCorrMatrix <- function(cormat, pmat) {
  ut <- upper.tri(cormat)
  data.frame(
    row = rownames(cormat)[row(cormat)[ut]],
    column = rownames(cormat)[col(cormat)[ut]],
    cor  =(cormat)[ut],
    p = pmat[ut]
    )
}
flattenCorrMatrix(res2$r, res2$P)
##    row column         cor            p
## 1  WTI    VNI  0.02479711 4.327643e-01
## 2  WTI    JCI  0.50870020 0.000000e+00
## 3  VNI    JCI  0.60779089 0.000000e+00
## 4  WTI    SGX -0.39443392 0.000000e+00
## 5  VNI    SGX  0.59544532 0.000000e+00
## 6  JCI    SGX  0.13805585 1.144886e-05
## 7  WTI    PSE  0.17330172 3.323182e-08
## 8  VNI    PSE  0.49819697 0.000000e+00
## 9  JCI    PSE  0.28525385 0.000000e+00
## 10 SGX    PSE -0.04423359 1.615661e-01
## 11 WTI    SET  0.66554784 0.000000e+00
## 12 VNI    SET  0.40814859 0.000000e+00
## 13 JCI    SET  0.72100997 0.000000e+00
## 14 SGX    SET -0.27423884 0.000000e+00
## 15 PSE    SET  0.58641403 0.000000e+00
## 16 WTI   KLCI  0.35320381 0.000000e+00
## 17 VNI   KLCI -0.06369054 4.373486e-02
## 18 JCI   KLCI  0.08559485 6.679735e-03
## 19 SGX   KLCI -0.60065647 0.000000e+00
## 20 PSE   KLCI  0.44699997 0.000000e+00
## 21 SET   KLCI  0.63767353 0.000000e+00
symnum(res, abbr.colnames = FALSE)
##      WTI VNI JCI SGX PSE SET KLCI
## WTI  1                           
## VNI      1                       
## JCI  .   ,   1                   
## SGX  .   .       1               
## PSE      .           1           
## SET  ,   .   ,       .   1       
## KLCI .           ,   .   ,   1   
## attr(,"legend")
## [1] 0 ' ' 0.3 '.' 0.6 ',' 0.8 '+' 0.9 '*' 0.95 'B' 1

Hàm symnum() là một trong hàm hiển thị ma trận tương quan trong phần mềm R. Nó thay thế cho các hệ số tương quan bằng các ký hiệu theo mức độ tương quan và lấy ma trận tương qaun làm đối số.

Trong đó:

library(corrplot)
corrplot(res, type = "upper", order = "hclust", 
         tl.col = "black", tl.srt = 45)

Biểu đồ tương quan (correlation plot) giúp chúng ta có thể sự tương quan của thị trường dầu và chứng khoán của 6 nước ASEAN-6. dựa vừa mô hình thì chúng ta thấy cả 2 thị trường này có sự tương quan chặt chẽ với nhau, nhìn chung thì hệ số hồi quy dương, thị trường dầu và chứng khoán tương quan mạnh ở các cặp SET - JCI, SET - WTI, SET - PSE, JCI - VNI, SGX - VNI, và tương quan yếu ở PSE - SGX, WTI - SGX, JCI - SGX, WTI - PSE

chart.Correlation(mydata, histogram=TRUE, pch=19)

Đường chéo trên biểu đồ thể hiện sự phân bố của từng biến

Ở dưới đường chéo là các ô đồ thị dạng scatter.

Ở trên đường chéo là các hệ số tương quan và mức ý nghĩa thống kê (p_value) được thể hiện dưới dạng ngôi sao. Mỗi mức ý nghĩa sẽ được liên kết với 1 ký hiệu : *** nghĩa là giá trị từ 0 đến 0.001.

-Tương tự cho các cặp biến khác.

library(ggplot2)
library(ggcorrplot)
df <- dplyr::select_if(mydata, is.numeric)
r <- cor(df, use="complete.obs")
ggcorrplot(r)

Tương quan của tất cả thị trường trong giai đoạn Covid 19 và chiến tranh Nga – Ukraine. Có thể thấy tương quan giữa các thị trường trước COVID – 19 ở mức trung bình. Mối tương quan cao nhất trong giai đoạn này là giữa thị trường chứng khoán Malaysia và Thái Lan (0,510733). Mức tương quan giữa các thị trường có xu hướng giảm.

library(tseries)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
data <- read_excel("C:/Users/chaua/OneDrive - UFM/TLHT/Mô hình ngẫu nhiên/data.xlsx")
Var1 <- data$VNI

result1 <-  jarque.bera.test(Var1)
print(result1)
## 
##  Jarque Bera Test
## 
## data:  Var1
## X-squared = 74.384, df = 2, p-value < 2.2e-16
library(stats)
result2 <-  Box.test(Var1, lag = 10, type = "Ljung-Box")
print(result2)
## 
##  Box-Ljung test
## 
## data:  Var1
## X-squared = 576.76, df = 10, p-value < 2.2e-16
test_statistic <- result2$statistic
p_value <- result2$p.value

cat("Test Statistic:", test_statistic, "\n")
## Test Statistic: 576.7578
cat("p-value:", p_value, "\n")
## p-value: 0

Tuần 7

Bước 1

library(rugarch)
## Loading required package: parallel
## 
## Attaching package: 'rugarch'
## The following object is masked from 'package:stats':
## 
##     sigma
data <- read_excel("C:/Users/chaua/OneDrive - UFM/TLHT/Mô hình ngẫu nhiên/data.xlsx")
VNts <- ts(data$VNI)

# Ước lượng mô hình GARCH(1,1) theo phân phối chuẩn
VNspec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(0, 0)))
VNfit <- ugarchfit(VNspec, VNts)
print(VNfit)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##          Estimate  Std. Error   t value Pr(>|t|)
## mu     1.0515e+03    8.163394 128.80173 0.000000
## omega  1.2788e+02  193.298951   0.66158 0.508244
## alpha1 4.6370e-02    0.009993   4.64013 0.000003
## beta1  9.5010e-01    0.010456  90.86779 0.000000
## gamma1 5.0680e-03    0.013774   0.36791 0.712938
## 
## Robust Standard Errors:
##          Estimate  Std. Error   t value Pr(>|t|)
## mu     1.0515e+03   26.295202  39.98674 0.000000
## omega  1.2788e+02  248.320196   0.51499 0.606562
## alpha1 4.6370e-02    0.009982   4.64543 0.000003
## beta1  9.5010e-01    0.009419 100.87251 0.000000
## gamma1 5.0680e-03    0.011037   0.45914 0.646136
## 
## LogLikelihood : -6697.912 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       13.366
## Bayes        13.390
## Shibata      13.366
## Hannan-Quinn 13.375
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      54.21 1.805e-13
## Lag[2*(p+q)+(p+q)-1][2]     56.00 1.665e-15
## Lag[4*(p+q)+(p+q)-1][5]    125.98 0.000e+00
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      5.642 1.754e-02
## Lag[2*(p+q)+(p+q)-1][5]    15.442 3.380e-04
## Lag[4*(p+q)+(p+q)-1][9]    21.427 8.581e-05
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]     2.772 0.500 2.000 0.09591
## ARCH Lag[5]     3.778 1.440 1.667 0.19513
## ARCH Lag[7]     9.124 2.315 1.543 0.02928
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  17.1566
## Individual Statistics:              
## mu     8.98336
## omega  0.33281
## alpha1 0.08117
## beta1  0.16826
## gamma1 0.13802
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.28 1.47 1.88
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value     prob sig
## Sign Bias           2.7824 0.005498 ***
## Negative Sign Bias  0.6546 0.512867    
## Positive Sign Bias  2.9345 0.003417 ***
## Joint Effect       10.0765 0.017927  **
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     261.7    1.307e-44
## 2    30     283.0    1.836e-43
## 3    40     310.0    6.623e-44
## 4    50     331.6    1.292e-43
## 
## 
## Elapsed time : 0.6972082
# Phân phối Student (std)
vnst.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")

vnst<- ugarchfit(vnst.spec,VNts) 
print(vnst)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##           Estimate  Std. Error  t value Pr(>|t|)
## mu     1008.584236   40.923972 24.64532 0.000000
## ar1       0.473812    0.339855  1.39416 0.163269
## ar2       0.521571    0.339007  1.53852 0.123921
## ma1      -0.262014    0.279604 -0.93709 0.348711
## ma2      -0.614297    0.254162 -2.41695 0.015651
## omega    42.757431   42.247974  1.01206 0.311510
## alpha1    0.086994    0.019450  4.47270 0.000008
## beta1     0.925328    0.013354 69.29195 0.000000
## gamma1   -0.026644    0.028594 -0.93179 0.351445
## shape    12.356594    3.810561  3.24272 0.001184
## 
## Robust Standard Errors:
##           Estimate  Std. Error  t value Pr(>|t|)
## mu     1008.584236   34.958369 28.85101 0.000000
## ar1       0.473812    1.047408  0.45237 0.651005
## ar2       0.521571    1.046687  0.49831 0.618268
## ma1      -0.262014    0.852573 -0.30732 0.758598
## ma2      -0.614297    0.784171 -0.78337 0.433409
## omega    42.757431   65.307551  0.65471 0.512655
## alpha1    0.086994    0.033487  2.59783 0.009381
## beta1     0.925328    0.016808 55.05205 0.000000
## gamma1   -0.026644    0.049539 -0.53783 0.590696
## shape    12.356594    6.379458  1.93694 0.052753
## 
## LogLikelihood : -6516.035 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       13.013
## Bayes        13.062
## Shibata      13.013
## Hannan-Quinn 13.032
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                      0.6471 4.212e-01
## Lag[2*(p+q)+(p+q)-1][11]   20.2034 0.000e+00
## Lag[4*(p+q)+(p+q)-1][19]   30.0425 5.603e-09
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      1.070  0.3009
## Lag[2*(p+q)+(p+q)-1][5]     2.047  0.6074
## Lag[4*(p+q)+(p+q)-1][9]     7.481  0.1622
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]    0.4888 0.500 2.000 0.48446
## ARCH Lag[5]    0.8167 1.440 1.667 0.78799
## ARCH Lag[7]    7.3750 2.315 1.543 0.07203
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  8.7664
## Individual Statistics:              
## mu     0.04099
## ar1    0.46417
## ar2    0.30878
## ma1    3.37250
## ma2    1.87039
## omega  0.09129
## alpha1 0.37431
## beta1  0.45320
## gamma1 0.41241
## shape  0.91445
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.29 2.54 3.05
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value   prob sig
## Sign Bias           0.2328 0.8160    
## Negative Sign Bias  1.0907 0.2757    
## Positive Sign Bias  1.5291 0.1265    
## Joint Effect        3.5280 0.3171    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     115.6    7.256e-16
## 2    30     130.6    7.445e-15
## 3    40     140.9    1.898e-13
## 4    50     154.8    6.731e-13
## 
## 
## Elapsed time : 5.298155
# Phân phối Student đối xứng (sstd)
vnsst.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")

vnsst<- ugarchfit(vnsst.spec,VNts) 
print(vnsst)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : sstd 
## 
## Optimal Parameters
## ------------------------------------
##           Estimate  Std. Error   t value Pr(>|t|)
## mu     1062.868563   30.481643  34.86914 0.000000
## ar1       0.450142    0.019544  23.03180 0.000000
## ar2       0.539138    0.019492  27.65968 0.000000
## ma1      -0.274112    0.017321 -15.82533 0.000000
## ma2      -0.594157    0.016194 -36.69001 0.000000
## omega    89.174028   70.024670   1.27347 0.202853
## alpha1    0.093174    0.023890   3.90011 0.000096
## beta1     0.922718    0.015842  58.24471 0.000000
## gamma1   -0.030258    0.030986  -0.97648 0.328829
## skew      1.459007    0.063475  22.98537 0.000000
## shape     7.223753    1.713434   4.21595 0.000025
## 
## Robust Standard Errors:
##           Estimate  Std. Error   t value Pr(>|t|)
## mu     1062.868563   21.829481  48.68959 0.000000
## ar1       0.450142    0.005619  80.10447 0.000000
## ar2       0.539138    0.003595 149.97949 0.000000
## ma1      -0.274112    0.029215  -9.38258 0.000000
## ma2      -0.594157    0.018886 -31.45973 0.000000
## omega    89.174028  105.794737   0.84290 0.399286
## alpha1    0.093174    0.029577   3.15019 0.001632
## beta1     0.922718    0.017059  54.09037 0.000000
## gamma1   -0.030258    0.034839  -0.86851 0.385117
## skew      1.459007    0.081454  17.91206 0.000000
## shape     7.223753    2.907841   2.48423 0.012983
## 
## LogLikelihood : -6480.562 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       12.944
## Bayes        12.998
## Shibata      12.944
## Hannan-Quinn 12.965
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                     0.00188 9.654e-01
## Lag[2*(p+q)+(p+q)-1][11]  23.51647 0.000e+00
## Lag[4*(p+q)+(p+q)-1][19]  33.70204 5.768e-11
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.8608  0.3535
## Lag[2*(p+q)+(p+q)-1][5]    2.9150  0.4228
## Lag[4*(p+q)+(p+q)-1][9]    8.3719  0.1089
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]    0.9242 0.500 2.000 0.33638
## ARCH Lag[5]    1.5794 1.440 1.667 0.57168
## ARCH Lag[7]    7.7980 2.315 1.543 0.05817
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  8.6037
## Individual Statistics:              
## mu     0.04452
## ar1    0.30059
## ar2    0.21649
## ma1    2.34399
## ma2    1.51178
## omega  0.06834
## alpha1 0.17009
## beta1  0.16484
## gamma1 0.18271
## skew   2.26651
## shape  0.54064
## 
## 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.184 0.23669    
## Negative Sign Bias   0.721 0.47111    
## Positive Sign Bias   2.229 0.02601  **
## Joint Effect         5.640 0.13048    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     58.00    7.991e-06
## 2    30     80.14    1.105e-06
## 3    40     83.70    4.207e-05
## 4    50    111.11    1.008e-06
## 
## 
## Elapsed time : 18.58467
# Phân phối Generalized Error Distribution(ged)
vnged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")

vnged <- ugarchfit(vnged.spec,VNts) 
print(vnged)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : ged 
## 
## Optimal Parameters
## ------------------------------------
##           Estimate  Std. Error   t value Pr(>|t|)
## mu     1002.362161   43.309298  23.14427 0.000000
## ar1       0.490972    0.064239   7.64289 0.000000
## ar2       0.504628    0.064019   7.88245 0.000000
## ma1      -0.267181    0.056852  -4.69959 0.000003
## ma2      -0.612536    0.051631 -11.86365 0.000000
## omega   111.484659   48.973254   2.27644 0.022820
## alpha1    0.087752    0.020167   4.35119 0.000014
## beta1     0.920590    0.014133  65.13873 0.000000
## gamma1   -0.018685    0.030280  -0.61709 0.537176
## shape     1.712774    0.130598  13.11481 0.000000
## 
## Robust Standard Errors:
##           Estimate  Std. Error   t value Pr(>|t|)
## mu     1002.362161   47.163628  21.25286 0.000000
## ar1       0.490972    0.039226  12.51666 0.000000
## ar2       0.504628    0.041750  12.08685 0.000000
## ma1      -0.267181    0.035137  -7.60392 0.000000
## ma2      -0.612536    0.034239 -17.88986 0.000000
## omega   111.484659   90.411776   1.23308 0.217547
## alpha1    0.087752    0.028110   3.12172 0.001798
## beta1     0.920590    0.017720  51.95323 0.000000
## gamma1   -0.018685    0.032825  -0.56924 0.569191
## shape     1.712774    0.253740   6.75010 0.000000
## 
## LogLikelihood : -6522.049 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       13.025
## Bayes        13.074
## Shibata      13.025
## Hannan-Quinn 13.044
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                       1.927 1.651e-01
## Lag[2*(p+q)+(p+q)-1][11]    20.117 0.000e+00
## Lag[4*(p+q)+(p+q)-1][19]    30.243 4.385e-09
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      1.501 0.22053
## Lag[2*(p+q)+(p+q)-1][5]     4.500 0.19795
## Lag[4*(p+q)+(p+q)-1][9]    10.096 0.04786
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]    0.7635 0.500 2.000 0.38224
## ARCH Lag[5]    2.0302 1.440 1.667 0.46460
## ARCH Lag[7]    8.1122 2.315 1.543 0.04954
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  8.7731
## Individual Statistics:              
## mu     0.04881
## ar1    0.47744
## ar2    0.31291
## ma1    3.63411
## ma2    1.94256
## omega  0.04802
## alpha1 0.15727
## beta1  0.49126
## gamma1 0.32387
## shape  1.27830
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.29 2.54 3.05
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value   prob sig
## Sign Bias           0.3672 0.7135    
## Negative Sign Bias  0.7591 0.4480    
## Positive Sign Bias  1.3917 0.1643    
## Joint Effect        2.5131 0.4729    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     108.8    1.323e-14
## 2    30     115.3    3.025e-12
## 3    40     130.0    1.035e-11
## 4    50     148.8    5.396e-12
## 
## 
## Elapsed time : 3.238974
# Phân phối Generalized Error Distribution đối xứng ("sged")
vnsged.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")

vnsged <- ugarchfit(vnsged.spec,VNts) 
print(vnsged)
## 
## *---------------------------------*
## *          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 : 11.11238

Bước 2

# Tạo danh sách bao gồm các phân phối và ước lượng
VNI_list <- list(VNfit,vnst,vnsst,vnged,vnsged)

# Tính toán các thông tin
vni_info_mat <- sapply(VNI_list, infocriteria) 
print(vni_info_mat)
##          [,1]     [,2]     [,3]     [,4]     [,5]
## [1,] 13.36573 13.01303 12.94429 13.02502 12.93589
## [2,] 13.39021 13.06199 12.99815 13.07398 12.98974
## [3,] 13.36568 13.01283 12.94405 13.02483 12.93565
## [4,] 13.37503 13.03164 12.96476 13.04363 12.95635
rownames(vni_info_mat)<-rownames(infocriteria(VNfit))

print(rownames(vni_info_mat))
## [1] "Akaike"       "Bayes"        "Shibata"      "Hannan-Quinn"