Introduction
I am going to build an ARMA-GARCH model for Dow Jones Industrial Average (DJIA) daily trade volume log-ratio.
Packages
The packages being used in this post series are herein listed.
suppressPackageStartupMessages(library(lubridate))
suppressPackageStartupMessages(library(fBasics))
suppressPackageStartupMessages(library(lmtest))
suppressPackageStartupMessages(library(urca))
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(quantmod))
suppressPackageStartupMessages(library(PerformanceAnalytics))
suppressPackageStartupMessages(library(rugarch))
suppressPackageStartupMessages(library(FinTS))
suppressPackageStartupMessages(library(forecast))
suppressPackageStartupMessages(library(strucchange))
suppressPackageStartupMessages(library(TSA))
Getting Data
We upload the environment status.
load(file='DowEnvironment.RData')
We run two fits in order to compare the results with two candidate mean models ARMA(1,2) and ARMA(2,3)
ARMA-GARCH: ARMA(1,2) + eGARCH(1,1)
garchspec <- ugarchspec(mean.model = list(armaOrder = c(1,2), include.mean = FALSE),
variance.model = list(model = "eGARCH", garchOrder = c(1, 1), variance.targeting = FALSE),
distribution.model = "sstd")
(garchfit <- ugarchfit(data = dj_vol_log_ratio, spec = garchspec, solver='hybrid'))
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(1,0,2)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.67731 0.014856 45.5918 0.0e+00
## ma1 -1.22817 0.000038 -31975.1819 0.0e+00
## ma2 0.27070 0.000445 608.3525 0.0e+00
## omega -1.79325 0.207588 -8.6385 0.0e+00
## alpha1 0.14348 0.032569 4.4053 1.1e-05
## beta1 0.35819 0.073164 4.8957 1.0e-06
## gamma1 0.41914 0.042252 9.9199 0.0e+00
## skew 1.32266 0.031528 41.9518 0.0e+00
## shape 3.54346 0.221750 15.9795 0.0e+00
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.67731 0.022072 30.6859 0.0e+00
## ma1 -1.22817 0.000067 -18466.0626 0.0e+00
## ma2 0.27070 0.000574 471.4391 0.0e+00
## omega -1.79325 0.233210 -7.6894 0.0e+00
## alpha1 0.14348 0.030588 4.6906 3.0e-06
## beta1 0.35819 0.082956 4.3178 1.6e-05
## gamma1 0.41914 0.046728 8.9698 0.0e+00
## skew 1.32266 0.037586 35.1902 0.0e+00
## shape 3.54346 0.238225 14.8744 0.0e+00
##
## LogLikelihood : 347.9765
##
## Information Criteria
## ------------------------------------
##
## Akaike -0.22456
## Bayes -0.20664
## Shibata -0.22458
## Hannan-Quinn -0.21812
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.5812 4.459e-01
## Lag[2*(p+q)+(p+q)-1][8] 8.5925 3.969e-08
## Lag[4*(p+q)+(p+q)-1][14] 14.1511 4.171e-03
## d.o.f=3
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.4995 0.4797
## Lag[2*(p+q)+(p+q)-1][5] 1.1855 0.8164
## Lag[4*(p+q)+(p+q)-1][9] 2.4090 0.8510
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.4215 0.500 2.000 0.5162
## ARCH Lag[5] 0.5974 1.440 1.667 0.8545
## ARCH Lag[7] 1.2835 2.315 1.543 0.8636
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 5.2333
## Individual Statistics:
## ar1 0.63051
## ma1 1.18685
## ma2 1.11562
## omega 2.10211
## alpha1 0.08261
## beta1 2.07607
## gamma1 0.15883
## skew 0.33181
## shape 2.56140
##
## 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 1.600 0.10965
## Negative Sign Bias 0.602 0.54725
## Positive Sign Bias 2.540 0.01115 **
## Joint Effect 6.815 0.07804 *
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 20.37 0.3726
## 2 30 36.82 0.1510
## 3 40 45.07 0.2328
## 4 50 52.03 0.3567
##
##
## Elapsed time : 1.407701
All coefficients are statistically significative. However, based on above reported Weighted Ljung-Box Test on Standardized Residuals p-values, we reject the null hypothesis of no correlation of residuals for the present model. Hence model ARMA(1,2)+eGARCH(1,1) is not able to capture all the structure of our time series.
ARMA-GARCH: ARMA(2,3) + eGARCH(1,1)
garchspec <- ugarchspec(mean.model = list(armaOrder = c(2,3), include.mean = FALSE),
variance.model = list(model = "eGARCH", garchOrder = c(1, 1), variance.targeting = FALSE),
distribution.model = "sstd")
(garchfit <- ugarchfit(data = dj_vol_log_ratio, spec = garchspec, solver='hybrid'))
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : eGARCH(1,1)
## Mean Model : ARFIMA(2,0,3)
## Distribution : sstd
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## ar1 -0.18607 0.008580 -21.6873 0.0e+00
## ar2 0.59559 0.004596 129.5884 0.0e+00
## ma1 -0.35619 0.013512 -26.3608 0.0e+00
## ma2 -0.83010 0.004689 -177.0331 0.0e+00
## ma3 0.26277 0.007285 36.0678 0.0e+00
## omega -1.92262 0.226738 -8.4795 0.0e+00
## alpha1 0.14382 0.033920 4.2401 2.2e-05
## beta1 0.31060 0.079441 3.9098 9.2e-05
## gamma1 0.43137 0.043016 10.0281 0.0e+00
## skew 1.32282 0.031382 42.1523 0.0e+00
## shape 3.48939 0.220787 15.8043 0.0e+00
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## ar1 -0.18607 0.023940 -7.7724 0.000000
## ar2 0.59559 0.022231 26.7906 0.000000
## ma1 -0.35619 0.024244 -14.6918 0.000000
## ma2 -0.83010 0.004831 -171.8373 0.000000
## ma3 0.26277 0.030750 8.5453 0.000000
## omega -1.92262 0.266462 -7.2154 0.000000
## alpha1 0.14382 0.032511 4.4239 0.000010
## beta1 0.31060 0.095329 3.2582 0.001121
## gamma1 0.43137 0.047092 9.1602 0.000000
## skew 1.32282 0.037663 35.1225 0.000000
## shape 3.48939 0.223470 15.6146 0.000000
##
## LogLikelihood : 356.4994
##
## Information Criteria
## ------------------------------------
##
## Akaike -0.22888
## Bayes -0.20698
## Shibata -0.22891
## Hannan-Quinn -0.22101
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.7678 0.38091
## Lag[2*(p+q)+(p+q)-1][14] 7.7336 0.33963
## Lag[4*(p+q)+(p+q)-1][24] 17.1601 0.04972
## d.o.f=5
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.526 0.4683
## Lag[2*(p+q)+(p+q)-1][5] 1.677 0.6965
## Lag[4*(p+q)+(p+q)-1][9] 2.954 0.7666
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 1.095 0.500 2.000 0.2955
## ARCH Lag[5] 1.281 1.440 1.667 0.6519
## ARCH Lag[7] 1.940 2.315 1.543 0.7301
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 5.3764
## Individual Statistics:
## ar1 0.12923
## ar2 0.20878
## ma1 1.15005
## ma2 1.15356
## ma3 0.97487
## omega 2.04688
## alpha1 0.09695
## beta1 2.01026
## gamma1 0.18039
## skew 0.38131
## shape 2.40996
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 2.49 2.75 3.27
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 1.4929 0.13556
## Negative Sign Bias 0.6317 0.52766
## Positive Sign Bias 2.4505 0.01432 **
## Joint Effect 6.4063 0.09343 *
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 17.92 0.5278
## 2 30 33.99 0.2395
## 3 40 44.92 0.2378
## 4 50 50.28 0.4226
##
##
## Elapsed time : 1.546991
All coefficients are statistically significative. No correlation within standardized residuals or standardized squared residuals is found. All ARCH effects are properly captured by the model. The Adjusted Pearson Goodness-of-fit test does not reject the null hypothesis that the empirical distribution of the standardized residuals and the selected theoretical distribution are the same. However:
the Nyblom stability test null hypothesis that the model parameters are constant over time is rejected for some of them
the Positive Sign Bias null hypothesis is rejected at 5% of significance level; this kind of test focuses on the effect of large and small positive shocks
See ref. [11] for an explanation about GARCH model diagnostic.
Some diagnostic plots are shown.
par(mfrow=c(2,2))
plot(garchfit, which=8)
plot(garchfit, which=9)
plot(garchfit, which=10)
plot(garchfit, which=11)
We show the original DJIA daily trade volume log-ratio time series with the mean model fit (red line) and the conditional volatility (blue line).
par(mfrow=c(1,1))
cond_volatility <- sigma(garchfit)
mean_model_fit <- fitted(garchfit)
p <- plot(dj_vol_log_ratio, col = "grey")
p <- addSeries(mean_model_fit, col = 'red', on = 1)
p <- addSeries(cond_volatility, col = 'blue', on = 1)
p
Model Equation
Combining both ARMA(2,3) and eGARCH(1,1) model equations we have:
\[ \begin{equation} \begin{cases} y_{t}\ -\ \phi_{1}y_{t-1}\ -\ \phi_{2}y_{t-2} =\ \phi_{0}\ +\ u_{t}\ +\ \theta_{1}u_{t-1}\ +\ \theta_{2}u_{t-2}\ +\ \theta_{3}u_{t-3} \\ \\ u_{t}\ =\ \sigma_{t}\epsilon_{t},\ \ \ \ \ \epsilon_{t}=N(0,1) \\ \\ \ln(\sigma_{t}^2)\ =\ \omega\ + \sum_{j=1}^{q} (\alpha_{j} \epsilon_{t-j}^2\ + \gamma (\epsilon_{t-j} - E|\epsilon_{t-j}|)) +\ \sum_{i=1}^{p} \beta_{i} ln(\sigma_{t-1}^2) \end{cases} \end{equation} \]
Using the model resulting coefficients we obtain:
\[ \begin{equation} \begin{cases} y_{t}\ +\ 0.186\ y_{t-1} -\ 0.595\ y_{t-2}\ = \ u_{t}\ -\ 0.356u_{t-1}\ - 0.830\ u_{t-2}\ +\ 0.263\ u_{t-3} \\ \\ u_{t}\ =\ \sigma_{t}\epsilon_{t},\ \ \ \ \ \epsilon_{t}=N(0,1) \\ \\ \ln(\sigma_{t}^2)\ =\ -1.922\ +0.144 \epsilon_{t-1}^2\ + 0.431\ (\epsilon_{t-1} - E|\epsilon_{t-1}|)) +\ 0.310\ ln(\sigma_{t-1}^2) \end{cases} \end{equation} \]
Saving the current enviroment for further analysis.
save.image(file='DowEnvironment.RData')
References
[1] Dow Jones Industrial Average [https://en.wikipedia.org/wiki/Dow_Jones_Industrial_Average]
[2] Skewness [https://en.wikipedia.org/wiki/Skewness]
[3] Kurtosis [https://en.wikipedia.org/wiki/Kurtosis]
[4] An introduction to analysis of financial data with R, Wiley, Ruey S. Tsay [https://www.wiley.com/en-us/An+Introduction+to+Analysis+of+Financial+Data+with+R-p-9780470890813]
[5] Time series analysis and its applications, Springer ed., R.H. Shumway, D.S. Stoffer [https://www.springer.com/gp/book/9783319524511]
[6] Applied Econometric Time Series, Wiley, W. Enders, 4th ed. [https://www.wiley.com/en-us/Applied+Econometric+Time+Series%2C+4th+Edition-p-9781118808566]
[7] Forecasting - Principle and Practice, Texts, R.J. Hyndman [https://otexts.org/fpp2/]
[8] Options, Futures and other Derivatives, Pearson ed., J.C. Hull[https://www.pearson.com/us/higher-education/product/Hull-Options-Futures-and-Other-Derivatives-9th-Edition/9780133456318.html]
[9] An introduction to rugarch package [https://cran.r-project.org/web/packages/rugarch/vignettes/Introduction_to_the_rugarch_package.pdf]
[10] Applied Econometrics with R, Achim Zeileis, Christian Kleiber - Springer Ed. [http://www.springer.com/la/book/9780387773162]
[11] GARCH modeling: diagnostic tests [https://logicalerrors.wordpress.com/2017/08/14/garch-modeling-conditional-variance-useful-diagnostic-tests/]
Disclaimer
Any securities or databases referred in this post are solely for illustration purposes, and under no regard should the findings presented here be interpreted as investment advice or a promotion of any particular security or source.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.