# [R] about comparison of KURTOSIS in package: moments and fBasics

P Ehlers ehlers at math.ucalgary.ca
Fri Dec 2 23:28:26 CET 2005

```(Haven't seen an anwer to this yet; maybe I missed it.)

klebyn wrote:

>
>
> Hello
>
>
>
> I do not know very much about statistics (and English language too :-( ),
> then I come in search of a clarification (explanation):
>
> I found two distinct results on KURTOSIS and
> I do not know which of them is the correct one.
> Any aid will be welcome!
>
>
> klebyn

The code will show you why you get different results.

fBasics:
kurtosis = sum((x - mean(x))^4/var(x)^2)/length(x) - 3

moments:
n <- length(x)
n * sum((x - mean(x))^4)/(sum((x - mean(x))^2)^2)

So pkg:moments uses the ratio of 4th sample moment to
square of second sample moment, while pkg:fBasics uses the
variance instead of the second moment and subtracts 3
(for reasons to do with the Normal distribution).

Peter Ehlers

>
>
>
> ################  CODE
>
> rnorm(1000) -> x
>
> library(moments)
>
> kurtosis(x)
> skewness(x)
>
> detach("package:moments")
> library(fBasics)
>
> kurtosis(x)
> skewness(x)
>
> detach("package:fBasics")
>
> R.version
>
> ################  OUTPUT
>
>  >
>  > rnorm(1000) -> x
>  >
>  >
>  > library(moments)
>  >
>  >
>  > kurtosis(x)
> [1] 3.145274
>  > skewness(x)
> [1] 0.04898635
>  >
>  >
>  > detach("package:moments")
>  > library(fBasics)
>
> Rmetrics, (C) 1999-2005, Diethelm Wuertz, GPL
> fBasics: Markets, Basic Statistics, Hypothesis Testing
>  >
>  >
>  > kurtosis(x)
> [1] 0.1389865
>  > skewness(x)
> [1] 0.04891289
>  >
>  >
>  > detach("package:fBasics")
>  >
>  > R.version
>          _
> platform i386-pc-mingw32
> arch     i386
> os       mingw32
> system   i386, mingw32
> status
> major    2
> minor    2.0
> year     2005
> month    10
> day      06
> svn rev  35749
> language R
>  >
>  >
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help