Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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) = sum((x-mean(x))^3/var(x)^(3/2))/length(x)

skewness(sample) = sum(((x-mean(x))/var(x))^3)*n/((n-1)*(n-2))

Skewness(fisher)((sqrt(n*(n-1))/(n-2))*(sum(x^3)/n))/((sum(x^2)/n)^(3/2))

where n is the number of return, \overline{r} is the mean of the return distribution, σ_P is its standard deviation and σ_{S_P} is its sample standard deviation

Author(s)

Diethelm Wuertz, Matthieu Lestel

References

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

See Also

Examples

## mean -
## var -
   # Mean, Variance:
   r = rnorm(100)
   mean(r)
   var(r)

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

PerformanceAnalytics

Econometric Tools for Performance and Risk Analysis

v2.0.4
GPL-2 | GPL-3
Authors
Brian G. Peterson [cre, aut, cph], Peter Carl [aut, cph], Kris Boudt [ctb, cph], Ross Bennett [ctb], Joshua Ulrich [ctb], Eric Zivot [ctb], Dries Cornilly [ctb], Eric Hung [ctb], Matthieu Lestel [ctb], Kyle Balkissoon [ctb], Diethelm Wuertz [ctb], Anthony Alexander Christidis [ctb], R. Douglas Martin [ctb], Zeheng 'Zenith' Zhou [ctb], Justin M. Shea [ctb]
Initial release
2020-02-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.