Functions for skewness and kurtosis.
skew(x,method="unbiased")kurt(x,method="unbiased")
Output will be the sample skewness or kurtosis.
A vector of quantitative data.
The type of method used for computation of skew and kurtosis. Two choices are possible for skewness: "moments"
and "unbiased"
, and three choices are possible for kurtosis: "unbiased", "moments"
, and "excess"
.
Ken Aho
Aside from centrality and variability we can describe distributions with respect to their shape. Two important shape descriptors are skewness and kurtosis. Skewness describes the relative density in the tails of a distribution while kurtosis describes the peakedness of a distribution. When quantified for a population skewness and kurtosis are denoted as \(\gamma_1\) and \(\gamma_2\) respectively. For a symmetric distribution skewness will equal zero; i.e. \(\gamma_1\) = 0. A distribution with more density in its right-hand tail will have \(\gamma_1\) > 0, while one with more density in its left-hand tail will have \(\gamma_1\) < 0. These distributions are often referred to as positively-skewed and negatively-skewed respectively. If a distribution is normally peaked (mesokurtic) then \(\gamma_2\) = 3. As a result the number three is generally subtracted from kurtosis estimates so that a normal distribution will have \(\gamma_2\) = 0 . Thus strongly peaked (leptokurtic) distributions will have \(\gamma_2\) > 0, while flat-looking (platykurtic) distributions will have a kurtosis \(\gamma_2\) < 0.
Several types of skewness and kurtosis estimation are possible.
For method of moments estimation let: $$m_j = (1/n)\sum_i({X_i-\bar{X}})^j,$$
then the method of moments skewness is: \(m_3/m_{2}^{3/2}\), the method of moments kurtosis is: \(m_4/m_2^2\), and the excess method of moments kurtosis is \(m_4/m_2^2 -3\).
These estimators are biased low, particularly given small sample sizes. A more complex estimator is required to account for this bias. This is provided by method = "unbiased"
in skew
and kurt
.
exp<-rexp(10000)
skew(exp)
kurt(exp)
Run the code above in your browser using DataLab