compute skewness of a univariate distribution.
skewness(x, na.rm = FALSE, method = c("moment", "fisher", "sample"), ...)
x | a numeric vector or object. |
---|---|
na.rm | a logical. Should missing values be removed? |
method | a character string which specifies the method of computation.
These are either |
… | arguments to be passed. |
This function was ported from the RMetrics package fUtilities to eliminate a
dependency on fUtiltiies being loaded every time. The function is identical
except for the addition of checkData and column support.
$$Skewness(moment) = \frac{1}{n}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_P})^3$$
$$Skewness(sample) = \frac{n}{(n-1)*(n-2)}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_{S_P}})^3 $$
$$Skewness(fisher) = \frac{\frac{\sqrt{n*(n-1)}}{n-2}*\sum^{n}_{i=1}\frac{x^3}{n}}{\sum^{n}_{i=1}(\frac{x^2}{n})^{3/2}}$$
where \(n\) is the number of return, \(\overline{r}\) is the mean of the return distribution, \(\sigma_P\) is its standard deviation and \(\sigma_{S_P}\) is its sample standard deviation
Carl Bacon, Practical portfolio performance measurement and attribution, second edition 2008 p.83-84
## mean - ## var - # Mean, Variance: r = rnorm(100) mean(r)#> [1] 0.1148568var(r)#> [1] 1.028762## skewness - skewness(r)#> [1] 0.09997428data(managers) skewness(managers)#> HAM1 HAM2 HAM3 HAM4 HAM5 HAM6 #> Skewness -0.6588445 1.45804 0.7908285 -0.4310631 0.07380869 -0.2799993 #> EDHEC LS EQ SP500 TR US 10Y TR US 3m TR #> Skewness 0.01773013 -0.5531032 -0.4048722 -0.328171