library(ggplot2)
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
## ✔ lubridate 1.9.2 ✔ tibble 3.2.0
## ✔ purrr 1.0.1 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(readxl)
library(rugarch)
## 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)
library(goftest)
library(tseries)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
data <- read_excel("~/2121001544_Ngoen/E/DATA.xlsx",
col_types = c("date", "numeric", "numeric",
"numeric", "numeric"))
data <- na.omit(data)
str(data)
## tibble [1,336 × 5] (S3: tbl_df/tbl/data.frame)
## $ DATE: POSIXct[1:1336], format: "2023-07-31" "2023-07-28" ...
## $ VNI : num [1:1336] 1223 1208 1197 1201 1196 ...
## $ TSVN: num [1:1336] 0.01253 0.0086 -0.00293 0.00412 0.00434 ...
## $ SGX : num [1:1336] 7.38 7.42 7.37 7.51 7.58 7.88 7.93 8 7.96 7.98 ...
## $ TSX : num [1:1336] -0.00541 0.00676 -0.01882 -0.00928 -0.03881 ...
CHUỖI LỢI TỨC
cor(data[, c("TSVN", "TSX")], method = "pearson")
## TSVN TSX
## TSVN 1.00000000 0.06072423
## TSX 0.06072423 1.00000000
cor(data[, c("TSVN", "TSX")], method = "spearman")
## TSVN TSX
## TSVN 1.00000000 -0.01050487
## TSX -0.01050487 1.00000000
cor(data[, c("TSVN", "TSX")], method = "kendall")
## TSVN TSX
## TSVN 1.000000000 -0.005628943
## TSX -0.005628943 1.000000000
Chuỗi lợi suất cho VNI
ggplot(data, aes(x = DATE, y= TSVN))+
geom_line()+
labs(title = "VNI",x = "Năm", y="Độ biến động")+
theme(plot.title = element_text(hjust = 0.5))

Chuỗi lợi suất SGX
ggplot(data, aes(x = DATE, y= TSX))+
geom_line()+
labs(title = "SGX",x = "Năm", y="Độ biến động")+
theme(plot.title = element_text(hjust = 0.5))

Mô tả thống kê
Mô tả thông kê cho VNI
library(moments)
data %>% summarise(Min = min(TSVN),
Max = max(TSVN),
Mean = mean(TSVN),
StDev = sd(TSVN),
Skewness = skewness(TSVN),
Kurtosis = kurtosis(TSVN))
## # A tibble: 1 × 6
## Min Max Mean StDev Skewness Kurtosis
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 -0.346 0.393 0.0000686 0.0642 0.308 11.1
summary(data$TSVN)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -0.3455330 -0.0102965 0.0011938 0.0000686 0.0116544 0.3930025
Thông kê cho SGX
data %>% summarise(Min = min(TSX),
Max = max(TSX),
Mean = mean(TSX),
StDev = sd(TSX),
Skewness = skewness(TSX),
Kurtosis = kurtosis(TSX))
## # A tibble: 1 × 6
## Min Max Mean StDev Skewness Kurtosis
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 -0.375 0.328 -0.000206 0.0644 -0.0908 15.0
Kiểm định
Kiểm định cho VNI
library(goftest)
## Kiểm định Augmented Dickey-Fuller
adf.test(data$TSVN)
##
## Augmented Dickey-Fuller Test
##
## data: data$TSVN
## Dickey-Fuller = -16.028, Lag order = 11, p-value = 0.01
## alternative hypothesis: stationary
## Kiểm định Jarque Bera
jarque.bera.test(data$TSVN)
##
## Jarque Bera Test
##
## data: data$TSVN
## X-squared = 3678.2, df = 2, p-value < 2.2e-16
## Kiểm định Box-Ljung
Box.test(data$TSVN, lag = 5, type = "Ljung-Box")
##
## Box-Ljung test
##
## data: data$TSVN
## X-squared = 77.683, df = 5, p-value = 2.554e-15
## Kiểm định Box-Pierce
Box.test(data$TSVN, lag = 5, type = "Box-Pierce")
##
## Box-Pierce test
##
## data: data$TSVN
## X-squared = 77.423, df = 5, p-value = 2.887e-15
## Kiểm định Arch
library(lmtest)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(fGarch)
## NOTE: Packages 'fBasics', 'timeDate', and 'timeSeries' are no longer
## attached to the search() path when 'fGarch' is attached.
##
## If needed attach them yourself in your R script by e.g.,
## require("timeSeries")
# Kiểm định hiệu ứng ARCH - LM cho chỉ số chứng khoán
arch_spec <- ugarchspec(variance.model = list(model = "sGARCH"))
arch_TSVN <- ugarchfit(spec = arch_spec, data = data$TSVN)
residuals <- residuals(arch_TSVN)
n <- length(residuals)
x <- 1:n
# Tạo mô hình tuyến tính
arch_lm_modelVNI <- lm(residuals^2 ~ x)
# Kiểm định hiệu ứng ARCH-LM
archVNI <- bptest(arch_lm_modelVNI)
# Hiển thị kết quả
archVNI
##
## studentized Breusch-Pagan test
##
## data: arch_lm_modelVNI
## BP = 4.2096, df = 1, p-value = 0.04019
Kiểm định cho SGX
library(goftest)
## Kiểm định Augmented Dickey-Fuller
adf.test(data$TSX)
## Warning in adf.test(data$TSX): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: data$TSX
## Dickey-Fuller = -15.589, Lag order = 11, p-value = 0.01
## alternative hypothesis: stationary
## Kiểm định Jarque Bera
jarque.bera.test(data$TSX)
##
## Jarque Bera Test
##
## data: data$TSX
## X-squared = 8046.6, df = 2, p-value < 2.2e-16
## Kiểm định Box-Ljung
Box.test(data$TSX, lag = 5, type = "Ljung-Box")
##
## Box-Ljung test
##
## data: data$TSX
## X-squared = 5.227, df = 5, p-value = 0.3888
## Kiểm định Box-Pierce
Box.test(data$TSX, lag = 5, type = "Box-Pierce")
##
## Box-Pierce test
##
## data: data$TSX
## X-squared = 5.2053, df = 5, p-value = 0.3913
## Kiểm định Arch
library(lmtest)
library(fGarch)
# Kiểm định hiệu ứng ARCH - LM cho chỉ số chứng khoán
arch_spec <- ugarchspec(variance.model = list(model = "sGARCH"))
arch_TSX <- ugarchfit(spec = arch_spec, data = data$TSX)
residuals <- residuals(arch_TSX)
n <- length(residuals)
x <- 1:n
# Tạo mô hình tuyến tính
arch_lm_modelSGX <- lm(residuals^2 ~ x)
# Kiểm định hiệu ứng ARCH-LM
archSGX <- bptest(arch_lm_modelSGX)
# Hiển thị kết quả
archSGX
##
## studentized Breusch-Pagan test
##
## data: arch_lm_modelSGX
## BP = 17.627, df = 1, p-value = 2.687e-05
Đồ thị QQ
library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.2.3
ggqqplot(data$TSVN)

ggqqplot(data$TSX)
