Saturday, February 23, 2019

Dow Jones Stock Index Analysis - part 3

Introduction

In this third post, I am going to analyse the Dow Jones Industrial Average (DJIA) trade volume.

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')

Daily Volume Exploratory Analysis

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

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

It is remarkable the level jump at the beginning of 2017, something that we will investigate in part 4.

We transform the volume time series data and timeline index into a dataframe.

dj_vol_df <- xts_to_dataframe(dj_vol)
head(dj_vol_df)
##   year     value
## 1 2007 327200000
## 2 2007 259060000
## 3 2007 235220000
## 4 2007 223500000
## 5 2007 225190000
## 6 2007 226570000
tail(dj_vol_df)
##      year     value
## 3015 2018 900510000
## 3016 2018 308420000
## 3017 2018 433080000
## 3018 2018 407940000
## 3019 2018 336510000
## 3020 2018 288830000

Basic statistics summary

(dj_stats <- dataframe_basicstats(dj_vol_df))
##                     2007         2008         2009         2010
## nobs        2.510000e+02 2.530000e+02 2.520000e+02 2.520000e+02
## NAs         0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
## Minimum     8.640000e+07 6.693000e+07 5.267000e+07 6.840000e+07
## Maximum     4.571500e+08 6.749200e+08 6.729500e+08 4.598900e+08
## 1. Quartile 2.063000e+08 2.132100e+08 1.961850e+08 1.633400e+08
## 3. Quartile 2.727400e+08 3.210100e+08 3.353625e+08 2.219025e+08
## Mean        2.449575e+08 2.767164e+08 2.800537e+08 2.017934e+08
## Median      2.350900e+08 2.569700e+08 2.443200e+08 1.905050e+08
## Sum         6.148432e+10 7.000924e+10 7.057354e+10 5.085193e+10
## SE Mean     3.842261e+06 5.965786e+06 7.289666e+06 3.950031e+06
## LCL Mean    2.373901e+08 2.649672e+08 2.656970e+08 1.940139e+08
## UCL Mean    2.525248e+08 2.884655e+08 2.944104e+08 2.095728e+08
## Variance    3.705505e+15 9.004422e+15 1.339109e+16 3.931891e+15
## Stdev       6.087286e+07 9.489163e+07 1.157199e+08 6.270480e+07
## Skewness    9.422400e-01 1.203283e+00 1.037015e+00 1.452082e+00
## Kurtosis    1.482540e+00 2.064821e+00 6.584810e-01 3.214065e+00
##                     2011         2012         2013         2014
## nobs        2.520000e+02 2.500000e+02 2.520000e+02 2.520000e+02
## NAs         0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
## Minimum     8.410000e+06 4.771000e+07 3.364000e+07 4.287000e+07
## Maximum     4.799800e+08 4.296100e+08 4.200800e+08 6.554500e+08
## 1. Quartile 1.458775e+08 1.107150e+08 9.488000e+07 7.283000e+07
## 3. Quartile 1.932400e+08 1.421775e+08 1.297575e+08 9.928000e+07
## Mean        1.804133e+08 1.312606e+08 1.184434e+08 9.288516e+07
## Median      1.671250e+08 1.251950e+08 1.109250e+08 8.144500e+07
## Sum         4.546415e+10 3.281515e+10 2.984773e+10 2.340706e+10
## SE Mean     3.897738e+06 2.796503e+06 2.809128e+06 3.282643e+06
## LCL Mean    1.727369e+08 1.257528e+08 1.129109e+08 8.642012e+07
## UCL Mean    1.880897e+08 1.367684e+08 1.239758e+08 9.935019e+07
## Variance    3.828475e+15 1.955108e+15 1.988583e+15 2.715488e+15
## Stdev       6.187468e+07 4.421660e+07 4.459353e+07 5.211034e+07
## Skewness    1.878239e+00 3.454971e+00 3.551752e+00 6.619268e+00
## Kurtosis    5.631080e+00 1.852581e+01 1.900989e+01 5.856136e+01
##                     2015         2016         2017         2018
## nobs        2.520000e+02 2.520000e+02 2.510000e+02 2.510000e+02
## NAs         0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
## Minimum     4.035000e+07 4.589000e+07 1.186100e+08 1.559400e+08
## Maximum     3.445600e+08 5.734700e+08 6.357400e+08 9.005100e+08
## 1. Quartile 8.775250e+07 8.224250e+07 2.695850e+08 2.819550e+08
## 3. Quartile 1.192150e+08 1.203550e+08 3.389950e+08 4.179200e+08
## Mean        1.093957e+08 1.172089e+08 3.112396e+08 3.593710e+08
## Median      1.021000e+08 9.410500e+07 2.996700e+08 3.414700e+08
## Sum         2.756772e+10 2.953664e+10 7.812114e+10 9.020213e+10
## SE Mean     2.433611e+06 4.331290e+06 4.376432e+06 6.984484e+06
## LCL Mean    1.046028e+08 1.086786e+08 3.026202e+08 3.456151e+08
## UCL Mean    1.141886e+08 1.257392e+08 3.198590e+08 3.731270e+08
## Variance    1.492461e+15 4.727538e+15 4.807442e+15 1.224454e+16
## Stdev       3.863238e+07 6.875709e+07 6.933572e+07 1.106550e+08
## Skewness    3.420032e+00 3.046742e+00 1.478708e+00 1.363823e+00
## Kurtosis    1.612326e+01 1.122161e+01 3.848619e+00 3.277164e+00

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

Mean

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

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

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

dj_stats["Mean",order(dj_stats["Mean",,])]
##          2014      2015      2016      2013      2012      2011      2010
## Mean 92885159 109395714 117208889 118443373 131260600 180413294 201793373
##           2007      2008      2009      2017      2018
## Mean 244957450 276716364 280053730 311239602 359371036

Median

Years when Dow Jones daily volume has positive median are:

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

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

dj_stats["Median",order(dj_stats["Median",,])]
##            2014     2016      2015      2013      2012      2011      2010
## Median 81445000 94105000 102100000 110925000 125195000 167125000 190505000
##             2007      2009      2008      2017      2018
## Median 235090000 244320000 256970000 299670000 341470000

Skewness

Years when Dow Jones daily trade volume has positive skewness are:

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

All Dow Jones daily trade volume skewness values in ascending order.

dj_stats["Skewness",order(dj_stats["Skewness",,])]
##             2007     2009     2008     2018     2010     2017     2011
## Skewness 0.94224 1.037015 1.203283 1.363823 1.452082 1.478708 1.878239
##              2016     2015     2012     2013     2014
## Skewness 3.046742 3.420032 3.454971 3.551752 6.619268

Excess Kurtosis

Years when Dow Jones daily volume 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 excess kurtosis values in ascending order.

dj_stats["Kurtosis",order(dj_stats["Kurtosis",,])]
##              2009    2007     2008     2010     2018     2017    2011
## Kurtosis 0.658481 1.48254 2.064821 3.214065 3.277164 3.848619 5.63108
##              2016     2015     2012     2013     2014
## Kurtosis 11.22161 16.12326 18.52581 19.00989 58.56136

Boxplots

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

Trade volume starts to decrease from 2010 and on 2017 a remarkable increase occurred. Year 2018 volume have been even larger than 2017 and other years as well.

Density plots

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

Shapiro Tests

dataframe_shapirotest(dj_vol_df)
##            result
## 2007 6.608332e-09
## 2008 3.555102e-10
## 2009 1.023147e-10
## 2010 9.890576e-13
## 2011 2.681476e-16
## 2012 1.866544e-20
## 2013 6.906596e-21
## 2014 5.304227e-27
## 2015 2.739912e-21
## 2016 6.640215e-23
## 2017 4.543843e-12
## 2018 9.288371e-11

The null hypothesis of normality is rejected for all years.

QQ plots

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

QQplots visually confirm the non normality of daily trade volume distribution.

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.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.