library(readxl)
library(rugarch)
## Loading required package: parallel
## 
## Attaching package: 'rugarch'
## The following object is masked from 'package:stats':
## 
##     sigma
library(goftest)
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()
## ✖ purrr::reduce() masks rugarch::reduce()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(tseries)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(VineCopula)
library(ggplot2)

Tương quan và kiểm định

data <- read_excel("D:/nckh/data/datareturn.xlsx")
#đọc dữ liệu vô ní 
cor(data[, c("BTC", "ETH")], method = "pearson")
##           BTC       ETH
## BTC 1.0000000 0.8350036
## ETH 0.8350036 1.0000000
cor(data[, c("BTC", "ETH")], method = "spearman")
##           BTC       ETH
## BTC 1.0000000 0.8214125
## ETH 0.8214125 1.0000000
cor(data[, c("BTC", "ETH")], method = "kendall")
##           BTC       ETH
## BTC 1.0000000 0.6466008
## ETH 0.6466008 1.0000000
ggplot(data, aes(x = DATE, y= BTC))+
  geom_line()+
  labs(title = "BTC",x = "Ngày", y="Độ biến động")+
  theme(plot.title = element_text(hjust = 0.5))

ggplot(data, aes(x = DATE, y= ETH))+
  geom_line()+
  labs(title = "ETH",x = "Ngày", y="Độ biến động")+
  theme(plot.title = element_text(hjust = 0.5))

library(moments)
# mô tả thống kê ETH 
data %>% summarise(Min = min(ETH),
            Max = max(ETH),
            Mean = mean(ETH),
            StDev = sd(ETH),
            Skewness = skewness(ETH),
            Kurtosis = kurtosis(ETH))
## # A tibble: 1 × 6
##     Min   Max   Mean StDev Skewness Kurtosis
##   <dbl> <dbl>  <dbl> <dbl>    <dbl>    <dbl>
## 1 -59.0  23.1 0.0395  5.17    -1.09     14.6
# mô tả thống kê BTC
data %>% summarise(Min = min(BTC),
            Max = max(BTC),
            Mean = mean(BTC),
            StDev = sd(BTC),
            Skewness = skewness(BTC),
            Kurtosis = kurtosis(BTC))
## # A tibble: 1 × 6
##     Min   Max   Mean StDev Skewness Kurtosis
##   <dbl> <dbl>  <dbl> <dbl>    <dbl>    <dbl>
## 1 -48.1  17.9 0.0289  3.95    -1.13     16.9
#kiểm định  BTC 
adf.test(data$BTC)
## Warning in adf.test(data$BTC): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  data$BTC
## Dickey-Fuller = -11.443, Lag order = 12, p-value = 0.01
## alternative hypothesis: stationary
jarque.bera.test(data$BTC)
## 
##  Jarque Bera Test
## 
## data:  data$BTC
## X-squared = 15311, df = 2, p-value < 2.2e-16
Box.test(data$BTC, lag = 2, type = "Ljung-Box")
## 
##  Box-Ljung test
## 
## data:  data$BTC
## X-squared = 13.545, df = 2, p-value = 0.001145
Box.test(data$BTC, lag = 2, type = "Box-Pierce")
## 
##  Box-Pierce test
## 
## data:  data$BTC
## X-squared = 13.52, df = 2, p-value = 0.001159
#ETH 

adf.test(data$ETH)
## Warning in adf.test(data$ETH): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  data$ETH
## Dickey-Fuller = -11.375, Lag order = 12, p-value = 0.01
## alternative hypothesis: stationary
jarque.bera.test(data$ETH)
## 
##  Jarque Bera Test
## 
## data:  data$ETH
## X-squared = 10694, df = 2, p-value < 2.2e-16
Box.test(data$ETH, lag = 2, type = "Ljung-Box")
## 
##  Box-Ljung test
## 
## data:  data$ETH
## X-squared = 19.556, df = 2, p-value = 5.669e-05
Box.test(data$ETH, lag = 2, type = "Box-Pierce")
## 
##  Box-Pierce test
## 
## data:  data$ETH
## X-squared = 19.52, df = 2, p-value = 5.773e-05

GARCH V

autoarfima(data$BTC,ar.max = 2, ma.max = 2,criterion = "AIC", method = "full")$fit
## 
## *----------------------------------*
## *          ARFIMA Model Fit        *
## *----------------------------------*
## Mean Model   : ARFIMA(2,0,1)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##        Estimate  Std. Error  t value Pr(>|t|)
## ar1    0.000000          NA       NA       NA
## ar2    0.051643    0.023276   2.2187 0.026505
## ma1   -0.067608    0.023294  -2.9024 0.003703
## sigma  3.932104    0.064556  60.9098 0.000000
## 
## Robust Standard Errors:
##        Estimate  Std. Error  t value Pr(>|t|)
## ar1    0.000000          NA       NA       NA
## ar2    0.051643    0.024829   2.0799 0.037531
## ma1   -0.067608    0.030535  -2.2141 0.026821
## sigma  3.932104    0.182365  21.5618 0.000000
## 
## LogLikelihood : -5171.95 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       5.5795
## Bayes        5.5884
## Shibata      5.5795
## Hannan-Quinn 5.5828
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                     0.00194  0.9649
## Lag[2*(p+q)+(p+q)-1][8]    1.93237  1.0000
## Lag[4*(p+q)+(p+q)-1][14]   3.72316  0.9845
## 
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      3.697 0.05452
## Lag[2*(p+q)+(p+q)-1][2]     3.751 0.08797
## Lag[4*(p+q)+(p+q)-1][5]     6.957 0.05314
## 
## 
## ARCH LM Tests
## ------------------------------------
##              Statistic DoF P-Value
## ARCH Lag[2]      3.765   2 0.15225
## ARCH Lag[5]     11.641   5 0.04005
## ARCH Lag[10]    19.237  10 0.03735
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  0.495
## Individual Statistics:             
## ar2   0.10226
## ma1   0.08025
## sigma 0.32241
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          0.846 1.01 1.35
## Individual Statistic:     0.35 0.47 0.75
## 
## 
## Elapsed time : 0.04775715
autoarfima(data$ETH,ar.max = 2, ma.max = 2,criterion = "AIC", method = "full")$fit
## 
## *----------------------------------*
## *          ARFIMA Model Fit        *
## *----------------------------------*
## Mean Model   : ARFIMA(2,0,1)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##        Estimate  Std. Error  t value Pr(>|t|)
## ar1     0.55326    0.201287   2.7486 0.005985
## ar2     0.10816    0.023326   4.6369 0.000004
## ma1    -0.63255    0.203120  -3.1142 0.001845
## sigma   5.13498    0.084305  60.9097 0.000000
## 
## Robust Standard Errors:
##        Estimate  Std. Error  t value Pr(>|t|)
## ar1     0.55326    0.207405   2.6675 0.007641
## ar2     0.10816    0.029176   3.7072 0.000210
## ma1    -0.63255    0.205392  -3.0797 0.002072
## sigma   5.13498    0.270933  18.9529 0.000000
## 
## LogLikelihood : -5667.051 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       6.1143
## Bayes        6.1263
## Shibata      6.1143
## Hannan-Quinn 6.1187
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                     0.02941  0.8638
## Lag[2*(p+q)+(p+q)-1][8]    2.19808  1.0000
## Lag[4*(p+q)+(p+q)-1][14]   7.24943  0.5113
## 
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      11.10 8.645e-04
## Lag[2*(p+q)+(p+q)-1][2]     11.23 9.047e-04
## Lag[4*(p+q)+(p+q)-1][5]     20.08 1.842e-05
## 
## 
## ARCH LM Tests
## ------------------------------------
##              Statistic DoF   P-Value
## ARCH Lag[2]      11.02   2 4.044e-03
## ARCH Lag[5]      31.55   5 7.295e-06
## ARCH Lag[10]     37.21  10 5.215e-05
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  0.3883
## Individual Statistics:             
## ar1   0.03509
## ar2   0.09584
## ma1   0.03305
## sigma 0.21643
## 
## 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.04064798
###GARCH 11 
#NORM 

btc.garch11n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "norm")
btc.garch11n.fit <- ugarchfit(spec = btc.garch11n.spec, data = data$BTC)
#STD 

btc.garch11t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "std")
btc.garch11t.fit <- ugarchfit(spec = btc.garch11t.spec, data= data$BTC)
##sstd

btc.garch11st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "sstd")
btc.garch11st.fit <- ugarchfit(spec = btc.garch11st.spec, data = data$BTC)

##ged 
btc.garch11g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "ged")
btc.garch11g.fit <- ugarchfit(spec = btc.garch11g.spec, data = data$BTC)

#sged 
btc.garch11sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "sged") 
btc.garch11sg.fit <- ugarchfit(spec = btc.garch11sg.spec, data =  data$BTC)
##garch(1,2)

# GARCH(1,2) with NORM distribution
btc.garch12n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "norm")
btc.garch12n.fit <- ugarchfit(spec = btc.garch12n.spec, data = data$BTC)

# GARCH(1,2) with STD distribution
btc.garch12t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "std")
btc.garch12t.fit <- ugarchfit(spec = btc.garch12t.spec, data = data$BTC)

# GARCH(1,2) with SSTD distribution
btc.garch12st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sstd")
btc.garch12st.fit <- ugarchfit(spec = btc.garch12st.spec, data = data$BTC)

# GARCH(1,2) with GED distribution
btc.garch12g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "ged")
btc.garch12g.fit <- ugarchfit(spec = btc.garch12g.spec, data = data$BTC)

# GARCH(1,2) with SGED distribution
btc.garch12sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sged")
btc.garch12sg.fit <- ugarchfit(spec = btc.garch12sg.spec, data = data$BTC)
#GARCH 21 


# GARCH(2,1) with NORM distribution
btc.garch21n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "norm")
btc.garch21n.fit <- ugarchfit(spec = btc.garch21n.spec, data = data$BTC)

# GARCH(2,1) with STD distribution
btc.garch21t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "std")
btc.garch21t.fit <- ugarchfit(spec = btc.garch21t.spec, data = data$BTC)

# GARCH(2,1) with SSTD distribution
btc.garch21st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sstd")
btc.garch21st.fit <- ugarchfit(spec = btc.garch21st.spec, data = data$BTC)

# GARCH(2,1) with GED distribution
btc.garch21g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "ged")
btc.garch21g.fit <- ugarchfit(spec = btc.garch21g.spec, data = data$BTC)

# GARCH(2,1) with SGED distribution
btc.garch21sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sged")
btc.garch21sg.fit <- ugarchfit(spec = btc.garch21sg.spec, data = data$BTC)
#GARCH 22 


# GARCH(2,2) with NORM distribution and ARMA(2,1)
btc.garch22n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "norm")
btc.garch22n.fit <- ugarchfit(spec = btc.garch22n.spec, data = data$BTC)

# GARCH(2,2) with STD distribution and ARMA(2,1)
btc.garch22t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "std")
btc.garch22t.fit <- ugarchfit(spec = btc.garch22t.spec, data = data$BTC)

# GARCH(2,2) with SSTD distribution and ARMA(2,1)
btc.garch22st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sstd")
btc.garch22st.fit <- ugarchfit(spec = btc.garch22st.spec, data = data$BTC)

# GARCH(2,2) with GED distribution and ARMA(2,1)
btc.garch22g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "ged")
btc.garch22g.fit <- ugarchfit(spec = btc.garch22g.spec, data = data$BTC)

# GARCH(2,2) with SGED distribution and ARMA(2,1)
btc.garch22sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sged")
btc.garch22sg.fit <- ugarchfit(spec = btc.garch22sg.spec, data = data$BTC)

CHỌN MÔ HÌNH BTC

btc.model.list <- list(garch11n = btc.garch11n.fit, garch11t = btc.garch11t.fit, garch11st = btc.garch11st.fit, garch11g = btc.garch11g.fit, garch11sg = btc.garch11sg.fit,
garch12n = btc.garch12n.fit, garch12t = btc.garch12t.fit, garch12st = btc.garch12st.fit, garch12g = 
btc.garch12g.fit, garch12sg = btc.garch12sg.fit,
garch21n = btc.garch21n.fit, garch21t = btc.garch21t.fit, garch21st = btc.garch21st.fit, garch21g = 
btc.garch21g.fit, garch21sg = btc.garch21sg.fit,
garch22n = btc.garch22n.fit, garch22t = btc.garch22t.fit, garch22st = btc.garch22st.fit, garch22g = 
btc.garch22g.fit, garch22sg = btc.garch22sg.fit)
btc.info.mat <- sapply(btc.model.list, infocriteria)
rownames(btc.info.mat) <- rownames(infocriteria(btc.garch11n.fit))
btc.info.mat
##              garch11n garch11t garch11st garch11g garch11sg garch12n garch12t
## Akaike       5.497814 5.260249  5.261170 5.263723  5.264580 5.498892 5.261029
## Bayes        5.521645 5.287058  5.290957 5.290532  5.294368 5.525701 5.290817
## Shibata      5.497777 5.260202  5.261112 5.263677  5.264523 5.498846 5.260971
## Hannan-Quinn 5.506598 5.270130  5.272149 5.273605  5.275560 5.508774 5.272008
##              garch12st garch12g garch12sg garch21n garch21t garch21st garch21g
## Akaike        5.261925 5.264373  5.265328 5.498362 5.259547  5.260545 5.263696
## Bayes         5.294692 5.294161  5.298094 5.528150 5.292314  5.296290 5.296463
## Shibata       5.261856 5.264316  5.265258 5.498304 5.259477  5.260462 5.263626
## Hannan-Quinn  5.274003 5.275353  5.277405 5.509341 5.271624  5.273720 5.275773
##              garch21sg garch22n garch22t garch22st garch22g garch22sg
## Akaike        5.264723 5.499440 5.260625  5.261623 5.264821  5.265797
## Bayes         5.300468 5.532207 5.296371  5.300347 5.300566  5.304521
## Shibata       5.264640 5.499370 5.260542  5.261525 5.264738  5.265700
## Hannan-Quinn  5.277898 5.511517 5.273800  5.275896 5.277996  5.280070
btc.inds <- which(btc.info.mat == min(btc.info.mat), arr.ind=TRUE)
model.btc <- colnames(btc.info.mat)[btc.inds[,2]]
model.btc
## [1] "garch21t"
btc.garch21t.fit
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(2,1)
## Mean Model   : ARFIMA(2,0,1)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.094507    0.057211  1.65190 0.098555
## ar1     0.125511    0.595380  0.21081 0.833037
## ar2     0.032668    0.040824  0.80021 0.423588
## ma1    -0.188052    0.595791 -0.31563 0.752280
## omega   0.172159    0.122519  1.40516 0.159974
## alpha1  0.016661    0.029510  0.56459 0.572351
## alpha2  0.066135    0.033252  1.98889 0.046714
## beta1   0.925372    0.017862 51.80654 0.000000
## gamma1  0.114086    0.061736  1.84797 0.064607
## gamma2 -0.132424    0.061129 -2.16630 0.030289
## shape   3.210383    0.222968 14.39838 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.094507    0.055903  1.69056 0.090921
## ar1     0.125511    0.362723  0.34603 0.729324
## ar2     0.032668    0.030919  1.05655 0.290717
## ma1    -0.188052    0.359810 -0.52264 0.601223
## omega   0.172159    0.199092  0.86472 0.387190
## alpha1  0.016661    0.029338  0.56791 0.570097
## alpha2  0.066135    0.033015  2.00317 0.045159
## beta1   0.925372    0.025536 36.23814 0.000000
## gamma1  0.114086    0.064126  1.77909 0.075225
## gamma2 -0.132424    0.067882 -1.95081 0.051080
## shape   3.210383    0.213301 15.05097 0.000000
## 
## LogLikelihood : -4867.23 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       5.2595
## Bayes        5.2923
## Shibata      5.2595
## Hannan-Quinn 5.2716
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                       5.325 2.102e-02
## Lag[2*(p+q)+(p+q)-1][8]      9.340 3.904e-10
## Lag[4*(p+q)+(p+q)-1][14]    11.495 4.083e-02
## d.o.f=3
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                     0.01779  0.8939
## Lag[2*(p+q)+(p+q)-1][8]    1.97755  0.8623
## Lag[4*(p+q)+(p+q)-1][14]   2.72734  0.9690
## d.o.f=3
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[4]     2.067 0.500 2.000  0.1505
## ARCH Lag[6]     2.232 1.461 1.711  0.4418
## ARCH Lag[8]     2.329 2.368 1.583  0.6749
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  4.8561
## Individual Statistics:              
## mu     0.13673
## ar1    0.07998
## ar2    0.36941
## ma1    0.06251
## omega  0.34649
## alpha1 0.47602
## alpha2 0.57143
## beta1  0.36317
## gamma1 0.51094
## gamma2 0.55695
## shape  0.35809
## 
## 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.49272 0.1357    
## Negative Sign Bias 0.06678 0.9468    
## Positive Sign Bias 1.42768 0.1536    
## Joint Effect       3.03923 0.3856    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     30.49      0.04591
## 2    30     35.97      0.17443
## 3    40     54.15      0.05405
## 4    50     59.85      0.13773
## 
## 
## Elapsed time : 1.22368
btc.res <- residuals(btc.garch21t.fit)/sigma(btc.garch21t.fit)
 fitdist(distribution = "std", btc.res, control = list())$pars
##            mu         sigma         shape 
## -0.0004689593  1.1224293088  2.8131536722
 v <- pdist(distribution = "std", q = btc.res, mu = -0.0004689593 , sigma = 1.1224293088, shape = 2.8131536722)

GARCH ETH

###GARCH 11 
#NORM 

eth.garch11n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "norm")
eth.garch11n.fit <- ugarchfit(spec = eth.garch11n.spec, data = data$ETH)
#STD 

eth.garch11t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "std")
eth.garch11t.fit <- ugarchfit(spec = eth.garch11t.spec, data= data$ETH)
##sstd

eth.garch11st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "sstd")
eth.garch11st.fit <- ugarchfit(spec = eth.garch11st.spec, data = data$ETH)

##ged 
eth.garch11g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "ged")
eth.garch11g.fit <- ugarchfit(spec = eth.garch11g.spec, data = data$ETH)

#sged 
eth.garch11sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 1), include.mean = TRUE), distribution.model = "sged") 
eth.garch11sg.fit <- ugarchfit(spec = eth.garch11sg.spec, data =  data$ETH)
##garch(1,2)

# GARCH(1,2) with NORM distribution
eth.garch12n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "norm")
eth.garch12n.fit <- ugarchfit(spec = eth.garch12n.spec, data = data$ETH)

# GARCH(1,2) with STD distribution
eth.garch12t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "std")
eth.garch12t.fit <- ugarchfit(spec = eth.garch12t.spec, data = data$ETH)

# GARCH(1,2) with SSTD distribution
eth.garch12st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sstd")
eth.garch12st.fit <- ugarchfit(spec = eth.garch12st.spec, data = data$ETH)

# GARCH(1,2) with GED distribution
eth.garch12g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "ged")
eth.garch12g.fit <- ugarchfit(spec = eth.garch12g.spec, data = data$ETH)

# GARCH(1,2) with SGED distribution
eth.garch12sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sged")
eth.garch12sg.fit <- ugarchfit(spec = eth.garch12sg.spec, data = data$ETH)
# GARCH(2,1) with NORM distribution
eth.garch21n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "norm")
eth.garch21n.fit <- ugarchfit(spec = eth.garch21n.spec, data = data$ETH)

# GARCH(2,1) with STD distribution
eth.garch21t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "std")
eth.garch21t.fit <- ugarchfit(spec = eth.garch21t.spec, data = data$ETH)

# GARCH(2,1) with SSTD distribution
eth.garch21st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sstd")
eth.garch21st.fit <- ugarchfit(spec = eth.garch21st.spec, data = data$ETH)

# GARCH(2,1) with GED distribution
eth.garch21g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "ged")
eth.garch21g.fit <- ugarchfit(spec = eth.garch21g.spec, data = data$ETH)

# GARCH(2,1) with SGED distribution
eth.garch21sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sged")
eth.garch21sg.fit <- ugarchfit(spec = eth.garch21sg.spec, data = data$ETH)

##GARCH 22 

# GARCH(2,2) with NORM distribution
eth.garch22n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "norm")
eth.garch22n.fit <- ugarchfit(spec = eth.garch22n.spec, data = data$ETH)

# GARCH(2,2) with STD distribution
eth.garch22t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "std")
eth.garch22t.fit <- ugarchfit(spec = eth.garch22t.spec, data = data$ETH)

# GARCH(2,2) with SSTD distribution
eth.garch22st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sstd")
eth.garch22st.fit <- ugarchfit(spec = eth.garch22st.spec, data = data$ETH)

# GARCH(2,2) with GED distribution
eth.garch22g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                 mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                 distribution.model = "ged")
eth.garch22g.fit <- ugarchfit(spec = eth.garch22g.spec, data = data$ETH)

# GARCH(2,2) with SGED distribution
eth.garch22sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
                                  mean.model = list(armaOrder = c(2, 1), include.mean = TRUE),
                                  distribution.model = "sged")
eth.garch22sg.fit <- ugarchfit(spec = eth.garch22sg.spec, data = data$ETH)

CHỌN MÔ HÌNH ETH

eth.model.list <- list(garch11n = eth.garch11n.fit, garch11t = eth.garch11t.fit, garch11st = eth.garch11st.fit, garch11g = eth.garch11g.fit, garch11sg = eth.garch11sg.fit,
                       garch12n = eth.garch12n.fit, garch12t = eth.garch12t.fit, garch12st = eth.garch12st.fit, garch12g = eth.garch12g.fit, garch12sg = eth.garch12sg.fit,
                       garch21n = eth.garch21n.fit, garch21t = eth.garch21t.fit, garch21st = eth.garch21st.fit, garch21g = eth.garch21g.fit, garch21sg = eth.garch21sg.fit,
                       garch22n = eth.garch22n.fit, garch22t = eth.garch22t.fit, garch22st = eth.garch22st.fit, garch22g = eth.garch22g.fit, garch22sg = eth.garch22sg.fit)

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

rownames(eth.info.mat) <- rownames(infocriteria(eth.garch11n.fit))
eth.info.mat
##              garch11n garch11t garch11st garch11g garch11sg garch12n garch12t
## Akaike       6.032872 5.872167  5.873086 5.872511  5.871646 6.033950 5.873245
## Bayes        6.056702 5.898976  5.902874 5.899320  5.901433 6.060759 5.903033
## Shibata      6.032835 5.872120  5.873028 5.872464  5.871588 6.033903 5.873187
## Hannan-Quinn 6.041655 5.882048  5.884065 5.882392  5.882625 6.043831 5.884224
##              garch12st garch12g garch12sg garch21n garch21t garch21st garch21g
## Akaike        5.874164 5.873590  5.872723 6.031311 5.871234  5.872232 5.871492
## Bayes         5.906931 5.903377  5.905490 6.061098 5.904001  5.907977 5.904259
## Shibata       5.874095 5.873532  5.872654 6.031253 5.871164  5.872149 5.871422
## Hannan-Quinn  5.886241 5.884569  5.884800 6.042290 5.883311  5.885407 5.883569
##              garch21sg garch22n garch22t garch22st garch22g garch22sg
## Akaike        5.871993 6.032389 5.872312  5.873310 5.872570  5.873071
## Bayes         5.907738 6.065155 5.908058  5.912034 5.908315  5.911795
## Shibata       5.871910 6.032319 5.872229  5.873213 5.872487  5.872974
## Hannan-Quinn  5.885168 6.044466 5.885487  5.887583 5.885745  5.887344
eth.inds <- which(eth.info.mat == min(eth.info.mat), arr.ind=TRUE)
model.eth <- colnames(eth.info.mat)[eth.inds[,2]]
model.eth
## [1] "garch21t"
eth.garch21t.fit
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(2,1)
## Mean Model   : ARFIMA(2,0,1)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error   t value Pr(>|t|)
## mu      0.143356    0.097159   1.47548 0.140084
## ar1     0.839171    0.007515 111.66816 0.000000
## ar2     0.099756    0.021141   4.71854 0.000002
## ma1    -0.932963    0.022409 -41.63254 0.000000
## omega   1.919940    0.738241   2.60070 0.009303
## alpha1  0.013148    0.037572   0.34995 0.726378
## alpha2  0.115818    0.047854   2.42022 0.015511
## beta1   0.823755    0.044177  18.64658 0.000000
## gamma1  0.148043    0.075247   1.96741 0.049136
## gamma2 -0.147651    0.076393  -1.93279 0.053262
## shape   3.461593    0.317580  10.89991 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error    t value Pr(>|t|)
## mu      0.143356    0.101173    1.41695 0.156498
## ar1     0.839171    0.020649   40.63889 0.000000
## ar2     0.099756    0.018985    5.25460 0.000000
## ma1    -0.932963    0.007313 -127.58436 0.000000
## omega   1.919940    0.945342    2.03095 0.042260
## alpha1  0.013148    0.037180    0.35364 0.723608
## alpha2  0.115818    0.045601    2.53982 0.011091
## beta1   0.823755    0.054225   15.19137 0.000000
## gamma1  0.148043    0.084448    1.75307 0.079590
## gamma2 -0.147651    0.090231   -1.63637 0.101762
## shape   3.461593    0.324129   10.67969 0.000000
## 
## LogLikelihood : -5434.569 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       5.8712
## Bayes        5.9040
## Shibata      5.8712
## Hannan-Quinn 5.8833
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                        9.72 1.823e-03
## Lag[2*(p+q)+(p+q)-1][8]      16.63 0.000e+00
## Lag[4*(p+q)+(p+q)-1][14]     19.98 9.020e-06
## d.o.f=3
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                      0.2313  0.6306
## Lag[2*(p+q)+(p+q)-1][8]     5.3799  0.3038
## Lag[4*(p+q)+(p+q)-1][14]    7.2364  0.4756
## d.o.f=3
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[4]     5.786 0.500 2.000 0.01616
## ARCH Lag[6]     5.941 1.461 1.711 0.06957
## ARCH Lag[8]     6.097 2.368 1.583 0.15315
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  2.6243
## Individual Statistics:              
## mu     0.42614
## ar1    0.09409
## ar2    0.22568
## ma1    0.11586
## omega  0.22336
## alpha1 0.27720
## alpha2 0.28511
## beta1  0.28792
## gamma1 0.38098
## gamma2 0.35243
## shape  0.55476
## 
## 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.42811 0.1534    
## Negative Sign Bias 0.91458 0.3605    
## Positive Sign Bias 0.04783 0.9619    
## Joint Effect       2.97648 0.3953    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     32.71      0.02597
## 2    30     40.92      0.06999
## 3    40     53.89      0.05669
## 4    50     61.68      0.10546
## 
## 
## Elapsed time : 1.580666
eth.res <- residuals(eth.garch21t.fit)/sigma(eth.garch21t.fit)
 fitdist(distribution = "std", eth.res, control = list())$pars
##           mu        sigma        shape 
## 0.0009551004 1.0110046149 3.3988135082
 u <- pdist(distribution = "std", q = eth.res, mu = 0.0009551004 , sigma = 1.0110046149, shape = 3.3988135082)
ad.test(u, "punif")
## 
##  Anderson-Darling test of goodness-of-fit
##  Null hypothesis: uniform distribution
##  Parameters assumed to be fixed
## 
## data:  u
## An = 0.64479, p-value = 0.6067
ad.test(v, "punif")
## 
##  Anderson-Darling test of goodness-of-fit
##  Null hypothesis: uniform distribution
##  Parameters assumed to be fixed
## 
## data:  v
## An = 0.67779, p-value = 0.5776
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.1085, p-value = 0.5448
cvm.test(u, "punif")
## 
##  Cramer-von Mises test of goodness-of-fit
##  Null hypothesis: uniform distribution
##  Parameters assumed to be fixed
## 
## data:  u
## omega2 = 0.083103, p-value = 0.6742
 ks.test(v, "punif")
## 
##  Asymptotic one-sample Kolmogorov-Smirnov test
## 
## data:  v
## D = 0.017586, p-value = 0.6147
## alternative hypothesis: two-sided
 ks.test(u, "punif")
## 
##  Asymptotic one-sample Kolmogorov-Smirnov test
## 
## data:  u
## D = 0.016902, p-value = 0.6643
## alternative hypothesis: two-sided

#CHẠY COPULA

## phù hợp nhất 
BiCopSelect(u, v, familyset= 1:9, selectioncrit="AIC",indeptest = FALSE, level = 0.05)
## Bivariate copula: Survival BB1 (par = 0.08, par2 = 2.72, tau = 0.65)
Stu <- BiCopEst(u, v, family = 7, method = "mle", se = T, max.df = 10)
summary(Stu)
## Family
## ------ 
## No:    7
## Name:  BB1
## 
## Parameter(s)
## ------------
## par:  1.26  (SE = 0.09)
## par2: 1.68  (SE = 0.06)
## Dependence measures
## -------------------
## Kendall's tau:    0.64 (empirical = 0.65, p value < 0.01)
## Upper TD:         0.49 
## Lower TD:         0.72 
## 
## Fit statistics
## --------------
## logLik:  1210.84 
## AIC:    -2417.69 
## BIC:    -2406.64
# gau 
gaus <- BiCopEst(u, v, family = 1, method = "mle", se = T, max.df = 10)
summary(gaus)
## Family
## ------ 
## No:    1
## Name:  Gaussian
## 
## Parameter(s)
## ------------
## par:  0.83  (SE = 0.01)
## 
## Dependence measures
## -------------------
## Kendall's tau:    0.63 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  1104.56 
## AIC:    -2207.12 
## BIC:    -2201.59
stud <- BiCopEst(u, v, family = 2, method = "mle", se = T, max.df = 10)
summary(stud)
## Family
## ------ 
## No:    2
## Name:  t
## 
## Parameter(s)
## ------------
## par:  0.85  (SE = 0.01)
## par2: 3.67  (SE = 0.41)
## Dependence measures
## -------------------
## Kendall's tau:    0.64 (empirical = 0.65, p value < 0.01)
## Upper TD:         0.56 
## Lower TD:         0.56 
## 
## Fit statistics
## --------------
## logLik:  1190.49 
## AIC:    -2376.98 
## BIC:    -2365.93
clay <- BiCopEst(u, v, family = 3, method = "mle", se = T, max.df = 10)
summary(clay)
## Family
## ------ 
## No:    3
## Name:  Clayton
## 
## Parameter(s)
## ------------
## par:  2.8  (SE = 0.08)
## 
## Dependence measures
## -------------------
## Kendall's tau:    0.58 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0.78 
## 
## Fit statistics
## --------------
## logLik:  1109.16 
## AIC:    -2216.31 
## BIC:    -2210.79
rotclay <- BiCopEst(u, v, family = 23, method = "mle", se = T, max.df = 10)
summary(rotclay)
## Family
## ------ 
## No:    23
## Name:  Rotated Clayton 90 degrees
## 
## Parameter(s)
## ------------
## par:  0  (SE = 0.07)
## 
## Dependence measures
## -------------------
## Kendall's tau:    0 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  -0.17 
## AIC:    2.33 
## BIC:    7.86
gum <- BiCopEst(u, v, family = 4, method = "mle", se = T, max.df = 10)
summary(gum)
## Family
## ------ 
## No:    4
## Name:  Gumbel
## 
## Parameter(s)
## ------------
## par:  2.53  (SE = 0.05)
## 
## Dependence measures
## -------------------
## Kendall's tau:    0.6 (empirical = 0.65, p value < 0.01)
## Upper TD:         0.68 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  1005.12 
## AIC:    -2008.24 
## BIC:    -2002.71
rotgum <- BiCopEst(u, v, family = 24, method = "mle", se = T, max.df = 10)
summary(rotgum)
## Family
## ------ 
## No:    24
## Name:  Rotated Gumbel 90 degrees
## 
## Parameter(s)
## ------------
## par:  -1  (SE = 0.03)
## 
## Dependence measures
## -------------------
## Kendall's tau:    0 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  -0.29 
## AIC:    2.59 
## BIC:    8.11
Frank <- BiCopEst(u, v, family = 5, method = "mle", se = T, max.df = 10)
summary(Frank)
## Family
## ------ 
## No:    5
## Name:  Frank
## 
## Parameter(s)
## ------------
## par:  9.51  (SE = 0.24)
## 
## Dependence measures
## -------------------
## Kendall's tau:    0.65 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  1092.75 
## AIC:    -2183.5 
## BIC:    -2177.98
Joe <- BiCopEst(u, v, family = 6, method = "mle", se = T, max.df = 10)
summary(Joe)
## Family
## ------ 
## No:    6
## Name:  Joe
## 
## Parameter(s)
## ------------
## par:  2.77  (SE = 0.06)
## 
## Dependence measures
## -------------------
## Kendall's tau:    0.49 (empirical = 0.65, p value < 0.01)
## Upper TD:         0.72 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  716.8 
## AIC:    -1431.6 
## BIC:    -1426.07
RotJoe <- BiCopEst(u, v, family = 26, method = "mle", se = T, max.df = 10)
summary(RotJoe)
## Family
## ------ 
## No:    26
## Name:  Rotated Joe 90 degrees
## 
## Parameter(s)
## ------------
## par:  -1  (SE = 0.03)
## 
## Dependence measures
## -------------------
## Kendall's tau:    0 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  -0.17 
## AIC:    2.33 
## BIC:    7.86
# cái bb1 là phù hợp nhất phần ở trên  

rotbb1 <- BiCopEst(u, v, family = 27, method = "mle", se = T, max.df = 10)
## [1] "The rotated BB1 copulas cannot be used for positively dependent data."
summary(rotbb1)
## Family
## ------ 
## No:    27
## Name:  Rotated BB1 90 degrees
## 
## Parameter(s)
## ------------
## par:  0  (SE = NaN)
## par2: -1  (SE = 0.03)
## Dependence measures
## -------------------
## Kendall's tau:    0 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  -2.92 
## AIC:    9.83 
## BIC:    20.89
BB6 <- BiCopEst(u, v, family = 8, method = "mle", se = T, max.df = 10)
summary(BB6)
## Family
## ------ 
## No:    8
## Name:  BB6
## 
## Parameter(s)
## ------------
## par:  1  (SE = NaN)
## par2: 2.52  (SE = NaN)
## Dependence measures
## -------------------
## Kendall's tau:    0.6 (empirical = 0.65, p value < 0.01)
## Upper TD:         0.68 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  1004.92 
## AIC:    -2005.84 
## BIC:    -1994.79
rotbb6 <- BiCopEst(u, v, family = 28, method = "mle", se = T, max.df = 10)
## [1] "The rotated BB6 copulas cannot be used for positively dependent data."
summary(rotbb6)
## Family
## ------ 
## No:    28
## Name:  Rotated BB6 90 degrees
## 
## Parameter(s)
## ------------
## par:  -1  (SE = NaN)
## par2: -1  (SE = NaN)
## Dependence measures
## -------------------
## Kendall's tau:    0 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  -2.91 
## AIC:    9.82 
## BIC:    20.87
BB7 <- BiCopEst(u, v, family = 9, method = "mle", se = T, max.df = 10)
summary(BB7)
## Family
## ------ 
## No:    9
## Name:  BB7
## 
## Parameter(s)
## ------------
## par:  1.84  (SE = 0.07)
## par2: 2.5  (SE = 0.1)
## Dependence measures
## -------------------
## Kendall's tau:    0.6 (empirical = 0.65, p value < 0.01)
## Upper TD:         0.54 
## Lower TD:         0.76 
## 
## Fit statistics
## --------------
## logLik:  1176.67 
## AIC:    -2349.33 
## BIC:    -2338.28
BB7r <- BiCopEst(u, v, family = 29, method = "mle", se = T, max.df = 10)
## [1] "The rotated BB7 copulas cannot be used for positively dependent data."
summary(BB7r)
## Family
## ------ 
## No:    29
## Name:  Rotated BB7 90 degrees
## 
## Parameter(s)
## ------------
## par:  -1  (SE = NaN)
## par2: 0  (SE = NaN)
## Dependence measures
## -------------------
## Kendall's tau:    0 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  -2.02 
## AIC:    8.04 
## BIC:    19.1
BB8 <- BiCopEst(u, v, family = 10, method = "mle", se = T, max.df = 10)
summary(BB8)
## Family
## ------ 
## No:    10
## Name:  BB8
## 
## Parameter(s)
## ------------
## par:  6  (SE = 0.33)
## par2: 0.78  (SE = 0.02)
## Dependence measures
## -------------------
## Kendall's tau:    0.58 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  962.82 
## AIC:    -1921.64 
## BIC:    -1910.59
RBB8 <- BiCopEst(u, v, family = 30, method = "mle", se = T, max.df = 10)
## [1] "The rotated BB8 copulas cannot be used for positively dependent data."
summary(RBB8)
## Family
## ------ 
## No:    30
## Name:  Rotated BB8 90 degrees
## 
## Parameter(s)
## ------------
## par:  -1  (SE = NaN)
## par2: 0  (SE = NaN)
## Dependence measures
## -------------------
## Kendall's tau:    0 (empirical = 0.65, p value < 0.01)
## Upper TD:         0 
## Lower TD:         0 
## 
## Fit statistics
## --------------
## logLik:  0 
## AIC:    4 
## BIC:    15.05