Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

different results of Skewness and kurtosis from timDate and Moments packages

Tags:

r

let a = c(1:9,1), in library(timeDate) (which is imported in library(fBasics) too), skewness(a) = 0.10901 and kurtosis(a) = -1.634, .

in library(moments), skewness(a) = 0.1277 and kurtosis(a) - 3 = -1.313, which match the results from Matlab.

is this a bug in one of these packages?

like image 296
user 7023 Avatar asked Jan 21 '23 11:01

user 7023


1 Answers

There are a number of ways to estimate the population moments. You can compare these different methods using the skewness and kurtosis functions in the e1071 package

> library(e1071)
> skewness(a,,1)
[1] 0.1277249
> skewness(a,,2)
[1] 0.1514631
> skewness(a,,3)
[1] 0.1090534
> kurtosis(a,,1)
[1] -1.313042
> kurtosis(a,,2)
[1] -1.356985
> kurtosis(a,,3)
[1] -1.633564

All of these measures are valid, and unbiased (at least in the case of normality). according to D. N. Joanes and C. A. Gill (1998) (Comparing measures of sample skewness and kurtosis. The Statistician, 47, 183–189.), type 3 performs better in non-normal populations, whereas type 2 performs best in normal looking populations. Type 1 is an older definition.

In large samples the difference between these estimators becomes negligible. see ?skewness for the formulas used.

like image 179
Ian Fellows Avatar answered Jan 30 '23 19:01

Ian Fellows