Sunday, February 24, 2019

Dow Jones Stock Index Analysis - part 4

Introduction

In this fourth post, I am going to analyse the Dow Jones Industrial Average (DJIA) 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 as saved at the end of part 1.

load(file='DowEnvironment.RData')

From saved environment, we can find back our DJI object. We plot the daily volume.

dj_vol <- DJI[,"DJI.Volume"]
plot(dj_vol)

Daily volume log-ratio Exploratory Analysis

Simlarly to log-returns, we can define the trade volume log ratio as.

\[ v_{t}\ := ln \frac{V_{t}}{V_{t-1}} \] We can compute it by CalculateReturns within the PerformanceAnalytics package.

dj_vol_log_ratio <- CalculateReturns(dj_vol, "log")
dj_vol_log_ratio <- na.omit(dj_vol_log_ratio)
plot(dj_vol_log_ratio)

Mapping the trade volume log-ratio time series data and timeline index into a dataframe.

dj_vol_df <- xts_to_dataframe(dj_vol_log_ratio)
head(dj_vol_df)
##   year        value
## 1 2007 -0.233511910
## 2 2007 -0.096538449
## 3 2007 -0.051109832
## 4 2007  0.007533076
## 5 2007  0.006109458
## 6 2007  0.144221282
tail(dj_vol_df)
##      year       value
## 3014 2018  0.44563907
## 3015 2018 -1.07149878
## 3016 2018  0.33945998
## 3017 2018 -0.05980236
## 3018 2018 -0.19249224
## 3019 2018 -0.15278959

Basic statistics summary

(dj_stats <- dataframe_basicstats(dj_vol_df))
##                   2007       2008       2009       2010       2011
## nobs        250.000000 253.000000 252.000000 252.000000 252.000000
## NAs           0.000000   0.000000   0.000000   0.000000   0.000000
## Minimum      -1.606192  -1.122526  -1.071225  -1.050181  -2.301514
## Maximum       0.775961   0.724762   0.881352   1.041216   2.441882
## 1. Quartile  -0.123124  -0.128815  -0.162191  -0.170486  -0.157758
## 3. Quartile   0.130056   0.145512   0.169233   0.179903   0.137108
## Mean         -0.002685   0.001203  -0.001973  -0.001550   0.000140
## Median       -0.010972   0.002222  -0.031748  -0.004217  -0.012839
## Sum          -0.671142   0.304462  -0.497073  -0.390677   0.035162
## SE Mean       0.016984   0.016196   0.017618   0.019318   0.026038
## LCL Mean     -0.036135  -0.030693  -0.036670  -0.039596  -0.051141
## UCL Mean      0.030766   0.033100   0.032725   0.036495   0.051420
## Variance      0.072112   0.066364   0.078219   0.094041   0.170850
## Stdev         0.268536   0.257612   0.279677   0.306661   0.413341
## Skewness     -0.802037  -0.632586   0.066535  -0.150523   0.407226
## Kurtosis      5.345212   2.616615   1.500979   1.353797  14.554642
##                   2012       2013       2014       2015       2016
## nobs        250.000000 252.000000 252.000000 252.000000 252.000000
## NAs           0.000000   0.000000   0.000000   0.000000   0.000000
## Minimum      -2.158960  -1.386215  -2.110572  -1.326016  -1.336471
## Maximum       1.292956   1.245202   2.008667   1.130289   1.319713
## 1. Quartile  -0.152899  -0.145444  -0.144280  -0.143969  -0.134011
## 3. Quartile   0.144257   0.149787   0.134198   0.150003   0.141287
## Mean          0.001642  -0.002442   0.000200   0.000488   0.004228
## Median       -0.000010  -0.004922   0.013460   0.004112  -0.002044
## Sum           0.410521  -0.615419   0.050506   0.123080   1.065480
## SE Mean       0.021293   0.019799   0.023514   0.019010   0.019089
## LCL Mean     -0.040295  -0.041435  -0.046110  -0.036952  -0.033367
## UCL Mean      0.043579   0.036551   0.046510   0.037929   0.041823
## Variance      0.113345   0.098784   0.139334   0.091071   0.091826
## Stdev         0.336667   0.314299   0.373274   0.301780   0.303028
## Skewness     -0.878227  -0.297951  -0.209417  -0.285918   0.083826
## Kurtosis      8.115847   4.681120   9.850061   4.754926   4.647785
##                   2017       2018
## nobs        251.000000 251.000000
## NAs           0.000000   0.000000
## Minimum      -0.817978  -1.071499
## Maximum       0.915599   0.926101
## 1. Quartile  -0.112190  -0.119086
## 3. Quartile   0.110989   0.112424
## Mean         -0.000017   0.000257
## Median       -0.006322   0.003987
## Sum          -0.004238   0.064605
## SE Mean       0.013446   0.014180
## LCL Mean     -0.026500  -0.027671
## UCL Mean      0.026466   0.028185
## Variance      0.045383   0.050471
## Stdev         0.213032   0.224658
## Skewness      0.088511  -0.281007
## Kurtosis      3.411036   4.335748

In the following, we make specific comments to some relevant aboveshown metrics.

Mean

Years when Dow Jones daily trade volume log-ratio has positive mean are:

filter_dj_stats(dj_stats, "Mean", 0)
## [1] "2008" "2011" "2012" "2014" "2015" "2016" "2018"

All Dow Jones daily trade volume log-ratio mean values in ascending order.

dj_stats["Mean",order(dj_stats["Mean",,])]
##           2007      2013      2009     2010     2017    2011  2014
## Mean -0.002685 -0.002442 -0.001973 -0.00155 -1.7e-05 0.00014 2e-04
##          2018     2015     2008     2012     2016
## Mean 0.000257 0.000488 0.001203 0.001642 0.004228

Median

Years when Dow Jones daily volume log-ratio has positive median are:

filter_dj_stats(dj_stats, "Median", 0)
## [1] "2008" "2014" "2015" "2018"

All Dow Jones daily trade volume log-ratio median values in ascending order.

dj_stats["Median",order(dj_stats["Median",,])]
##             2009      2011      2007      2017      2013      2010
## Median -0.031748 -0.012839 -0.010972 -0.006322 -0.004922 -0.004217
##             2016   2012     2008     2018     2015    2014
## Median -0.002044 -1e-05 0.002222 0.003987 0.004112 0.01346

Skewness

Years when Dow Jones daily volume log-ratio has positive skewness are:

filter_dj_stats(dj_stats, "Skewness", 0)
## [1] "2009" "2011" "2016" "2017"

All Dow Jones daily trade volume log-ratio mean values in ascending order.

dj_stats["Skewness",order(dj_stats["Skewness",,])]
##               2012      2007      2008      2013      2015      2018
## Skewness -0.878227 -0.802037 -0.632586 -0.297951 -0.285918 -0.281007
##               2014      2010     2009     2016     2017     2011
## Skewness -0.209417 -0.150523 0.066535 0.083826 0.088511 0.407226

Excess Kurtosis

Years when Dow Jones daily log-returns has positive excess kurtosis are:

filter_dj_stats(dj_stats, "Kurtosis", 0)
##  [1] "2007" "2008" "2009" "2010" "2011" "2012" "2013" "2014" "2015" "2016"
## [11] "2017" "2018"

All Dow Jones daily trade volume log-ratio excess kurtosis values in ascending order.

dj_stats["Kurtosis",order(dj_stats["Kurtosis",,])]
##              2010     2009     2008     2017     2018     2016    2013
## Kurtosis 1.353797 1.500979 2.616615 3.411036 4.335748 4.647785 4.68112
##              2015     2007     2012     2014     2011
## Kurtosis 4.754926 5.345212 8.115847 9.850061 14.55464

Boxplots

dataframe_boxplot(dj_vol_df, "DJIA daily volume box plots 2007-2018")

The most positive extreme values can be spotted on years 2011, 2014 and 2016. The most negative extreme values, on years 2007, 2011, 2012, 2014.

Density plots

dataframe_densityplot(dj_vol_df, "DJIA daily volume density plots 2007-2018")

Shapiro Tests

dataframe_shapirotest(dj_vol_df)
##            result
## 2007 3.695053e-09
## 2008 6.160136e-07
## 2009 2.083475e-04
## 2010 1.500060e-03
## 2011 3.434415e-18
## 2012 8.417627e-12
## 2013 1.165184e-10
## 2014 1.954662e-16
## 2015 5.261037e-11
## 2016 7.144940e-11
## 2017 1.551041e-08
## 2018 3.069196e-09

Based on reported p-values, for all we can reject the null hypothesis of normal distribution.

QQ plots

dataframe_qqplot(dj_vol_df, "DJIA daily volume QQ plots 2007-2018")

Departure from normality can be spotted for all reported years.

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]

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.