PerformanceAnalytics (version 1.5.3)

skewness: Skewness

Description

compute skewness of a univariate distribution.

Usage

skewness(x, na.rm = FALSE, method = c("moment", "fisher", "sample"),
  ...)

Arguments

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 "moment" or "fisher" The "moment" method is based on the definitions of skewnessfor distributions; these forms should be used when resampling (bootstrap or jackknife). The "fisher" method correspond to the usual "unbiased" definition of sample variance, although in the case of skewness exact unbiasedness is not possible. The "sample" method gives the sample skewness of the distribution.

arguments to be passed.

Details

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

References

Carl Bacon, Practical portfolio performance measurement and attribution, second edition 2008 p.83-84

See Also

kurtosis

Examples

Run this code
# NOT RUN {
## mean -
## var -
   # Mean, Variance:
   r = rnorm(100)
   mean(r)
   var(r)

## skewness -
   skewness(r)
data(managers)
skewness(managers)

# }

Run the code above in your browser using DataCamp Workspace