compute kurtosis of a univariate distribution
kurtosis(
x,
na.rm = FALSE,
method = c("excess", "moment", "fisher", "sample", "sample_excess"),
...
)a numeric vector or object.
a logical. Should missing values be removed?
a character string which specifies the method of computation.
These are either "moment", "fisher", or "excess". If
"excess" is selected, then the value of the kurtosis is computed by
the "moment" method and a value of 3 will be subtracted. The
"moment" method is based on the definitions of kurtosis for
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 kurtosis exact
unbiasedness is not possible. The "sample" method gives the sample
kurtosis of the distribution.
arguments to be passed.
This function was ported from the RMetrics package fUtilities to eliminate a
dependency on fUtilties being loaded every time. This function is identical
except for the addition of checkData and additional labeling.
$$Kurtosis(moment) = \frac{1}{n}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_P})^4$$ $$Kurtosis(excess) = \frac{1}{n}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_P})^4 - 3$$ $$Kurtosis(sample) = \frac{n*(n+1)}{(n-1)*(n-2)*(n-3)}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_{S_P}})^4 $$ $$Kurtosis(fisher) = \frac{(n+1)*(n-1)}{(n-2)*(n-3)}*(\frac{\sum^{n}_{i=1}\frac{(r_i)^4}{n}}{(\sum^{n}_{i=1}(\frac{(r_i)^2}{n})^2} - \frac{3*(n-1)}{n+1})$$ $$Kurtosis(sample excess) = \frac{n*(n+1)}{(n-1)*(n-2)*(n-3)}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_{S_P}})^4 - \frac{3*(n-1)^2}{(n-2)*(n-3)}$$
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.84-85
## mean -
## var -
# Mean, Variance:
r = rnorm(100)
mean(r)
#> [1] -0.06002293
var(r)
#> [1] 1.065546
## kurtosis -
kurtosis(r)
#> [1] 0.4347487
data(managers)
kurtosis(managers[,1:8])
#> HAM1 HAM2 HAM3 HAM4 HAM5 HAM6
#> Excess Kurtosis 2.361589 2.379398 2.682936 0.8632077 2.314343 -0.348865
#> EDHEC LS EQ SP500 TR
#> Excess Kurtosis 0.9104791 0.5598191
data(portfolio_bacon)
print(kurtosis(portfolio_bacon[,1], method="sample")) #expected 3.03
#> [1] 3.027405
print(kurtosis(portfolio_bacon[,1], method="sample_excess")) #expected -0.41
#> [1] -0.4076603
print(kurtosis(managers['1996'], method="sample"))
#> HAM1 HAM2 HAM3 HAM4 HAM5 HAM6 EDHEC LS EQ
#> Excess Kurtosis 4.571471 6.932463 5.039467 4.13553 0 0 0
#> SP500 TR US 10Y TR US 3m TR
#> Excess Kurtosis 4.893647 3.250776 4.817395
print(kurtosis(managers['1996',1], method="sample"))
#> [1] 4.571471