10) Create the Skewness and Kurtosis statistics.

This Blog entry is from the Summary Statistics Plots section in Learn R.

It can be observed from previous procedures that the histogram has a severe lean towards the axis, which would be described as being positively skewed.   The positive skew deviating from the shape expected of a normal distribution would be cause mistrust of the standard deviation that was created.  Two useful statistics and functions for assessing the extent to which a distribution deviates from the normal distribution is skewness() measuring the lean towards and away from the y axis and kurtosis() measuring how tall or squashed the distribution is.

The functions skewness() and kurtosis() do not exist in the base R packages rather they are available in a package called moments.  It follows that the moments package need be installed then loaded.  Search for and install the package moments via RStudio:

1.png

Click the Install button to run the installation instruction to console:

2.png

Load the library moments by typing into the script window:

library(moments)
3.png

Run the line of script to console:

4.png

Firstly, in the quest to appraise the extent to which the vector leans towards or away from the axis, type:

skewness(AAPL$Interim_Close)
5.png

Run the line of script to console:

6.png

It can be observed that there is a positive value returned, indicating that there is indeed lean and owing to it being positive, that the lean is towards the y axis (which is of course what was visually observed in subsequent Blog entries).  Secondly to understand if the distribution is tall or squat, verify the kurtosis by typing:

kurtosis(AAPL$Interim_Close)
7.png

Run the line of script to console:

8.png

The kurtosis is a difficult statistic to make sense of and in many respects the skewness is a more useful statistic.  To make an assessment of the shape of the distribution, typically, all summary statistics need to be considered:

9.png