GARCH
#GARCH(1,1)_VNI
vni.garch11n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "norm")
vni.garch11n.fit <- ugarchfit(spec = vni.garch11n.spec, data = dl[,2])
show(vni.garch11n.fit )
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : gjrGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000111 0.000672 1487.5039 0.000000
## ar1 0.665137 0.235883 2.8198 0.004806
## ma1 -0.592563 0.232215 -2.5518 0.010717
## omega 0.000009 0.000000 59.7726 0.000000
## alpha1 0.019597 0.007329 2.6738 0.007501
## beta1 0.847365 0.010845 78.1370 0.000000
## gamma1 0.143301 0.025344 5.6542 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000111 0.001582 632.3517 0.000000
## ar1 0.665137 0.464942 1.4306 0.152550
## ma1 -0.592563 0.428318 -1.3835 0.166522
## omega 0.000009 0.000000 36.5158 0.000000
## alpha1 0.019597 0.011324 1.7305 0.083540
## beta1 0.847365 0.023408 36.1997 0.000000
## gamma1 0.143301 0.039278 3.6484 0.000264
##
## LogLikelihood : 4424.805
##
## Information Criteria
## ------------------------------------
##
## Akaike -6.0684
## Bayes -6.0430
## Shibata -6.0685
## Hannan-Quinn -6.0589
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.2200 0.6391
## Lag[2*(p+q)+(p+q)-1][5] 0.2908 1.0000
## Lag[4*(p+q)+(p+q)-1][9] 0.7027 1.0000
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.0272 0.8690
## Lag[2*(p+q)+(p+q)-1][5] 0.3809 0.9744
## Lag[4*(p+q)+(p+q)-1][9] 1.1996 0.9764
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.4864 0.500 2.000 0.4855
## ARCH Lag[5] 0.6060 1.440 1.667 0.8520
## ARCH Lag[7] 0.8389 2.315 1.543 0.9383
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 28.5762
## Individual Statistics:
## mu 0.17643
## ar1 0.18842
## ma1 0.18887
## omega 5.25357
## alpha1 0.09718
## beta1 0.08105
## gamma1 0.05971
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.3841 0.7010
## Negative Sign Bias 0.3324 0.7396
## Positive Sign Bias 1.2250 0.2208
## Joint Effect 4.2623 0.2345
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 111.0 5.324e-15
## 2 30 134.2 1.811e-15
## 3 40 153.6 1.575e-15
## 4 50 162.9 3.795e-14
##
##
## Elapsed time : 0.5587609
vni.garch11t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "std")
vni.garch11t.fit <- ugarchfit(spec = vni.garch11t.spec, data = dl[, 2])
show(vni.garch11t.fit)
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : gjrGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.001005 0.001278 783.3167 0.000000
## ar1 0.719397 0.327646 2.1957 0.028117
## ma1 -0.664103 0.311647 -2.1309 0.033093
## omega 0.000013 0.000001 25.5935 0.000000
## alpha1 0.022415 0.046562 0.4814 0.630233
## beta1 0.759282 0.023167 32.7736 0.000000
## gamma1 0.289742 0.087077 3.3274 0.000877
## shape 3.901376 0.452746 8.6171 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.001005 0.006841 146.314595 0.000000
## ar1 0.719397 1.510334 0.476316 0.633849
## ma1 -0.664103 1.351009 -0.491561 0.623030
## omega 0.000013 0.000001 12.506058 0.000000
## alpha1 0.022415 0.236158 0.094914 0.924383
## beta1 0.759282 0.022827 33.262912 0.000000
## gamma1 0.289742 0.370594 0.781831 0.434314
## shape 3.901376 1.597491 2.442189 0.014598
##
## LogLikelihood : 4522.391
##
## Information Criteria
## ------------------------------------
##
## Akaike -6.2011
## Bayes -6.1721
## Shibata -6.2011
## Hannan-Quinn -6.1903
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.02966 0.8633
## Lag[2*(p+q)+(p+q)-1][5] 0.16886 1.0000
## Lag[4*(p+q)+(p+q)-1][9] 0.49349 1.0000
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.036 0.3088
## Lag[2*(p+q)+(p+q)-1][5] 2.117 0.5910
## Lag[4*(p+q)+(p+q)-1][9] 3.054 0.7501
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 1.166 0.500 2.000 0.2801
## ARCH Lag[5] 1.422 1.440 1.667 0.6129
## ARCH Lag[7] 1.503 2.315 1.543 0.8207
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 41.7646
## Individual Statistics:
## mu 0.2333
## ar1 0.2087
## ma1 0.1965
## omega 9.0004
## alpha1 0.2084
## beta1 0.2111
## gamma1 0.1748
## shape 0.2109
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.89 2.11 2.59
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.3019 0.76274
## Negative Sign Bias 0.8814 0.37823
## Positive Sign Bias 1.7846 0.07453 *
## Joint Effect 4.0660 0.25443
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 35.84 0.0110412
## 2 30 54.38 0.0029211
## 3 40 73.95 0.0006136
## 4 50 83.77 0.0014496
##
##
## Elapsed time : 0.7100089
vni.garch11st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "sstd")
vni.garch11st.fit <- ugarchfit(spec = vni.garch11st.spec, data = dl[, 2])
show(vni.garch11st.fit)
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : gjrGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000264 0.000279 3582.3203 0.000000
## ar1 0.930879 0.048835 19.0616 0.000000
## ma1 -0.900299 0.062192 -14.4760 0.000000
## omega 0.000011 0.000000 24.4197 0.000000
## alpha1 0.025853 0.012891 2.0055 0.044912
## beta1 0.792915 0.019233 41.2274 0.000000
## gamma1 0.243466 0.048216 5.0494 0.000000
## skew 0.836503 0.028443 29.4098 0.000000
## shape 4.288637 0.436064 9.8349 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000264 0.000365 2737.4034 0.000000
## ar1 0.930879 0.060099 15.4892 0.000000
## ma1 -0.900299 0.074218 -12.1305 0.000000
## omega 0.000011 0.000001 18.1466 0.000000
## alpha1 0.025853 0.014215 1.8186 0.068966
## beta1 0.792915 0.017740 44.6973 0.000000
## gamma1 0.243466 0.049432 4.9252 0.000001
## skew 0.836503 0.030467 27.4560 0.000000
## shape 4.288637 0.418969 10.2362 0.000000
##
## LogLikelihood : 4534.214
##
## Information Criteria
## ------------------------------------
##
## Akaike -6.2160
## Bayes -6.1833
## Shibata -6.2160
## Hannan-Quinn -6.2038
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.292 0.2557
## Lag[2*(p+q)+(p+q)-1][5] 1.634 0.9945
## Lag[4*(p+q)+(p+q)-1][9] 2.177 0.9758
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.8592 0.3540
## Lag[2*(p+q)+(p+q)-1][5] 1.9570 0.6286
## Lag[4*(p+q)+(p+q)-1][9] 3.0046 0.7582
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 1.197 0.500 2.000 0.2739
## ARCH Lag[5] 1.496 1.440 1.667 0.5933
## ARCH Lag[7] 1.586 2.315 1.543 0.8040
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 43.2216
## Individual Statistics:
## mu 0.18228
## ar1 0.18077
## ma1 0.19057
## omega 9.47558
## alpha1 0.16663
## beta1 0.17405
## gamma1 0.11933
## skew 0.09849
## shape 0.15482
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.1 2.32 2.82
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.5779 0.5634
## Negative Sign Bias 1.0718 0.2840
## Positive Sign Bias 1.4164 0.1569
## Joint Effect 4.3477 0.2263
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 35.70 0.0114765
## 2 30 49.03 0.0114712
## 3 40 62.57 0.0096871
## 4 50 86.38 0.0007833
##
##
## Elapsed time : 9.016754
vni.garch11g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "ged")
vni.garch11g.fit <- ugarchfit(spec = vni.garch11g.spec, data = dl[, 2])
show(vni.garch11g.fit)
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : gjrGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : ged
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.001025 0.000715 1400.1793 0.000000
## ar1 0.909700 0.015946 57.0478 0.000000
## ma1 -0.883610 0.020378 -43.3607 0.000000
## omega 0.000011 0.000000 31.7820 0.000000
## alpha1 0.023010 0.014979 1.5361 0.124513
## beta1 0.794615 0.019142 41.5109 0.000000
## gamma1 0.203300 0.044047 4.6155 0.000004
## shape 1.072843 0.049190 21.8101 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.001025 0.002138 468.20394 0.000000
## ar1 0.909700 0.028486 31.93468 0.000000
## ma1 -0.883610 0.044115 -20.02949 0.000000
## omega 0.000011 0.000000 25.92415 0.000000
## alpha1 0.023010 0.023329 0.98633 0.323970
## beta1 0.794615 0.024818 32.01779 0.000000
## gamma1 0.203300 0.047195 4.30766 0.000016
## shape 1.072843 0.067527 15.88769 0.000000
##
## LogLikelihood : 4517.522
##
## Information Criteria
## ------------------------------------
##
## Akaike -6.1944
## Bayes -6.1654
## Shibata -6.1945
## Hannan-Quinn -6.1836
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.171 0.2793
## Lag[2*(p+q)+(p+q)-1][5] 1.520 0.9976
## Lag[4*(p+q)+(p+q)-1][9] 2.022 0.9836
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.5708 0.4500
## Lag[2*(p+q)+(p+q)-1][5] 1.3184 0.7844
## Lag[4*(p+q)+(p+q)-1][9] 2.2034 0.8794
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.9098 0.500 2.000 0.3402
## ARCH Lag[5] 1.0762 1.440 1.667 0.7104
## ARCH Lag[7] 1.1677 2.315 1.543 0.8848
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 37.8862
## Individual Statistics:
## mu 0.2094
## ar1 0.1819
## ma1 0.2070
## omega 9.4917
## alpha1 0.1882
## beta1 0.1437
## gamma1 0.1369
## shape 0.1316
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.89 2.11 2.59
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.1435 0.8859
## Negative Sign Bias 0.4160 0.6775
## Positive Sign Bias 1.6272 0.1039
## Joint Effect 3.3146 0.3456
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 49.30 1.659e-04
## 2 30 63.78 2.045e-04
## 3 40 70.54 1.468e-03
## 4 50 113.02 5.715e-07
##
##
## Elapsed time : 1.099863
vni.garch11sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "sged")
vni.garch11sg.fit <- ugarchfit(spec = vni.garch11sg.spec, data = dl[, 2])
#GARCH(1,2)_VNI
vni.garch12n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "norm")
vni.garch12n.fit <- ugarchfit(spec = vni.garch12n.spec, data = dl[,2])
vni.garch12t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "std")
vni.garch12t.fit <- ugarchfit(spec = vni.garch12t.spec, data = dl[, 2])
show(vni.garch12t.fit)
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : gjrGARCH(1,2)
## Mean Model : ARFIMA(1,0,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000994 0.001551 645.38452 0.000000
## ar1 0.714380 0.401676 1.77850 0.075322
## ma1 -0.658274 0.379472 -1.73471 0.082792
## omega 0.000014 0.000001 26.13715 0.000000
## alpha1 0.022502 0.087835 0.25619 0.797808
## beta1 0.619948 0.145308 4.26645 0.000020
## beta2 0.120112 0.132297 0.90790 0.363934
## gamma1 0.315382 0.119164 2.64663 0.008130
## shape 3.924783 0.407975 9.62015 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000994 0.011038 90.685899 0.000000
## ar1 0.714380 2.577869 0.277120 0.781688
## ma1 -0.658274 2.340261 -0.281282 0.778494
## omega 0.000014 0.000004 3.189466 0.001425
## alpha1 0.022502 0.608593 0.036974 0.970506
## beta1 0.619948 0.217627 2.848670 0.004390
## beta2 0.120112 0.195018 0.615899 0.537961
## gamma1 0.315382 0.731983 0.430860 0.666570
## shape 3.924783 1.290143 3.042131 0.002349
##
## LogLikelihood : 4522.849
##
## Information Criteria
## ------------------------------------
##
## Akaike -6.2003
## Bayes -6.1677
## Shibata -6.2004
## Hannan-Quinn -6.1882
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.02483 0.8748
## Lag[2*(p+q)+(p+q)-1][5] 0.16530 1.0000
## Lag[4*(p+q)+(p+q)-1][9] 0.48293 1.0000
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.297 0.2547
## Lag[2*(p+q)+(p+q)-1][8] 2.766 0.7283
## Lag[4*(p+q)+(p+q)-1][14] 5.888 0.6538
## d.o.f=3
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[4] 0.2477 0.500 2.000 0.6187
## ARCH Lag[6] 0.3187 1.461 1.711 0.9405
## ARCH Lag[8] 1.4749 2.368 1.583 0.8443
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 40.177
## Individual Statistics:
## mu 0.2387
## ar1 0.2067
## ma1 0.1955
## omega 5.3938
## alpha1 0.2016
## beta1 0.1989
## beta2 0.2089
## gamma1 0.1709
## shape 0.2124
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.1 2.32 2.82
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.3345 0.73808
## Negative Sign Bias 0.9959 0.31946
## Positive Sign Bias 1.7746 0.07618 *
## Joint Effect 4.1810 0.24257
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 37.21 0.0074593
## 2 30 63.45 0.0002256
## 3 40 73.78 0.0006406
## 4 50 88.23 0.0005000
##
##
## Elapsed time : 0.799232
vni.garch12st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "sstd")
vni.garch12st.fit <- ugarchfit(spec = vni.garch12st.spec, data = dl[, 2])
vni.garch12g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "ged")
vni.garch12g.fit <- ugarchfit(spec = vni.garch12g.spec, data = dl[, 2])
vni.garch12sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "sged")
vni.garch12sg.fit <- ugarchfit(spec = vni.garch12sg.spec, data = dl[, 2])
#GARCH(2.1)_VNI
vni.garch21n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.mode
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "norm")
vni.garch21n.fit <- ugarchfit(spec = vni.garch21n.spec, data = dl[,2])
vni.garch21t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "std")
vni.garch21t.fit <- ugarchfit(spec = vni.garch21t.spec, data = dl[, 2])
vni.garch21st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "sstd")
vni.garch21st.fit <- ugarchfit(spec = vni.garch21st.spec, data = dl[, 2])
vni.garch21g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "ged")
vni.garch21g.fit <- ugarchfit(spec = vni.garch21g.spec, data = dl[, 2])
vni.garch21sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "sged")
vni.garch21sg.fit <- ugarchfit(spec = vni.garch21sg.spec, data = dl[, 2])
#GARCH(2,2)_VNI
vni.garch22n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "norm")
vni.garch22n.fit <- ugarchfit(spec = vni.garch22n.spec, data = dl[,2])
vni.garch22t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "std")
vni.garch22t.fit <- ugarchfit(spec = vni.garch22t.spec, data = dl[, 2])
vni.garch22st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "sstd")
vni.garch22st.fit <- ugarchfit(spec = vni.garch22st.spec, data = dl[, 2])
vni.garch22g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "ged")
vni.garch22g.fit <- ugarchfit(spec = vni.garch22g.spec, data = dl[, 2])
vni.garch22sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(1, 1), include.mean = TRUE), distribution.model = "sged")
vni.garch22sg.fit <- ugarchfit(spec = vni.garch22sg.spec, data = dl[, 2])
# Các dạng MH GJR-GARCH cho chuỗi sp500
## GJR-GARCH(11)SP500
sp500.garch11n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch11n.fit <- ugarchfit(spec = sp500.garch11n.spec, data = dl[,3])
sp500.garch11t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch11t.fit <- ugarchfit(spec =sp500.garch11t.spec, data = dl[, 3])
sp500.garch11st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch11st.fit <- ugarchfit(spec = sp500.garch11st.spec, data = dl[, 3])
sp500.garch11g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch11g.fit <- ugarchfit(spec =sp500.garch11g.spec, data = dl[, 3])
sp500.garch11sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch11sg.fit <- ugarchfit(spec = sp500.garch11sg.spec, data = dl[, 3])
## GJR-GARCH(12)sp500
sp500.garch12n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch12n.fit <- ugarchfit(spec = sp500.garch12n.spec, data = dl[,3])
sp500.garch12t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch12t.fit <- ugarchfit(spec = sp500.garch12t.spec, data = dl[, 3])
sp500.garch12st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch12st.fit <- ugarchfit(spec = sp500.garch12st.spec, data = dl[, 3])
sp500.garch12g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = "ged")
sp500.garch12g.fit <- ugarchfit(spec = sp500.garch12g.spec, data = dl[, 3])
sp500.garch12sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch12sg.fit <- ugarchfit(spec = sp500.garch12sg.spec, data = dl[, 3])
## GJR-GARCH(21)sp500
sp500.garch21n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch21n.fit <- ugarchfit(spec = sp500.garch21n.spec, data = dl[, 3])
sp500.garch21t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch21t.fit <- ugarchfit(spec = sp500.garch21t.spec, data = dl[, 3])
sp500.garch21st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch21st.fit <- ugarchfit(spec = sp500.garch21st.spec, data = dl[, 3])
sp500.garch21g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch21g.fit <- ugarchfit(spec =sp500.garch21g.spec, data = dl[, 3])
sp500.garch21sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch21sg.fit <- ugarchfit(spec = sp500.garch21sg.spec, data = dl[, 3])
## GJR-GARCH(22)SP500
sp500.garch22n.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch22n.fit <- ugarchfit(spec = sp500.garch22n.spec, data = dl[, 3])
sp500.garch22t.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch22t.fit <- ugarchfit(spec = sp500.garch22t.spec, data = dl[, 3])
sp500.garch22st.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch22st.fit <- ugarchfit(spec = sp500.garch22st.spec, data = dl[, 3])
sp500.garch22g.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch22g.fit <- ugarchfit(spec = sp500.garch22g.spec, data = dl[, 3])
sp500.garch22sg.spec <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch22sg.fit <- ugarchfit(spec =sp500.garch22sg.spec, data = dl[, 3])
LỰA CHỌN MÔ HÌNH BIÊN PHÙ HỢP
# Lựa chọn mô hình biên phù hợp nhất cho chuỗi VNI
vni.model.list <- list(garch11n = vni.garch11n.fit, garch11t = vni.garch11t.fit, garch11st = vni.garch11st.fit,
garch11g = vni.garch11g.fit, garch11sg = vni.garch11sg.fit,
garch12n = vni.garch12n.fit, garch12t = vni.garch12t.fit, garch12st = vni.garch12st.fit, garch12g =
vni.garch12g.fit, garch12sg = vni.garch12sg.fit,
garch21n = vni.garch21n.fit, garch21t = vni.garch21t.fit, garch21st = vni.garch21st.fit, garch21g =
vni.garch21g.fit, garch21sg = vni.garch21sg.fit,
garch22n = vni.garch22n.fit, garch22t = vni.garch22t.fit, garch22st = vni.garch22st.fit, garch22g =
vni.garch22g.fit, garch22sg = vni.garch22sg.fit)
vni.info.mat <- sapply(vni.model.list, infocriteria)
rownames(vni.info.mat) <- rownames(infocriteria(vni.garch11n.fit))
vni.info.mat
## garch11n garch11t garch11st garch11g garch11sg garch12n
## Akaike -6.068413 -6.201087 -6.215953 -6.194398 -6.211257 -6.068398
## Bayes -6.043012 -6.172057 -6.183295 -6.165368 -6.178598 -6.039368
## Shibata -6.068459 -6.201147 -6.216029 -6.194458 -6.211332 -6.068458
## Hannan-Quinn -6.058936 -6.190256 -6.203769 -6.183567 -6.199072 -6.057567
## garch12t garch12st garch12g garch12sg garch21n garch21t
## Akaike -6.200342 -6.215487 -6.193576 -6.210640 -6.073841 -6.201058
## Bayes -6.167683 -6.179200 -6.160917 -6.174352 -6.041182 -6.164770
## Shibata -6.200418 -6.215581 -6.193651 -6.210733 -6.073917 -6.201151
## Hannan-Quinn -6.188157 -6.201949 -6.181391 -6.197101 -6.061656 -6.187519
## garch21st garch21g garch21sg garch22n garch22t garch22st
## Akaike -6.215822 -6.194634 -6.211688 -6.072468 -6.199684 -6.214448
## Bayes -6.175905 -6.158347 -6.171772 -6.036180 -6.159768 -6.170903
## Shibata -6.215935 -6.194727 -6.211801 -6.072561 -6.199797 -6.214582
## Hannan-Quinn -6.200929 -6.181095 -6.196796 -6.058929 -6.184792 -6.198202
## garch22g garch22sg
## Akaike -6.193260 -6.210314
## Bayes -6.153344 -6.166769
## Shibata -6.193373 -6.210449
## Hannan-Quinn -6.178368 -6.194068
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] "garch11st"
# Lựa chọn mô hình biên phù hợp nhất cho chuỗi sp500
sp500.model.list <- list(garch11n = sp500.garch11n.fit, garch11t = sp500.garch11t.fit, garch11st =
sp500.garch11st.fit, garch11g = sp500.garch11g.fit, garch11sg = sp500.garch11sg.fit,
garch12n = sp500.garch12n.fit, garch12t = sp500.garch12t.fit, garch12st = sp500.garch12st.fit,
garch12g = sp500.garch12g.fit, garch12sg = sp500.garch12sg.fit,
garch21n = sp500.garch21n.fit, garch21t = sp500.garch21t.fit, garch21st = sp500.garch21st.fit,
garch21g = sp500.garch21g.fit, garch21sg = sp500.garch21sg.fit,
garch22n = sp500.garch22n.fit, garch22t =sp500.garch22t.fit, garch22st = sp500.garch22st.fit,
garch22g = sp500.garch22g.fit, garch22sg = sp500.garch22sg.fit)
sp500.info.mat <- sapply(sp500.model.list, infocriteria)
rownames(sp500.info.mat) <- rownames(infocriteria(sp500.garch11n.fit))
sp500.info.mat
## garch11n garch11t garch11st garch11g garch11sg garch12n
## Akaike -4.531249 -4.685160 -4.750474 -4.649937 -4.731633 -4.531520
## Bayes -4.498590 -4.648873 -4.710558 -4.613649 -4.691717 -4.495233
## Shibata -4.531325 -4.685253 -4.750587 -4.650030 -4.731746 -4.531614
## Hannan-Quinn -4.519064 -4.671621 -4.735582 -4.636398 -4.716740 -4.517982
## garch12t garch12st garch12g garch12sg garch21n garch21t
## Akaike -4.683226 -4.749101 -4.648563 -4.728687 -4.533647 -4.686150
## Bayes -4.643310 -4.705556 -4.608647 -4.685142 -4.493731 -4.642605
## Shibata -4.683339 -4.749235 -4.648676 -4.728822 -4.533760 -4.686284
## Hannan-Quinn -4.668334 -4.732854 -4.633671 -4.712441 -4.518755 -4.669904
## garch21st garch21g garch21sg garch22n garch22t garch22st
## Akaike -4.751333 -4.650871 -4.732770 -4.536538 -4.685296 -4.749960
## Bayes -4.704160 -4.607327 -4.685596 -4.492993 -4.638123 -4.699157
## Shibata -4.751491 -4.651006 -4.732927 -4.536672 -4.685454 -4.750142
## Hannan-Quinn -4.733733 -4.634625 -4.715170 -4.520291 -4.667696 -4.731006
## garch22g garch22sg
## Akaike -4.649655 -4.731396
## Bayes -4.602482 -4.680594
## Shibata -4.649813 -4.731579
## Hannan-Quinn -4.632055 -4.712442
sp500.inds <- which(sp500.info.mat == min(sp500.info.mat), arr.ind = TRUE)
model.sp500 <- colnames(sp500.info.mat)[sp500.inds[,2]]
model.sp500
## [1] "garch21st"
#ƯỚC LƯỢNG MÔ HÌNH BIẾN
### THAM SỐ ƯỚC LƯỢNG MÔ HÌNH BIÊN PHÙ HỢP NHẤT:
extract_garch_results <- function(fit) {
coef <- coef(fit)
se <- fit@fit$se.coef
pvalues <- 2 * (1 - pnorm(abs(fit@fit$tval))) # tính giá trị p từ giá trị t
results <- cbind(coef, se, pvalues)
colnames(results) <- c("Estimate", "Std. Error", "Pr(>|z|)")
return(results)
}
library(kableExtra)
fit1 <- extract_garch_results(vni.garch11st.fit)
kable(as.data.frame(fit1),
caption = "Bảng 5: Kết quả mô hình ARMA(1,1)-GJR-Garch(1,1)-Skewed Student của biến VNI",
format = 'pandoc') %>% kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = F)
## Warning in kable_styling(., bootstrap_options = c("striped", "hover",
## "condensed"), : Please specify format in kable. kableExtra can customize either
## HTML or LaTeX outputs. See https://haozhu233.github.io/kableExtra/ for details.
Bảng 5: Kết quả mô hình ARMA(1,1)-GJR-Garch(1,1)-Skewed Student
của biến VNI
| mu |
1.0002636 |
0.0002792 |
0.0000000 |
| ar1 |
0.9308793 |
0.0488353 |
0.0000000 |
| ma1 |
-0.9002987 |
0.0621923 |
0.0000000 |
| omega |
0.0000105 |
0.0000004 |
0.0000000 |
| alpha1 |
0.0258526 |
0.0128910 |
0.0449120 |
| beta1 |
0.7929153 |
0.0192327 |
0.0000000 |
| gamma1 |
0.2434658 |
0.0482163 |
0.0000004 |
| skew |
0.8365026 |
0.0284430 |
0.0000000 |
| shape |
4.2886371 |
0.4360637 |
0.0000000 |
extract_garch_results <- function(fit) {
coef <- coef(fit)
se <- fit@fit$se.coef
pvalues <- 2 * (1 - pnorm(abs(fit@fit$tval))) # tính giá trị p từ giá trị t
results <- cbind(coef, se, pvalues)
colnames(results) <- c("Estimate", "Std. Error", "Pr(>|z|)")
return(results)
}
fit1 <- extract_garch_results(sp500.garch21st.fit)
kable(as.data.frame(fit1),
caption = "Bảng 5: Kết quả mô hình ARMA(2,2)-GJR-Garch(2,1)-Skewed Student của biến VNI",
format = 'pandoc') %>% kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = F)
## Warning in kable_styling(., bootstrap_options = c("striped", "hover",
## "condensed"), : Please specify format in kable. kableExtra can customize either
## HTML or LaTeX outputs. See https://haozhu233.github.io/kableExtra/ for details.
Bảng 5: Kết quả mô hình ARMA(2,2)-GJR-Garch(2,1)-Skewed Student
của biến VNI
| mu |
0.9993791 |
0.0003429 |
0.0000000 |
| ar1 |
0.3678745 |
0.0576473 |
0.0000000 |
| ar2 |
0.5546145 |
0.0309664 |
0.0000000 |
| ma1 |
-0.4093224 |
0.0582344 |
0.0000000 |
| ma2 |
-0.5373071 |
0.0415071 |
0.0000000 |
| omega |
0.0000811 |
0.0000144 |
0.0000000 |
| alpha1 |
0.1782402 |
0.0538989 |
0.0009432 |
| alpha2 |
0.1437518 |
0.0652052 |
0.0274817 |
| beta1 |
0.6761241 |
0.0394507 |
0.0000000 |
| gamma1 |
0.0042258 |
0.0860512 |
0.9608331 |
| gamma2 |
-0.2101218 |
0.0770761 |
0.0064076 |
| skew |
1.4546350 |
0.0520990 |
0.0000000 |
| shape |
4.8257809 |
0.5920977 |
0.0000000 |
| # KIỂM ĐỊ |
NH SỰ PHÙ HỢP |
CỦA MÔ HÌNH |
BIÊN |
## Trích xuất chuỗi phần dư v của chuỗi lợi suất S&P500
sp500.res <- residuals(sp500.garch21st.fit)/sigma(sp500.garch21st.fit)
fitdist(distribution = "sstd", sp500.res, control = list())$pars
## mu sigma skew shape
## 0.007560442 0.999048157 1.460140356 4.891704011
v <- pdist(distribution = "sstd", q = sp500.res, mu =0.007560442 , sigma = 0.999048157, skew = 1.460140356, shape = 4.891704011 )
## Trích xuất chuỗi phần dư u của chuỗi lợi suất VNI
vni.res <- residuals(vni.garch11st.fit)/sigma(vni.garch11st.fit)
fitdist(distribution = "sstd", vni.res, control = list())$pars
## mu sigma skew shape
## -0.001894329 1.004416729 0.835631546 4.249451143
u = pdist(distribution ="sstd",vni.res, mu = -0.001894329 , sigma =1.004416729 , skew =0.835631546 , shape = 4.249451143 )
### Các kiểm định sự phù hợp của mô hình biên:
# Kiem dinh Anderson-Darling
library(nortest)
library(goftest)
ad.test(u,"punif")
##
## Anderson-Darling test of goodness-of-fit
## Null hypothesis: uniform distribution
## Parameters assumed to be fixed
##
## data: u
## An = 0.80976, p-value = 0.474
ad.test(v, "punif")
##
## Anderson-Darling test of goodness-of-fit
## Null hypothesis: uniform distribution
## Parameters assumed to be fixed
##
## data: v
## An = 0.17138, p-value = 0.9963
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.15514, p-value = 0.3743
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.018096, p-value = 0.9984
# Kiem dinh ks-test
ks.test(u, "punif")
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: u
## D = 0.030072, p-value = 0.1436
## alternative hypothesis: two-sided
ks.test(v, "punif")
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: v
## D = 0.010015, p-value = 0.9986
## alternative hypothesis: two-sided
#Ước lượng
library(VineCopula)
gau <- BiCopEst(u,v,family = 1, method = "mle", se = T, max.df = 10)
stu <- BiCopEst(u,v,family = 2, method = "mle", se = T, max.df = 10)
#Trình bày kết quả
est <- data.frame(mqh = c('VNI-SP500' ,'VNI-SP500'),
Copula = c('Gauss', 'Student'),
Thamso = c(gau$par, stu$par),
Thamso2 = c(gau$par2, stu$par2),
duoi = c(gau$taildep$lower,stu$taildep$lower))
kable(est, caption = "Bảng 8: Kết quả ước lượng Copula họ Elip", col.names = c("Chỉ số","Copula", "Par","Par2", "Phụ thuộc đuôi"),
format = 'pandoc') %>% kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = F)
## Warning in kable_styling(., bootstrap_options = c("striped", "hover",
## "condensed"), : Please specify format in kable. kableExtra can customize either
## HTML or LaTeX outputs. See https://haozhu233.github.io/kableExtra/ for details.
Bảng 8: Kết quả ước lượng Copula họ Elip
| VNI-SP500 |
Gauss |
-0.0773425 |
0 |
0.0000000 |
| VNI-SP500 |
Student |
-0.0610718 |
10 |
0.0047501 |
library(VineCopula)
cop<-BiCopSelect(u, v, familyset= 1:9, selectioncrit="AIC",indeptest = FALSE, level = 0.05)
summary(cop)
## Family
## ------
## No: 26
## Name: Rotated Joe 90 degrees
##
## Parameter(s)
## ------------
## par: -1.07
##
## Dependence measures
## -------------------
## Kendall's tau: -0.04 (empirical = -0.03, p value = 0.05)
## Upper TD: 0
## Lower TD: 0
##
## Fit statistics
## --------------
## logLik: 10.52
## AIC: -19.03
## BIC: -13.75
Stu <- BiCopEst(u, v, family = 36, method = "mle", se = T, max.df = 10)
summary(Stu)
## Family
## ------
## No: 36
## Name: Rotated Joe 270 degrees
##
## Parameter(s)
## ------------
## par: -1.02 (SE = 0.01)
##
## Dependence measures
## -------------------
## Kendall's tau: -0.01 (empirical = -0.03, p value = 0.05)
## Upper TD: 0
## Lower TD: 0
##
## Fit statistics
## --------------
## logLik: 0.33
## AIC: 1.34
## BIC: 6.63
#Lựa chọn và ước lượng
opt_cop <- BiCopSelect(u,v,selectioncrit = "AIC",method = "mle")
est_opt_cop <- BiCopEst(u,v,family = opt_cop$family,method = "mle",max.df = 30)
#Trình bày kết quả
est_opt_cop_dt <- data.frame(mqh = c('VNI-Sp500'),
Copula = est_opt_cop$familyname,
Thamso = est_opt_cop$par,
Thamso2 = est_opt_cop$par2,
duoiduoi = est_opt_cop$taildep$lower,
duoitren = est_opt_cop$taildep$upper,
tau = est_opt_cop$tau,
aic = est_opt_cop$AIC,
bic = est_opt_cop$BIC)
kable(est_opt_cop_dt,
caption = "Bảng 9: Kết quả ước lượng mô hình Copula tối ưu", col.names = c("Chỉ số","Copula", "Par","Par2", "Đuôi dưới", "Đuôi trên","Hệ số Kendall", "AIC","BIC"),
format = 'pandoc') %>% kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = F)
## Warning in kable_styling(., bootstrap_options = c("striped", "hover",
## "condensed"), : Please specify format in kable. kableExtra can customize either
## HTML or LaTeX outputs. See https://haozhu233.github.io/kableExtra/ for details.
Bảng 9: Kết quả ước lượng mô hình Copula tối ưu
| VNI-Sp500 |
Rotated Joe 90 degrees |
-1.066832 |
0 |
0 |
0 |
-0.0371115 |
-19.03345 |
-13.75001 |
| # VẼ ĐỒ THÌ |
PDF |
|
|
|
|
|
|
|
library(copula)
library(png)
library(grid)
library(rgl)
library(VineCopula)
opt_cop <- BiCopSelect(u,v,selectioncrit = "AIC",method = "mle")
est_opt_cop <- BiCopEst(u,v,family = opt_cop$family,method = "mle",max.df = 30)
#Trình bày kết quả
est_opt_cop_dt <- data.frame(mqh = c('VNI-SP500'),
Copula = est_opt_cop$familyname,
Thamso = est_opt_cop$par,
Thamso2 = est_opt_cop$par2,
duoiduoi = est_opt_cop$taildep$lower,
duoitren = est_opt_cop$taildep$upper,
tau = est_opt_cop$tau,
aic = est_opt_cop$AIC,
bic = est_opt_cop$BIC)
kable(est_opt_cop_dt,
caption = "Bảng : Kết quả ước lượng mô hình Copula tối ưu", col.names = c("Chỉ số","Copula", "Par","Par2", "Đuôi dưới", "Đuôi trên","Hệ số Kendall", "AIC","BIC"),
format = 'html') %>% kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = F)
Bảng : Kết quả ước lượng mô hình Copula tối ưu
|
Chỉ số
|
Copula
|
Par
|
Par2
|
Đuôi dưới
|
Đuôi trên
|
Hệ số Kendall
|
AIC
|
BIC
|
|
VNI-SP500
|
Rotated Joe 90 degrees
|
-1.066832
|
0
|
0
|
0
|
-0.0371115
|
-19.03345
|
-13.75001
|
library(VC2copula)
copula <- r270JoeBiCopula(param = est_opt_cop$par)
# Sử dụng hàm persp để vẽ đồ thị 3D
persp(copula, dCopula, xlab = "u", ylab = "v",
main = "Đồ thị PDF của mô hình Rotated Joe 90 degrees",
col = "pink")
# VNI VÀ S&P500 TRONG 3 GIAI ĐOẠN
#Trích dữ liệu
library(xts)
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
##
## first, last
library(xlsx)
a1<- read.xlsx("D:/mhnn/vni.xlsx", sheetIndex=1, header=T)
a2<- read.xlsx("D:/mhnn/sp500.xlsx", sheetIndex=1, header=T)
vni<- xts(a1[,-1], order.by = a1$DATE)
sp500<-xts(a2[,-1], order.by = a2$DATE)
dlt <- merge.xts(vni,sp500,join = 'inner')
truoccov<- dlt["2018-01-03/2019-12-31"]
cov<- dlt["2020-01-02/2021-12-31"]
saucov<- dlt["2022-01-04/2023-12-29"]
ARMA
#arma vni trước covid
armavnitruoc<-autoarfima(truoccov$vni, ar.max = 2, ma.max = 2, criterion = "AIC", method = "full")$fit
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
armavnitruoc
##
## *----------------------------------*
## * ARFIMA Model Fit *
## *----------------------------------*
## Mean Model : ARFIMA(2,0,0)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000101 0.000561 1783.5809 0.000000
## ar1 0.000000 NA NA NA
## ar2 0.133571 0.045103 2.9615 0.003062
## sigma 0.010684 0.000344 31.0806 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000101 0.000560 1784.8187 0.000000
## ar1 0.000000 NA NA NA
## ar2 0.133571 0.062105 2.1507 0.031497
## sigma 0.010684 0.000518 20.6146 0.000000
##
## LogLikelihood : 1506.978
##
## Information Criteria
## ------------------------------------
##
## Akaike -6.2277
## Bayes -6.2017
## Shibata -6.2277
## Hannan-Quinn -6.2175
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.209 0.6475
## Lag[2*(p+q)+(p+q)-1][5] 1.744 0.9889
## Lag[4*(p+q)+(p+q)-1][9] 3.987 0.6941
##
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 18.63 1.583e-05
## Lag[2*(p+q)+(p+q)-1][2] 27.20 5.750e-08
## Lag[4*(p+q)+(p+q)-1][5] 43.86 3.642e-12
##
##
## ARCH LM Tests
## ------------------------------------
## Statistic DoF P-Value
## ARCH Lag[2] 29.61 2 3.711e-07
## ARCH Lag[5] 37.43 5 4.908e-07
## ARCH Lag[10] 47.21 10 8.630e-07
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 5.2943
## Individual Statistics:
## mu 0.07554
## ar2 0.10260
## sigma 4.72074
##
## 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.01867199
# arma vni trong covid
armavnitrong<-autoarfima(cov$vni, ar.max = 2, ma.max = 2, criterion = "AIC", method = "full")$fit
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
armavnitrong
##
## *----------------------------------*
## * ARFIMA Model Fit *
## *----------------------------------*
## Mean Model : ARFIMA(2,0,2)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.001286 0.000636 1575.0229 0.000000
## ar1 -0.063999 0.020774 -3.0808 0.002065
## ar2 -0.929639 0.003559 -261.2181 0.000000
## ma1 0.069458 0.006531 10.6345 0.000000
## ma2 0.994114 0.000019 51817.5202 0.000000
## sigma 0.013526 0.000429 31.5177 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.001286 0.000687 1456.4430 0.000000
## ar1 -0.063999 0.020313 -3.1507 0.001629
## ar2 -0.929639 0.007299 -127.3658 0.000000
## ma1 0.069458 0.006544 10.6141 0.000000
## ma2 0.994114 0.000023 43296.5530 0.000000
## sigma 0.013526 0.001215 11.1355 0.000000
##
## LogLikelihood : 1398.834
##
## Information Criteria
## ------------------------------------
##
## Akaike -5.7436
## Bayes -5.6919
## Shibata -5.7439
## Hannan-Quinn -5.7233
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.717 1.901e-01
## Lag[2*(p+q)+(p+q)-1][11] 11.274 9.418e-13
## Lag[4*(p+q)+(p+q)-1][19] 19.662 5.389e-04
##
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 21.86 2.933e-06
## Lag[2*(p+q)+(p+q)-1][2] 30.45 8.074e-09
## Lag[4*(p+q)+(p+q)-1][5] 47.73 2.838e-13
##
##
## ARCH LM Tests
## ------------------------------------
## Statistic DoF P-Value
## ARCH Lag[2] 31.92 2 1.174e-07
## ARCH Lag[5] 43.30 5 3.212e-08
## ARCH Lag[10] 62.56 10 1.187e-09
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 1.1756
## Individual Statistics:
## mu 0.10942
## ar1 0.01744
## ar2 0.06746
## ma1 0.06375
## ma2 0.07320
## sigma 0.69665
##
## 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.05071211
# arma vni sau covid
armavnisau<-autoarfima(saucov$vni, ar.max = 2, ma.max = 2, criterion = "AIC", method = "full")$fit
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
armavnisau
##
## *----------------------------------*
## * ARFIMA Model Fit *
## *----------------------------------*
## Mean Model : ARFIMA(0,0,1)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 0.999511 0.000646 1546.2723 0.00000
## ma1 0.055539 0.048034 1.1563 0.24757
## sigma 0.013474 0.000435 30.9999 0.00000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.999511 0.000637 1569.7906 0.00000
## ma1 0.055539 0.049075 1.1317 0.25775
## sigma 0.013474 0.000928 14.5203 0.00000
##
## LogLikelihood : 1398.987
##
## Information Criteria
## ------------------------------------
##
## Akaike -5.7685
## Bayes -5.7426
## Shibata -5.7686
## Hannan-Quinn -5.7584
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.003832 0.9506
## Lag[2*(p+q)+(p+q)-1][2] 0.612223 0.9316
## Lag[4*(p+q)+(p+q)-1][5] 1.152468 0.9215
##
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 8.282 4.004e-03
## Lag[2*(p+q)+(p+q)-1][2] 11.857 6.180e-04
## Lag[4*(p+q)+(p+q)-1][5] 31.909 9.155e-09
##
##
## ARCH LM Tests
## ------------------------------------
## Statistic DoF P-Value
## ARCH Lag[2] 13.58 2 1.123e-03
## ARCH Lag[5] 35.32 5 1.298e-06
## ARCH Lag[10] 47.38 10 8.046e-07
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 0.9941
## Individual Statistics:
## mu 0.19239
## ma1 0.03409
## sigma 0.90587
##
## 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.01100612
# arma sp500 trước covid
armasp500truoc<-autoarfima(truoccov$sp500, ar.max = 2, ma.max = 2, criterion = "AIC", method = "full")$fit
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
armasp500truoc
##
## *----------------------------------*
## * ARFIMA Model Fit *
## *----------------------------------*
## Mean Model : ARFIMA(2,0,2)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 0.999218 0.001032 967.9819 0.000000
## ar1 -0.124133 0.039990 -3.1041 0.001909
## ar2 -0.619908 0.152804 -4.0569 0.000050
## ma1 0.000000 NA NA NA
## ma2 0.595930 0.160142 3.7212 0.000198
## sigma 0.024787 0.000798 31.0805 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.999218 0.001034 966.1085 0.000000
## ar1 -0.124133 0.061917 -2.0048 0.044982
## ar2 -0.619908 0.141907 -4.3684 0.000013
## ma1 0.000000 NA NA NA
## ma2 0.595930 0.146334 4.0724 0.000047
## sigma 0.024787 0.001319 18.7885 0.000000
##
## LogLikelihood : 1100.517
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.5363
## Bayes -4.4930
## Shibata -4.5365
## Hannan-Quinn -4.5193
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.04199 0.8376
## Lag[2*(p+q)+(p+q)-1][11] 2.55172 1.0000
## Lag[4*(p+q)+(p+q)-1][19] 4.88224 0.9954
##
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 19.59 9.582e-06
## Lag[2*(p+q)+(p+q)-1][2] 34.81 5.855e-10
## Lag[4*(p+q)+(p+q)-1][5] 62.24 0.000e+00
##
##
## ARCH LM Tests
## ------------------------------------
## Statistic DoF P-Value
## ARCH Lag[2] 41.41 2 1.021e-09
## ARCH Lag[5] 52.75 5 3.792e-10
## ARCH Lag[10] 66.21 10 2.373e-10
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 0.5344
## Individual Statistics:
## mu 0.05408
## ar1 0.05007
## ar2 0.08869
## ma2 0.08351
## sigma 0.19840
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.28 1.47 1.88
## Individual Statistic: 0.35 0.47 0.75
##
##
## Elapsed time : 0.05162501
# arma sp500 trong covid
armasp500trong<-autoarfima(cov$sp500, ar.max = 2, ma.max = 2, criterion = "AIC", method = "full")$fit
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
armasp500trong
##
## *----------------------------------*
## * ARFIMA Model Fit *
## *----------------------------------*
## Mean Model : ARFIMA(2,0,2)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 0.999052 0.001566 638.1659 0.000000
## ar1 -0.080077 0.042141 -1.9002 0.057405
## ar2 -0.594859 0.166990 -3.5623 0.000368
## ma1 0.000000 NA NA NA
## ma2 0.665224 0.164120 4.0533 0.000051
## sigma 0.034677 0.001113 31.1448 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.999052 0.001568 637.0412 0.000000
## ar1 -0.080077 0.072115 -1.1104 0.266825
## ar2 -0.594859 0.227923 -2.6099 0.009057
## ma1 0.000000 NA NA NA
## ma2 0.665224 0.236606 2.8115 0.004931
## sigma 0.034677 0.002435 14.2430 0.000000
##
## LogLikelihood : 942.2264
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.8649
## Bayes -3.8217
## Shibata -3.8651
## Hannan-Quinn -3.8479
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.457 4.990e-01
## Lag[2*(p+q)+(p+q)-1][11] 10.511 3.113e-10
## Lag[4*(p+q)+(p+q)-1][19] 20.072 3.631e-04
##
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 19.74 8.884e-06
## Lag[2*(p+q)+(p+q)-1][2] 27.59 4.531e-08
## Lag[4*(p+q)+(p+q)-1][5] 119.37 0.000e+00
##
##
## ARCH LM Tests
## ------------------------------------
## Statistic DoF P-Value
## ARCH Lag[2] 29.24 2 4.476e-07
## ARCH Lag[5] 132.15 5 0.000e+00
## ARCH Lag[10] 163.47 10 0.000e+00
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 2.8091
## Individual Statistics:
## mu 0.16322
## ar1 0.06762
## ar2 0.02967
## ma2 0.03045
## sigma 2.17161
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.28 1.47 1.88
## Individual Statistic: 0.35 0.47 0.75
##
##
## Elapsed time : 0.05019999
# arma sp500 sau covid
armasp500sau<-autoarfima(saucov$sp500, ar.max = 2, ma.max = 2, criterion = "AIC", method = "full")$fit
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
## Warning in .makearfimafitmodel(f = .arfimaLLH, T = T, m = m, timer = timer, :
## rugarch-->warning: failed to invert hessian
armasp500sau
##
## *----------------------------------*
## * ARFIMA Model Fit *
## *----------------------------------*
## Mean Model : ARFIMA(2,0,2)
## Distribution : norm
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000875 0.000011 89308.7 0
## ar1 0.190450 0.000709 268.8 0
## ar2 0.789596 0.000079 9953.1 0
## ma1 -0.253558 0.000009 -27505.0 0
## ma2 -0.776267 0.000038 -20457.9 0
## sigma 0.024187 0.000015 1635.8 0
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000875 0.000148 6779.3135 0.000000
## ar1 0.190450 0.027189 7.0046 0.000000
## ar2 0.789596 0.004428 178.3074 0.000000
## ma1 -0.253558 0.000222 -1140.8922 0.000000
## ma2 -0.776267 0.000729 -1064.8297 0.000000
## sigma 0.024187 0.007321 3.3038 0.000954
##
## LogLikelihood : 1115.113
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.5831
## Bayes -4.5313
## Shibata -4.5834
## Hannan-Quinn -4.5627
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.4171 0.5184
## Lag[2*(p+q)+(p+q)-1][11] 4.1792 0.9996
## Lag[4*(p+q)+(p+q)-1][19] 5.8131 0.9775
##
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 29.68 5.097e-08
## Lag[2*(p+q)+(p+q)-1][2] 31.92 3.342e-09
## Lag[4*(p+q)+(p+q)-1][5] 35.41 9.341e-10
##
##
## ARCH LM Tests
## ------------------------------------
## Statistic DoF P-Value
## ARCH Lag[2] 30.03 2 3.017e-07
## ARCH Lag[5] 31.94 5 6.112e-06
## ARCH Lag[10] 36.47 10 7.000e-05
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 6.7085
## Individual Statistics:
## mu 0.03340
## ar1 0.03481
## ar2 0.03307
## ma1 0.03218
## ma2 0.03202
## sigma 0.68601
##
## 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.159718
GARCH VNI
#garch trước covid vni
#(1,1)
vni.garch11n.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "norm")
vni.garch11n.fit1 <- ugarchfit(spec = vni.garch11n.spec1, data = truoccov[,1])
vni.garch11t.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "std")
vni.garch11t.fit1 <- ugarchfit(spec = vni.garch11t.spec1, data = truoccov[, 1])
vni.garch11st.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "sstd")
vni.garch11st.fit1 <- ugarchfit(spec = vni.garch11st.spec1, data = truoccov[, 1])
vni.garch11g.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "ged")
vni.garch11g.fit1 <- ugarchfit(spec = vni.garch11g.spec1, data =truoccov[, 1])
vni.garch11sg.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "sged")
vni.garch11sg.fit1 <- ugarchfit(spec = vni.garch11sg.spec1, data =truoccov[, 1])
##(1,2)
vni.garch12n.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "norm")
vni.garch12n.fit1 <- ugarchfit(spec = vni.garch12n.spec1, data = truoccov[,1])
vni.garch12t.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "std")
vni.garch12t.fit1 <- ugarchfit(spec = vni.garch12t.spec1, data = truoccov[, 1])
vni.garch12st.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "sstd")
vni.garch12st.fit1 <- ugarchfit(spec = vni.garch12st.spec1, data = truoccov[, 1])
vni.garch12g.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "ged")
vni.garch12g.fit1 <- ugarchfit(spec = vni.garch12g.spec1, data = truoccov[, 1])
vni.garch12sg.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "sged")
vni.garch12sg.fit1 <- ugarchfit(spec = vni.garch12sg.spec1, data = truoccov[, 1])
#(2.1)
vni.garch21n.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.mode
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "norm")
vni.garch21n.fit1 <- ugarchfit(spec = vni.garch21n.spec1, data = truoccov[,1])
vni.garch21t.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "std")
vni.garch21t.fit1 <- ugarchfit(spec = vni.garch21t.spec1, data = truoccov[, 1])
vni.garch21st.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "sstd")
vni.garch21st.fit1 <- ugarchfit(spec = vni.garch21st.spec1, data = truoccov[, 1])
vni.garch21g.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "ged")
vni.garch21g.fit1 <- ugarchfit(spec = vni.garch21g.spec1, data = truoccov[, 1])
vni.garch21sg.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "sged")
vni.garch21sg.fit1 <- ugarchfit(spec = vni.garch21sg.spec1, data = truoccov[, 1])
#(2,2)
vni.garch22n.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "norm")
vni.garch22n.fit1 <- ugarchfit(spec = vni.garch22n.spec1, data = truoccov[, 1])
vni.garch22t.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "std")
vni.garch22t.fit1 <- ugarchfit(spec = vni.garch22t.spec1, data = truoccov[, 1])
vni.garch22st.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "sstd")
vni.garch22st.fit1 <- ugarchfit(spec = vni.garch22st.spec1, data = truoccov[, 1])
vni.garch22g.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "ged")
vni.garch22g.fit1 <- ugarchfit(spec = vni.garch22g.spec1, data = truoccov[, 1])
vni.garch22sg.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 0), include.mean = TRUE), distribution.model = "sged")
vni.garch22sg.fit1 <- ugarchfit(spec = vni.garch22sg.spec1, data = truoccov[, 1])
#garch trong covid vni
#(1,1)
vni.garch11n.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
vni.garch11n.fit2 <- ugarchfit(spec = vni.garch11n.spec2, data = cov[,1])
vni.garch11t.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
vni.garch11t.fit2 <- ugarchfit(spec = vni.garch11t.spec2, data = cov[, 1])
vni.garch11st.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
vni.garch11st.fit2 <- ugarchfit(spec = vni.garch11st.spec2, data = cov[, 1])
vni.garch11g.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
vni.garch11g.fit2 <- ugarchfit(spec = vni.garch11g.spec2, data =cov[, 1])
vni.garch11sg.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
vni.garch11sg.fit2 <- ugarchfit(spec = vni.garch11sg.spec2, data =cov[, 1])
##(1,2)
vni.garch12n.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
vni.garch12n.fit2 <- ugarchfit(spec = vni.garch12n.spec2, data = cov[,1])
vni.garch12t.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
vni.garch12t.fit2 <- ugarchfit(spec = vni.garch12t.spec2, data = cov[, 1])
vni.garch12st.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
vni.garch12st.fit2 <- ugarchfit(spec = vni.garch12st.spec2, data = cov[, 1])
vni.garch12g.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
vni.garch12g.fit2 <- ugarchfit(spec = vni.garch12g.spec2, data = cov[, 1])
vni.garch12sg.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
vni.garch12sg.fit2 <- ugarchfit(spec = vni.garch12sg.spec2, data = cov[, 1])
#(2.1)
vni.garch21n.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.mode
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
vni.garch21n.fit2 <- ugarchfit(spec = vni.garch21n.spec2, data = cov[,1])
vni.garch21t.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
vni.garch21t.fit2 <- ugarchfit(spec = vni.garch21t.spec2, data = cov[, 1])
vni.garch21st.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
vni.garch21st.fit2 <- ugarchfit(spec = vni.garch21st.spec2, data = cov[, 1])
vni.garch21g.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
vni.garch21g.fit2 <- ugarchfit(spec = vni.garch21g.spec2, data = cov[, 1])
vni.garch21sg.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
vni.garch21sg.fit2 <- ugarchfit(spec = vni.garch21sg.spec2, data = cov[, 1])
#(2,2)
vni.garch22n.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
vni.garch22n.fit2 <- ugarchfit(spec = vni.garch22n.spec2, data = cov[,1])
vni.garch22t.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
vni.garch22t.fit2 <- ugarchfit(spec = vni.garch22t.spec2, data = cov[, 1])
vni.garch22st.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
vni.garch22st.fit2 <- ugarchfit(spec = vni.garch22st.spec2, data = cov[, 1])
vni.garch22g.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
vni.garch22g.fit2 <- ugarchfit(spec = vni.garch22g.spec2, data = cov[, 1])
vni.garch22sg.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
vni.garch22sg.fit2 <- ugarchfit(spec = vni.garch22sg.spec2, data = cov[, 1])
#garch sau covid vni
#(1,1)
vni.garch11n.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "norm")
vni.garch11n.fit3 <- ugarchfit(spec = vni.garch11n.spec3, data = saucov[,1])
vni.garch11t.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "std")
vni.garch11t.fit3 <- ugarchfit(spec = vni.garch11t.spec3, data = saucov[,1])
vni.garch11st.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "sstd")
vni.garch11st.fit3 <- ugarchfit(spec = vni.garch11st.spec3, data = saucov[,1])
show(vni.garch11st.fit)
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : gjrGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000264 0.000279 3582.3203 0.000000
## ar1 0.930879 0.048835 19.0616 0.000000
## ma1 -0.900299 0.062192 -14.4760 0.000000
## omega 0.000011 0.000000 24.4197 0.000000
## alpha1 0.025853 0.012891 2.0055 0.044912
## beta1 0.792915 0.019233 41.2274 0.000000
## gamma1 0.243466 0.048216 5.0494 0.000000
## skew 0.836503 0.028443 29.4098 0.000000
## shape 4.288637 0.436064 9.8349 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000264 0.000365 2737.4034 0.000000
## ar1 0.930879 0.060099 15.4892 0.000000
## ma1 -0.900299 0.074218 -12.1305 0.000000
## omega 0.000011 0.000001 18.1466 0.000000
## alpha1 0.025853 0.014215 1.8186 0.068966
## beta1 0.792915 0.017740 44.6973 0.000000
## gamma1 0.243466 0.049432 4.9252 0.000001
## skew 0.836503 0.030467 27.4560 0.000000
## shape 4.288637 0.418969 10.2362 0.000000
##
## LogLikelihood : 4534.214
##
## Information Criteria
## ------------------------------------
##
## Akaike -6.2160
## Bayes -6.1833
## Shibata -6.2160
## Hannan-Quinn -6.2038
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.292 0.2557
## Lag[2*(p+q)+(p+q)-1][5] 1.634 0.9945
## Lag[4*(p+q)+(p+q)-1][9] 2.177 0.9758
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.8592 0.3540
## Lag[2*(p+q)+(p+q)-1][5] 1.9570 0.6286
## Lag[4*(p+q)+(p+q)-1][9] 3.0046 0.7582
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 1.197 0.500 2.000 0.2739
## ARCH Lag[5] 1.496 1.440 1.667 0.5933
## ARCH Lag[7] 1.586 2.315 1.543 0.8040
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 43.2216
## Individual Statistics:
## mu 0.18228
## ar1 0.18077
## ma1 0.19057
## omega 9.47558
## alpha1 0.16663
## beta1 0.17405
## gamma1 0.11933
## skew 0.09849
## shape 0.15482
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.1 2.32 2.82
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.5779 0.5634
## Negative Sign Bias 1.0718 0.2840
## Positive Sign Bias 1.4164 0.1569
## Joint Effect 4.3477 0.2263
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 35.70 0.0114765
## 2 30 49.03 0.0114712
## 3 40 62.57 0.0096871
## 4 50 86.38 0.0007833
##
##
## Elapsed time : 9.016754
vni.garch11g.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "ged")
vni.garch11g.fit3 <- ugarchfit(spec = vni.garch11g.spec3, data =saucov[,1])
show(vni.garch11g.fit)
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : gjrGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : ged
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.001025 0.000715 1400.1793 0.000000
## ar1 0.909700 0.015946 57.0478 0.000000
## ma1 -0.883610 0.020378 -43.3607 0.000000
## omega 0.000011 0.000000 31.7820 0.000000
## alpha1 0.023010 0.014979 1.5361 0.124513
## beta1 0.794615 0.019142 41.5109 0.000000
## gamma1 0.203300 0.044047 4.6155 0.000004
## shape 1.072843 0.049190 21.8101 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.001025 0.002138 468.20394 0.000000
## ar1 0.909700 0.028486 31.93468 0.000000
## ma1 -0.883610 0.044115 -20.02949 0.000000
## omega 0.000011 0.000000 25.92415 0.000000
## alpha1 0.023010 0.023329 0.98633 0.323970
## beta1 0.794615 0.024818 32.01779 0.000000
## gamma1 0.203300 0.047195 4.30766 0.000016
## shape 1.072843 0.067527 15.88769 0.000000
##
## LogLikelihood : 4517.522
##
## Information Criteria
## ------------------------------------
##
## Akaike -6.1944
## Bayes -6.1654
## Shibata -6.1945
## Hannan-Quinn -6.1836
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.171 0.2793
## Lag[2*(p+q)+(p+q)-1][5] 1.520 0.9976
## Lag[4*(p+q)+(p+q)-1][9] 2.022 0.9836
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.5708 0.4500
## Lag[2*(p+q)+(p+q)-1][5] 1.3184 0.7844
## Lag[4*(p+q)+(p+q)-1][9] 2.2034 0.8794
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.9098 0.500 2.000 0.3402
## ARCH Lag[5] 1.0762 1.440 1.667 0.7104
## ARCH Lag[7] 1.1677 2.315 1.543 0.8848
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 37.8862
## Individual Statistics:
## mu 0.2094
## ar1 0.1819
## ma1 0.2070
## omega 9.4917
## alpha1 0.1882
## beta1 0.1437
## gamma1 0.1369
## shape 0.1316
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.89 2.11 2.59
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.1435 0.8859
## Negative Sign Bias 0.4160 0.6775
## Positive Sign Bias 1.6272 0.1039
## Joint Effect 3.3146 0.3456
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 49.30 1.659e-04
## 2 30 63.78 2.045e-04
## 3 40 70.54 1.468e-03
## 4 50 113.02 5.715e-07
##
##
## Elapsed time : 1.099863
vni.garch11sg.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "sged")
vni.garch11sg.fit3 <- ugarchfit(spec = vni.garch11sg.spec3, data =saucov[,1])
##(1,2)
vni.garch12n.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "norm")
vni.garch12n.fit3 <- ugarchfit(spec = vni.garch12n.spec3, data = saucov[,1])
vni.garch12t.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "std")
vni.garch12t.fit3 <- ugarchfit(spec = vni.garch12t.spec3, data = saucov[,1])
show(vni.garch12t.fit)
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : gjrGARCH(1,2)
## Mean Model : ARFIMA(1,0,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000994 0.001551 645.38452 0.000000
## ar1 0.714380 0.401676 1.77850 0.075322
## ma1 -0.658274 0.379472 -1.73471 0.082792
## omega 0.000014 0.000001 26.13715 0.000000
## alpha1 0.022502 0.087835 0.25619 0.797808
## beta1 0.619948 0.145308 4.26645 0.000020
## beta2 0.120112 0.132297 0.90790 0.363934
## gamma1 0.315382 0.119164 2.64663 0.008130
## shape 3.924783 0.407975 9.62015 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 1.000994 0.011038 90.685899 0.000000
## ar1 0.714380 2.577869 0.277120 0.781688
## ma1 -0.658274 2.340261 -0.281282 0.778494
## omega 0.000014 0.000004 3.189466 0.001425
## alpha1 0.022502 0.608593 0.036974 0.970506
## beta1 0.619948 0.217627 2.848670 0.004390
## beta2 0.120112 0.195018 0.615899 0.537961
## gamma1 0.315382 0.731983 0.430860 0.666570
## shape 3.924783 1.290143 3.042131 0.002349
##
## LogLikelihood : 4522.849
##
## Information Criteria
## ------------------------------------
##
## Akaike -6.2003
## Bayes -6.1677
## Shibata -6.2004
## Hannan-Quinn -6.1882
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.02483 0.8748
## Lag[2*(p+q)+(p+q)-1][5] 0.16530 1.0000
## Lag[4*(p+q)+(p+q)-1][9] 0.48293 1.0000
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.297 0.2547
## Lag[2*(p+q)+(p+q)-1][8] 2.766 0.7283
## Lag[4*(p+q)+(p+q)-1][14] 5.888 0.6538
## d.o.f=3
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[4] 0.2477 0.500 2.000 0.6187
## ARCH Lag[6] 0.3187 1.461 1.711 0.9405
## ARCH Lag[8] 1.4749 2.368 1.583 0.8443
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 40.177
## Individual Statistics:
## mu 0.2387
## ar1 0.2067
## ma1 0.1955
## omega 5.3938
## alpha1 0.2016
## beta1 0.1989
## beta2 0.2089
## gamma1 0.1709
## shape 0.2124
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.1 2.32 2.82
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.3345 0.73808
## Negative Sign Bias 0.9959 0.31946
## Positive Sign Bias 1.7746 0.07618 *
## Joint Effect 4.1810 0.24257
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 37.21 0.0074593
## 2 30 63.45 0.0002256
## 3 40 73.78 0.0006406
## 4 50 88.23 0.0005000
##
##
## Elapsed time : 0.799232
vni.garch12st.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "sstd")
vni.garch12st.fit3 <- ugarchfit(spec = vni.garch12st.spec3, data = saucov[,1])
vni.garch12g.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "ged")
vni.garch12g.fit3 <- ugarchfit(spec = vni.garch12g.spec3, data = saucov[,1])
vni.garch12sg.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "sged")
vni.garch12sg.fit3 <- ugarchfit(spec = vni.garch12sg.spec3, data = saucov[,1])
#(2.1)
vni.garch21n.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.mode
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "norm")
vni.garch21n.fit3 <- ugarchfit(spec = vni.garch21n.spec3, data = saucov[,1])
vni.garch21t.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "std")
vni.garch21t.fit3 <- ugarchfit(spec = vni.garch21t.spec3, data = saucov[,1])
vni.garch21st.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "sstd")
vni.garch21st.fit3 <- ugarchfit(spec = vni.garch21st.spec3, data = saucov[,1])
vni.garch21g.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "ged")
vni.garch21g.fit3 <- ugarchfit(spec = vni.garch21g.spec3, data = saucov[,1])
vni.garch21sg.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "sged")
vni.garch21sg.fit3 <- ugarchfit(spec = vni.garch21sg.spec3, data = saucov[,1])
#(2,2)
vni.garch22n.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "norm")
vni.garch22n.fit3 <- ugarchfit(spec = vni.garch22n.spec3, data = saucov[,1])
vni.garch22t.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "std")
vni.garch22t.fit3 <- ugarchfit(spec = vni.garch22t.spec3, data = saucov[,1])
vni.garch22st.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "sstd")
vni.garch22st.fit3 <- ugarchfit(spec = vni.garch22st.spec3, data =saucov[,1])
vni.garch22g.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)), mean.model
= list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "ged")
vni.garch22g.fit3 <- ugarchfit(spec = vni.garch22g.spec3, data = saucov[,1])
vni.garch22sg.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(0, 1), include.mean = TRUE), distribution.model = "sged")
vni.garch22sg.fit3 <- ugarchfit(spec = vni.garch22sg.spec3, data = saucov[,1])
LỰA CHỌN MÔ HÌNH BIÊN PHÙ HỢP CỦA VNI 3 GIAI ĐOẠN
# Lựa chọn mô hình biên phù hợp nhất cho chuỗi VNI trước covid
vni.model.list.truoc <- list(garch11n = vni.garch11n.fit1,
garch11t = vni.garch11t.fit1,
garch11st = vni.garch11st.fit1,
garch11g = vni.garch11g.fit1,
garch11sg = vni.garch11sg.fit1,
garch12n = vni.garch12n.fit1,
garch12t = vni.garch12t.fit1,
garch12st = vni.garch12st.fit1,
garch12g = vni.garch12g.fit1,
garch12sg = vni.garch12sg.fit1,
garch21n = vni.garch21n.fit1,
garch21t = vni.garch21t.fit1,
garch21st = vni.garch21st.fit1,
garch21g = vni.garch21g.fit1,
garch21sg = vni.garch21sg.fit1,
garch22n = vni.garch22n.fit1,
garch22t = vni.garch22t.fit1,
garch22st = vni.garch22st.fit1,
garch22g = vni.garch22g.fit1,
garch22sg = vni.garch22sg.fit1)
vni.info.mat1 <- sapply(vni.model.list.truoc, infocriteria)
rownames(vni.info.mat1) <- rownames(infocriteria(vni.garch11n.fit1))
vni.info.mat1
## garch11n garch11t garch11st garch11g garch11sg garch12n
## Akaike -6.428317 -6.514462 -6.517343 -6.505187 -6.506760 -6.426460
## Bayes -6.367737 -6.445228 -6.439455 -6.435952 -6.428872 -6.357225
## Shibata -6.428729 -6.514999 -6.518021 -6.505724 -6.507438 -6.426997
## Hannan-Quinn -6.404511 -6.487255 -6.486735 -6.477979 -6.476152 -6.399252
## garch12t garch12st garch12g garch12sg garch21n garch21t
## Akaike -6.511104 -6.513899 -6.501439 -6.503062 -6.445625 -6.512150
## Bayes -6.433216 -6.427356 -6.423551 -6.416519 -6.367737 -6.425607
## Shibata -6.511782 -6.514733 -6.502117 -6.503897 -6.446303 -6.512985
## Hannan-Quinn -6.480496 -6.479890 -6.470831 -6.469053 -6.415017 -6.478141
## garch21st garch21g garch21sg garch22n garch22t garch22st
## Akaike -6.513826 -6.501815 -6.503218 -6.441270 -6.508009 -6.509685
## Bayes -6.418629 -6.415272 -6.408021 -6.354728 -6.412812 -6.405834
## Shibata -6.514833 -6.502649 -6.504225 -6.442105 -6.509016 -6.510880
## Hannan-Quinn -6.476416 -6.467806 -6.465808 -6.407261 -6.470599 -6.468874
## garch22g garch22sg
## Akaike -6.497674 -6.499077
## Bayes -6.402477 -6.395226
## Shibata -6.498681 -6.500272
## Hannan-Quinn -6.460264 -6.458266
vni.inds1 <- which(vni.info.mat1 == min(vni.info.mat1), arr.ind=TRUE)
model.vni1 <- colnames(vni.info.mat1)[vni.inds1[,2]]
model.vni1
## [1] "garch11st"
# Lựa chọn mô hình biên phù hợp nhất cho chuỗi VNI covid
vni.model.list.trong<- list(garch11n = vni.garch11n.fit2,
garch11t = vni.garch11t.fit2,
garch11st = vni.garch11st.fit2,
garch11g = vni.garch11g.fit2,
garch11sg = vni.garch11sg.fit2,
garch12n = vni.garch12n.fit2,
garch12t = vni.garch12t.fit2,
garch12st = vni.garch12st.fit2,
garch12g = vni.garch12g.fit2,
garch12sg = vni.garch12sg.fit2,
garch21n = vni.garch21n.fit2,
garch21t = vni.garch21t.fit2,
garch21st = vni.garch21st.fit2,
garch21g = vni.garch21g.fit2,
garch21sg = vni.garch21sg.fit2,
garch22n = vni.garch22n.fit2,
garch22t = vni.garch22t.fit2,
garch22st = vni.garch22st.fit2,
garch22g = vni.garch22g.fit2,
garch22sg = vni.garch22sg.fit2)
vni.info.mat2 <- sapply(vni.model.list.trong, infocriteria)
rownames(vni.info.mat2) <- rownames(infocriteria(vni.garch11n.fit2))
vni.info.mat2
## garch11n garch11t garch11st garch11g garch11sg garch12n
## Akaike -5.969171 -6.149504 -6.173459 -6.145072 -6.160039 -5.967565
## Bayes -5.891527 -6.063233 -6.078561 -6.058801 -6.065141 -5.881294
## Shibata -5.969844 -6.150331 -6.174458 -6.145900 -6.161038 -5.968393
## Hannan-Quinn -5.938665 -6.115607 -6.136173 -6.111176 -6.122753 -5.933669
## garch12t garch12st garch12g garch12sg garch21n garch21t
## Akaike -6.137115 -6.154130 -6.128345 -6.156954 -5.964963 -6.142048
## Bayes -6.042216 -6.050605 -6.033447 -6.053429 -5.870065 -6.038523
## Shibata -6.138113 -6.155316 -6.129344 -6.158140 -5.965962 -6.143234
## Hannan-Quinn -6.099829 -6.113454 -6.091059 -6.116278 -5.927677 -6.101373
## garch21st garch21g garch21sg garch22n garch22t garch22st
## Akaike -6.165674 -6.124554 -6.152468 -5.961252 -6.129040 -6.149300
## Bayes -6.053521 -6.021028 -6.040315 -5.857726 -6.016887 -6.028520
## Shibata -6.167061 -6.125739 -6.153855 -5.962437 -6.130427 -6.150905
## Hannan-Quinn -6.121608 -6.083878 -6.108402 -5.920576 -6.084974 -6.101845
## garch22g garch22sg
## Akaike -6.119065 -6.147121
## Bayes -6.006912 -6.026341
## Shibata -6.120452 -6.148726
## Hannan-Quinn -6.074999 -6.099666
vni.inds2 <- which(vni.info.mat2 == min(vni.info.mat2), arr.ind=TRUE)
vni.inds2
## row col
## Shibata 3 3
model.vni2<- colnames(vni.info.mat2)[vni.inds2[,2]]
model.vni2
## [1] "garch11st"
# Lựa chọn mô hình biên phù hợp nhất cho chuỗi VNI sau covid
vni.model.list.sau <- list(
garch11n = vni.garch11n.fit3,
garch11t = vni.garch11t.fit3,
garch11st = vni.garch11st.fit3,
garch11g = vni.garch11g.fit3,
garch11sg = vni.garch11sg.fit3,
garch12n = vni.garch12n.fit3,
garch12t = vni.garch12t.fit3,
garch12st = vni.garch12st.fit3,
garch12g = vni.garch12g.fit3,
garch12sg = vni.garch12sg.fit3,
garch21n = vni.garch21n.fit3,
garch21t = vni.garch21t.fit3,
garch21st = vni.garch21st.fit3,
garch21g = vni.garch21g.fit3,
garch21sg = vni.garch21sg.fit3,
garch22n = vni.garch22n.fit3,
garch22t = vni.garch22t.fit3,
garch22st = vni.garch22st.fit3 )
vni.info.mat3<- sapply(vni.model.list.sau, infocriteria)
rownames(vni.info.mat3) <- rownames(infocriteria(vni.garch11n.fit3))
vni.info.mat3
## garch11n garch11t garch11st garch11g garch11sg garch12n
## Akaike -5.954509 -6.015445 -6.026530 -6.020818 -6.033703 -5.954145
## Bayes -5.902665 -5.954960 -5.957405 -5.960333 -5.964578 -5.893660
## Shibata -5.954812 -6.015856 -6.027065 -6.021228 -6.034238 -5.954555
## Hannan-Quinn -5.934138 -5.991678 -5.999368 -5.997051 -6.006541 -5.930378
## garch12t garch12st garch12g garch12sg garch21n garch21t
## Akaike -6.014164 -6.025669 -6.018934 -6.031791 -5.954598 -6.011148
## Bayes -5.945038 -5.947903 -5.949809 -5.954025 -5.885473 -5.933382
## Shibata -6.014698 -6.026344 -6.019469 -6.032465 -5.955133 -6.011823
## Hannan-Quinn -5.987002 -5.995111 -5.991772 -6.001233 -5.927436 -5.980590
## garch21st garch21g garch21sg garch22n garch22t garch22st
## Akaike -6.021362 -6.016904 -6.028108 -5.933075 -6.008959 -6.020045
## Bayes -5.934956 -5.939138 -5.941702 -5.855309 -5.922553 -5.924998
## Shibata -6.022193 -6.017579 -6.028939 -5.933750 -6.009790 -6.021048
## Hannan-Quinn -5.987410 -5.986346 -5.994156 -5.902518 -5.975007 -5.982697
vni.inds3 <- which(vni.info.mat3 == min(vni.info.mat3), arr.ind=TRUE)
model.vni3 <- colnames(vni.info.mat3)[vni.inds3[,2]]
model.vni3
## [1] "garch11sg"
GARCH S&P500 3 GIAI ĐOẠN
# Các dạng MH GJR-GARCH cho chuỗi sp500sp500
## GJR-GARCH(11)SP500
sp500.garch11n.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch11n.fit1 <- ugarchfit(spec = sp500.garch11n.spec1, data = truoccov[,2])
sp500.garch11t.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch11t.fit1 <- ugarchfit(spec =sp500.garch11t.spec1, data = truoccov[,2])
sp500.garch11st.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch11st.fit1 <- ugarchfit(spec = sp500.garch11st.spec1, data = truoccov[,2])
sp500.garch11g.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch11g.fit1 <- ugarchfit(spec =sp500.garch11g.spec1, data = truoccov[,2])
sp500.garch11sg.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch11sg.fit1 <- ugarchfit(spec = sp500.garch11sg.spec1, data =truoccov[,2])
## GJR-GARCH(12)vccb
sp500.garch12n.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch12n.fit1 <- ugarchfit(spec = sp500.garch12n.spec1, data = truoccov[,2])
sp500.garch12t.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch12t.fit1 <- ugarchfit(spec = sp500.garch12t.spec1, data = truoccov[,2])
sp500.garch12st.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch12st.fit1 <- ugarchfit(spec = sp500.garch12st.spec1, data = truoccov[,2])
sp500.garch12g.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = "ged")
sp500.garch12g.fit1 <- ugarchfit(spec = sp500.garch12g.spec1, data = truoccov[,2])
sp500.garch12sg.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch12sg.fit1 <- ugarchfit(spec = sp500.garch12sg.spec1, data = truoccov[,2])
## GJR-GARCH(21)vcbvcb
sp500.garch21n.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch21n.fit1 <- ugarchfit(spec = sp500.garch21n.spec1, data = truoccov[,2])
sp500.garch21t.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch21t.fit1 <- ugarchfit(spec = sp500.garch21t.spec1, data = truoccov[,2])
sp500.garch21st.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch21st.fit1 <- ugarchfit(spec = sp500.garch21st.spec1, data = truoccov[,2])
sp500.garch21g.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch21g.fit1 <- ugarchfit(spec =sp500.garch21g.spec1, data = truoccov[,2])
sp500.garch21sg.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch21sg.fit1 <- ugarchfit(spec = sp500.garch21sg.spec1, data = truoccov[,2])
## GJR-GARCH(22)SP500
sp500.garch22n.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch22n.fit1 <- ugarchfit(spec = sp500.garch22n.spec1, data = truoccov[,2])
sp500.garch22t.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch22t.fit1 <- ugarchfit(spec = sp500.garch22t.spec1, data = truoccov[,2])
sp500.garch22st.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch22st.fit1<- ugarchfit(spec = sp500.garch22st.spec1, data = truoccov[,2])
sp500.garch22g.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch22g.fit1 <- ugarchfit(spec = sp500.garch22g.spec1, data = truoccov[,2])
sp500.garch22sg.spec1 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch22sg.fit1 <- ugarchfit(spec =sp500.garch22sg.spec1, data = truoccov[,2])
# Các dạng MH GJR-GARCH cho chuỗi trong covid
## GJR-GARCH(11)SP500
sp500.garch11n.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch11n.fit2 <- ugarchfit(spec = sp500.garch11n.spec2, data = cov[,2])
sp500.garch11t.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch11t.fit2 <- ugarchfit(spec =sp500.garch11t.spec2, data = cov[,2])
sp500.garch11st.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch11st.fit2 <- ugarchfit(spec = sp500.garch11st.spec2, data = cov[,2])
sp500.garch11g.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch11g.fit2 <- ugarchfit(spec =sp500.garch11g.spec2, data = cov[,2])
sp500.garch11sg.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch11sg.fit2 <- ugarchfit(spec = sp500.garch11sg.spec2, data =cov[,2])
## GJR-GARCH(12)vccb
sp500.garch12n.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch12n.fit2 <- ugarchfit(spec = sp500.garch12n.spec2, data = cov[,2])
sp500.garch12t.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch12t.fit2 <- ugarchfit(spec = sp500.garch12t.spec2, data = cov[,2])
sp500.garch12st.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch12st.fit2 <- ugarchfit(spec = sp500.garch12st.spec2, data = cov[,2])
sp500.garch12g.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = "ged")
sp500.garch12g.fit2 <- ugarchfit(spec = sp500.garch12g.spec2, data = cov[,2])
sp500.garch12sg.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch12sg.fit2 <- ugarchfit(spec = sp500.garch12sg.spec2, data = cov[,2])
## GJR-GARCH(21)vcbvcb
sp500.garch21n.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch21n.fit2 <- ugarchfit(spec = sp500.garch21n.spec2, data = cov[,2])
sp500.garch21t.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch21t.fit2 <- ugarchfit(spec = sp500.garch21t.spec2, data = cov[,2])
sp500.garch21st.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch21st.fit2 <- ugarchfit(spec = sp500.garch21st.spec2, data = cov[,2])
sp500.garch21g.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch21g.fit2 <- ugarchfit(spec =sp500.garch21g.spec2, data = cov[,2])
sp500.garch21sg.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch21sg.fit2 <- ugarchfit(spec = sp500.garch21sg.spec2, data = cov[,2])
## GJR-GARCH(22)SP500
sp500.garch22n.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch22n.fit2 <- ugarchfit(spec = sp500.garch22n.spec2, data = cov[,2])
sp500.garch22t.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch22t.fit2 <- ugarchfit(spec = sp500.garch22t.spec2, data = cov[,2])
sp500.garch22st.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch22st.fit2<- ugarchfit(spec = sp500.garch22st.spec2, data = cov[,2])
sp500.garch22g.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch22g.fit2 <- ugarchfit(spec = sp500.garch22g.spec2, data = cov[,2])
sp500.garch22sg.spec2 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch22sg.fit2 <- ugarchfit(spec =sp500.garch22sg.spec2, data = cov[,2])
# Các dạng MH GJR-GARCH cho chuỗi trong covid
## GJR-GARCH(11)SP500
sp500.garch11n.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch11n.fit3 <- ugarchfit(spec = sp500.garch11n.spec3, data = saucov[,2])
sp500.garch11t.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch11t.fit3 <- ugarchfit(spec =sp500.garch11t.spec3, data = saucov[,2])
sp500.garch11st.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch11st.fit3 <- ugarchfit(spec = sp500.garch11st.spec3, data = saucov[,2])
sp500.garch11g.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch11g.fit3 <- ugarchfit(spec =sp500.garch11g.spec3, data = saucov[,2])
sp500.garch11sg.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch11sg.fit3 <- ugarchfit(spec = sp500.garch11sg.spec3, data =saucov[,2])
## GJR-GARCH(12)vccb
sp500.garch12n.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch12n.fit3 <- ugarchfit(spec = sp500.garch12n.spec3, data = saucov[,2])
sp500.garch12t.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch12t.fit3 <- ugarchfit(spec = sp500.garch12t.spec3, data = saucov[,2])
sp500.garch12st.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch12st.fit3 <- ugarchfit(spec = sp500.garch12st.spec3, data = saucov[,2])
sp500.garch12g.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2,2), include.mean = TRUE), distribution.model = "ged")
sp500.garch12g.fit3 <- ugarchfit(spec = sp500.garch12g.spec3, data = saucov[,2])
sp500.garch12sg.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(1, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch12sg.fit3 <- ugarchfit(spec = sp500.garch12sg.spec3, data = saucov[,2])
## GJR-GARCH(21)vcbvcb
sp500.garch21n.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch21n.fit3 <- ugarchfit(spec = sp500.garch21n.spec3, data = saucov[,2])
sp500.garch21t.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch21t.fit3 <- ugarchfit(spec = sp500.garch21t.spec3, data = saucov[,2])
sp500.garch21st.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch21st.fit3 <- ugarchfit(spec = sp500.garch21st.spec3, data = saucov[,2])
sp500.garch21g.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch21g.fit3 <- ugarchfit(spec =sp500.garch21g.spec3, data = saucov[,2])
sp500.garch21sg.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch21sg.fit3 <- ugarchfit(spec = sp500.garch21sg.spec3, data =saucov[,2])
## GJR-GARCH(22)SP500
sp500.garch22n.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "norm")
sp500.garch22n.fit3 <- ugarchfit(spec = sp500.garch22n.spec3, data = saucov[,2])
sp500.garch22t.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "std")
sp500.garch22t.fit3 <- ugarchfit(spec = sp500.garch22t.spec3, data =saucov[,2])
sp500.garch22st.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sstd")
sp500.garch22st.fit3<- ugarchfit(spec = sp500.garch22st.spec3, data = saucov[,2])
sp500.garch22g.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "ged")
sp500.garch22g.fit3 <- ugarchfit(spec = sp500.garch22g.spec3, data = saucov[,2])
sp500.garch22sg.spec3 <- ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder = c(2, 2)),
mean.model = list(armaOrder = c(2, 2), include.mean = TRUE), distribution.model = "sged")
sp500.garch22sg.fit3 <- ugarchfit(spec =sp500.garch22sg.spec3, data = saucov[,2])
KẾT QUẢ ƯỚC LƯỢNG
copulatruoc <- BiCopSelect(u1,v1,selectioncrit = "AIC",method = "mle")
copulatrong <- BiCopSelect(u2,v2,selectioncrit = "AIC",method = "mle")
copulasau<- BiCopSelect(u3,v3,selectioncrit = "AIC",method = "mle")
#est
est_copulatruoc <- BiCopEst(u1,v1,family = copulatruoc$family,method = "mle",max.df = 30)
est_copulatrong<- BiCopEst(u2,v2,family = copulatrong$family,method = "mle",max.df = 30)
est_copulasau <- BiCopEst(u3,v3,family = copulasau$family,method = "mle",max.df = 30)
#Trình bày kết quả
kq<- data.frame(mqh = c('Trước Covid' ,'Trong Covid','Sau Covid'),
Copula = c('Rotated Gumbel 270 degrees', 'Independence','Gaussian'),
Thamso = c(est_copulatruoc$par, est_copulatrong$par, est_copulasau$par),
Thamso2 = c(est_copulatruoc$par2, est_copulatrong$par2, est_copulasau$par2),
duoi = c(est_copulatruoc$tau, est_copulatrong$tau, est_copulasau$tau),
duoiduoi = c(est_copulatruoc$taildep$lower, est_copulatrong$taildep$lower, est_copulasau$taildep$lower),
duoitren = c(est_copulatruoc$taildep$upper, est_copulatrong$taildep$upper, est_copulasau$taildep$upper),
aic = c(est_copulatruoc$AIC, est_copulatrong$AIC, est_copulasau$AIC),
bic = c(est_copulatruoc$BIC, est_copulatrong$BIC, est_copulasau$BIC))
kable(kq,
caption = "Bảng 11: Kết quả ước lượng Copula của TSLN VNI và STI từng giai đoạn",
col.names = c("CHISO","Copula", "Par","Par2", "HS Kendall","Đuoiuoi","Duoitren","AIC","BIC"),
format = 'pandoc') %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = F)
## Warning in kable_styling(., bootstrap_options = c("striped", "hover",
## "condensed"), : Please specify format in kable. kableExtra can customize either
## HTML or LaTeX outputs. See https://haozhu233.github.io/kableExtra/ for details.
Bảng 11: Kết quả ước lượng Copula của TSLN VNI và STI từng giai
đoạn
| Trước Covid |
Rotated Gumbel 270 degrees |
-1.0592325 |
0 |
-0.0559202 |
0 |
0 |
-3.107264 |
1.072753 |
| Trong Covid |
Independence |
0.0000000 |
0 |
0.0000000 |
0 |
0 |
0.000000 |
0.000000 |
| Sau Covid |
Gaussian |
-0.0805305 |
0 |
-0.0513229 |
0 |
0 |
-1.166012 |
3.016073 |
years <- 2010:2023
sp500_values <- c(15.06, 2.11, 16.00, 32.39, 13.69, 1.38, 11.96, 21.83, -4.38, 31.49, 18.40, 28.71, -18.11, 26.29)
plot(years, sp500_values, type="o", col="blue", xlab="Năm", ylab="Tỷ lệ tăng trưởng (%)", main="S&P 500 Từ 2010 đến 2023")
abline(h=0, col="red", lty=2)

library(xlsx)
library(tidyverse)
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
##
## discard
## The following object is masked from 'package:readr':
##
## col_factor
h<- read.xlsx("D:/mhnn/thhdvni.xlsx", sheetIndex= 1, header= T)
h %>% ggplot(aes(x =Năm.)) +
geom_density()

ggplot(h, aes(x=Năm., y=poitvni)) +
geom_line(color="blue") +
labs(title="Điểm VNI giai đoạn 2010-2023", x="Năm", y="Điểm VNI") +
theme_minimal()
# VẼ CÁC HỌ COPULA
#BIỂU ĐỒ COPULA STUDENT VÀ GAUSSIAN
library(knitr)
## Warning: package 'knitr' was built under R version 4.3.3
library(copula)
library(ggplot2)
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.3
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(gridExtra)
## Warning: package 'gridExtra' was built under R version 4.3.3
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
library(VC2copula)
library(VineCopula)
library(gridGraphics)
## Warning: package 'gridGraphics' was built under R version 4.3.3
library(png)
# Hàm vẽ biểu đồ phân tán
scatter_plot <- function(random_data) {
ggplot(data.frame(random_data), aes(x = random_data[,1], y = random_data[,2])) +
geom_point(alpha = 0.5) +
theme_minimal() +
labs(x = "u", y = "v")
}
# Hàm vẽ biểu đồ phối cảnh
persp_plot <- function(copula_obj, file_name) {
png(file_name)
persp(copula_obj, dCopula,
xlab = 'u', ylab = 'v', ltheta = 120,
ticktype = "detailed", cex.axis = 0.8)
dev.off()
rasterGrob(readPNG(file_name), interpolate = TRUE)
}
# Mô phỏng dữ liệu
set.seed(123)
cop_nor <- normalCopula(param = 0.8, dim = 2)
random_nor <- rCopula(copula = cop_nor, n =10000)
cop_std <- tCopula(param = 0.8, dim = 2, df = 1)
random_std <- rCopula(copula = cop_std, n = 10000)
# Vẽ biểu đồ phân tán
png('nors.png')
scatter_plot(random_nor)
dev.off()
## png
## 2
nors <- rasterGrob(readPNG('nors.png'), interpolate = TRUE)
png('stds.png')
scatter_plot(random_std)
dev.off()
## png
## 2
stds <- rasterGrob(readPNG('stds.png'), interpolate = TRUE)
# Vẽ biểu đồ phối cảnh
nor_per <- persp_plot(cop_nor, 'norp.png')
std_per <- persp_plot(cop_std, 'stdp.png')
# Thêm ghi chú cho biểu đồ
top_note <- textGrob("Biểu đồ phân tán và phối cảnh PDF với Copula Gaussian và Copula t-Student",
gp = gpar(fontsize = 12, font = 1), hjust = 0.5)
# Kết hợp các biểu đồ và ghi chú
grid.arrange(
top_note,
arrangeGrob(nors, nor_per, stds, std_per, ncol = 3,
layout_matrix = rbind(c(1, 2, 5), c(3, 4, 5)),
widths = c(2, 2, 1)),
nrow = 3,
heights = c(1, 4, 1)
)

# Hàm vẽ biểu đồ phân tán
scatter_plot <- function(random_data,c1) {
ggplot(data.frame(random_data), aes(x = random_data[,1], y = random_data[,2])) +
geom_point(alpha = 0.5,col= c1) +
theme_minimal() +
labs(x = "u", y = "v")
}
# Hàm vẽ biểu đồ
persp_plot <- function(copula_obj, file_name,c1){
png(file_name)
persp(copula_obj, dCopula,
xlab = 'u', ylab = 'v',col=c1, ltheta = 120,
ticktype = "detailed", cex.axis = 0.8)
dev.off()
rasterGrob(readPNG(file_name), interpolate = TRUE)
}
set.seed(123)
#Mô phỏng copula clayton với p=4 10000 quan sát
cop_clay <- claytonCopula(param = 4, dim = 2)
random_clay <- rCopula(copula = cop_clay,n = 10000)
#Vẽ biểu đồ
png('clays.png')
scatter_plot(random_clay,'#FF0000')
dev.off()
## png
## 2
clays <- rasterGrob(readPNG('clays.png'), interpolate = TRUE)
clayp <- persp_plot(cop_clay,'clayp.png','#FF0000')
legend <- legendGrob(
labels = c("Clayton"), pch = 15,
gp = gpar(col = c('#FF0000'), fill = c('#FF0000'))
)
grid.arrange(clays, clayp,legend, ncol = 3,
layout_matrix = rbind(c(1, 2, 3)),
widths = c(1, 1, 1)
)

#Mô phỏng copula gumbel với p=5 10000 quan sát
cop_gum <- gumbelCopula(param = 5, dim = 2)
random_gum <- rCopula(copula = cop_gum,n =10000)
png('gums.png')
scatter_plot(random_gum,'#00FFFF')
dev.off()
## png
## 2
gums <- rasterGrob(readPNG('gums.png'), interpolate = TRUE)
gump <- persp_plot(cop_gum,'gump.png','#00FFFF')
legend <- legendGrob(
labels = c( "Gumbel"), pch = 15,
gp = gpar(col = c( '#00FFFF'), fill = c( '#00FFFF'))
)
grid.arrange( gums, gump, legend, ncol = 3,
layout_matrix = rbind(c(1, 2, 3)),
widths = c(1, 1, 1)
)

#Mô phỏng copula survival clayton(Rotated-Clayton)với p=4 10000 quan sát
cop_surclay <- VC2copula::surClaytonCopula(param = 4)
random_surclay <- rCopula(copula = cop_surclay,n = 10000)
png('surclays.png')
scatter_plot(random_surclay,'#808080')
dev.off()
## png
## 2
surclays <- rasterGrob(readPNG('surclays.png'), interpolate = TRUE)
surclayp <- persp_plot(cop_gum,'surclays.png','#808080')
legend <- legendGrob(
labels = c( "Survival Clayton"), pch = 15,
gp = gpar(col = c( '#808080'), fill = c( '#808080'))
)
grid.arrange( surclays, surclayp, legend, ncol = 3,
layout_matrix = rbind(c(1, 2, 3)),
widths = c(1, 1, 1)
)

#Mô phỏng copula survival gumbel 10000 qs
cop_surgum <- VC2copula::surGumbelCopula(param = 5)
random_surgum <- rCopula(copula = cop_surgum,n = 10000)
png('surgums.png')
scatter_plot(random_surgum,'#9966FF')
dev.off()
## png
## 2
surgums <- rasterGrob(readPNG('surgums.png'), interpolate = TRUE)
surgump <- persp_plot(cop_surgum, "surgump.png","#9966FF")
legend <- legendGrob(labels = c("Survival Gumbel"), pch = 15,
gp = gpar(col = c('#9966FF'), fill = c('#9966FF' )))
grid.arrange(surgums, surgump, legend, ncol = 3,
layout_matrix = rbind(c(1,2,3)),
widths = c(1,1,1)
)

set.seed(123)
#Mô phỏng copula Frank
cop_frank <- frankCopula(param = 9.2)
#Mô phỏng 7600 quan sát ngẫu nhiên dựa trên copula có sẵn
random_frank <- rCopula(copula = cop_frank,n = 10000)
#Mô phỏng copula survival clayton với p=4
cop_joe <- joeCopula(param = 3)
#Mô phỏng 7600 quan sát ngẫu nhiên dựa trên copula có sẵn
random_joe <- rCopula(copula = cop_joe,n = 10000)
png('franks.png')
scatter_plot(random_frank,'#FFCCFF')
dev.off()
## png
## 2
franks <- rasterGrob(readPNG('franks.png'), interpolate = TRUE)
png('joes.png')
scatter_plot(random_joe,'#FFCC66')
dev.off()
## png
## 2
joes <- rasterGrob(readPNG('joes.png'), interpolate = TRUE)
frankp <- persp_plot(cop_frank, "frankp.png","#FFCCFF")
joep <- persp_plot(cop_joe, "joep.png","#FFCC66")
legend <- legendGrob(labels = c("Frank","Joe"), pch = 15,
gp = gpar(col = c('#FFCCFF','#FFCC66'), fill = c('#FFCCFF','#FFCC66')))
grid.arrange(franks, frankp,joes, joep, legend, ncol = 3,
layout_matrix = rbind(c(1,2,5),c(3,4,5)),
widths = c(2,2,1)
)

set.seed(123)
#Mô phỏng copula BB1
cop_bb1 <- VC2copula::BB1Copula(param = c(2,2))
#Mô phỏng 7600 quan sát ngẫu nhiên dựa trên copula có sẵn
random_bb1 <- rCopula(copula = cop_bb1,n = 10000)
#Mô phỏng copula BB6
cop_bb6 <- VC2copula::BB6Copula(param = c(1.5,5))
#Mô phỏng 7600 quan sát ngẫu nhiên dựa trên copula có sẵn
random_bb6 <- rCopula(copula = cop_bb6,n = 10000)
png('bb1s.png')
scatter_plot(random_bb1,'#00EE00')
dev.off()
## png
## 2
bb1s <- rasterGrob(readPNG('bb1s.png'), interpolate = TRUE)
png('bb6s.png')
scatter_plot(random_bb6,'pink')
dev.off()
## png
## 2
bb6s <- rasterGrob(readPNG('bb6s.png'), interpolate = TRUE)
bb1p <- persp_plot(cop_bb1, "bb1p.png","#00EE00")
bb6p <- persp_plot(cop_bb6, "bb6p.png","pink")
legend <- legendGrob(labels = c("BB1","BB6"), pch = 15,
gp = gpar(col = c('#00EE00','pink'), fill = c('#00EE00','pink')))
grid.arrange(bb1s, bb1p,bb6s, bb6p, legend, ncol = 3,
layout_matrix = rbind(c(1,2,5),c(3,4,5)),
widths = c(2,2,1)
)

set.seed(123)
#Mô phỏng copula BB7
cop_bb7 <- VC2copula::BB7Copula(param = c(2,5))
#Mô phỏng 7600 quan sát ngẫu nhiên dựa trên copula có sẵn
random_bb7 <- rCopula(copula = cop_bb7,n = 10000)
#Mô phỏng copula BB8
cop_bb8 <- VC2copula::BB8Copula(param = c(4,1))
#Mô phỏng 7600 quan sát ngẫu nhiên dựa trên copula có sẵn
random_bb8 <- rCopula(copula = cop_bb8,n = 10000)
png('bb7s.png')
scatter_plot(random_bb7,'yellow')
dev.off()
## png
## 2
bb7s <- rasterGrob(readPNG('bb7s.png'), interpolate = TRUE)
png('bb8s.png')
scatter_plot(random_bb8,'#FF9966')
dev.off()
## png
## 2
bb8s <- rasterGrob(readPNG('bb8s.png'), interpolate = TRUE)
bb7p <- persp_plot(cop_bb7, "bb7p.png","yellow")
bb8p <- persp_plot(cop_bb8, "bb8p.png","#FF9966")
legend <- legendGrob(labels = c("BB7","BB8"), pch = 15,
gp = gpar(col = c('yellow','#FF9966'), fill = c('yellow','#FF9966')))
grid.arrange(bb7s, bb7p,bb8s, bb8p, legend, ncol = 3,
layout_matrix = rbind(c(1,2,5),c(3,4,5)),
widths = c(2,2,1)
)
