library(readxl)
library(dgof)
##
## Attaching package: 'dgof'
## The following object is masked from 'package:stats':
##
## ks.test
Data <- read_excel("C:/Users/84896/Desktop/2018 - 2024 CE & STOCK.xlsx", sheet = "DCoVaR_Full")
dcovar1 <- Data$VNI
dcovar2 <- Data$SET
dcovar3 <- Data$PSE
dcovar4 <- Data$JCI
dcovar5 <- Data$KLCI
dcovar6 <- Data$SGXL
Data <- read_excel("C:/Users/84896/Desktop/2018 - 2024 CE & STOCK.xlsx", sheet = "DCoVaR_Pre")
dcovar1_pre <- Data$VNI
dcovar2_pre <- Data$SET
dcovar3_pre <- Data$PSE
dcovar4_pre <- Data$JCI
dcovar5_pre <- Data$KLCI
dcovar6_pre <- Data$SGXL
Data <- read_excel("C:/Users/84896/Desktop/2018 - 2024 CE & STOCK.xlsx", sheet = "DCoVaR_Dur")
dcovar1_dur <- Data$VNI
dcovar2_dur <- Data$SET
dcovar3_dur <- Data$PSE
dcovar4_dur <- Data$JCI
dcovar5_dur <- Data$KLCI
dcovar6_dur <- Data$SGXL
Data <- read_excel("C:/Users/84896/Desktop/2018 - 2024 CE & STOCK.xlsx", sheet = "DCoVaR_War")
dcovar1_war <- Data$VNI
dcovar2_war <- Data$SET
dcovar3_war <- Data$PSE
dcovar4_war <- Data$JCI
dcovar5_war <- Data$KLCI
dcovar6_war <- Data$SGXL
plr <- cbind(dcovar1, dcovar2, dcovar3, dcovar4, dcovar5, dcovar6)
plot.ts(plr) # VẼ ĐỒ THỊ DCOVAR TRONG CẢ GIAI ĐOẠN

#### KIỂM ĐỊNH K-S TEST TỪNG GIAI ĐOẠN ###
# NOTE: "GREATER" = phân phối biên của x nằm trên phân phối biên của y => x âm hơn y
zero1 <- rep(0, length(dcovar1_pre)) # Ký hiệu "pre" => trước COVID
zero2 <- rep(0, length(dcovar1_dur)) # Ký hiệu "dur" => trong COVID
zero3 <- rep(0, length(dcovar1_war)) # Ký hiệu "war" => chiến tranh
ks.test(dcovar1_pre,zero1, alternative="greater")
## Warning in ks.test(dcovar1_pre, zero1, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar1_pre and zero1
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar2_pre,zero1, alternative="greater")
## Warning in ks.test(dcovar2_pre, zero1, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar2_pre and zero1
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar3_pre,zero1, alternative="greater")
## Warning in ks.test(dcovar3_pre, zero1, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar3_pre and zero1
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar4_pre,zero1, alternative="greater")
## Warning in ks.test(dcovar4_pre, zero1, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar4_pre and zero1
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar5_pre,zero1, alternative="greater")
## Warning in ks.test(dcovar5_pre, zero1, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar5_pre and zero1
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar6_pre,zero1, alternative="greater")
## Warning in ks.test(dcovar6_pre, zero1, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar6_pre and zero1
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar1_dur,zero2, alternative="greater")
## Warning in ks.test(dcovar1_dur, zero2, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar1_dur and zero2
## D^+ = 0.94495, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar2_dur,zero2, alternative="greater")
## Warning in ks.test(dcovar2_dur, zero2, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar2_dur and zero2
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar3_dur,zero2, alternative="greater")
## Warning in ks.test(dcovar3_dur, zero2, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar3_dur and zero2
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar4_dur,zero2, alternative="greater")
## Warning in ks.test(dcovar4_dur, zero2, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar4_dur and zero2
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar5_dur,zero2, alternative="greater")
## Warning in ks.test(dcovar5_dur, zero2, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar5_dur and zero2
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar6_dur,zero2, alternative="greater")
## Warning in ks.test(dcovar6_dur, zero2, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar6_dur and zero2
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar1_war,zero3, alternative="greater")
## Warning in ks.test(dcovar1_war, zero3, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar1_war and zero3
## D^+ = 0.97002, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar2_war,zero3, alternative="greater")
## Warning in ks.test(dcovar2_war, zero3, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar2_war and zero3
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar3_war,zero3, alternative="greater")
## Warning in ks.test(dcovar3_war, zero3, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar3_war and zero3
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar4_war,zero3, alternative="greater")
## Warning in ks.test(dcovar4_war, zero3, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar4_war and zero3
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar5_war,zero3, alternative="greater")
## Warning in ks.test(dcovar5_war, zero3, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar5_war and zero3
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y
ks.test(dcovar6_war,zero3, alternative="greater")
## Warning in ks.test(dcovar6_war, zero3, alternative = "greater"): cannot compute
## correct p-values with ties
##
## Two-sample Kolmogorov-Smirnov test
##
## data: dcovar6_war and zero3
## D^+ = 1, p-value < 2.2e-16
## alternative hypothesis: the CDF of x lies above that of y