statistics - calulating sample excess kurtosis using R package fBasics -
i used fbasics package calculate sample excess kurtosis of simple vector [1,2,3]:
> library(fbasics) > x=c(1,2,3) > kurtosis(x) [1] -2.333333 attr(,"method") [1] "excess"
what calculated based on wikipedia http://en.wikipedia.org/wiki/kurtosis#sample_kurtosis, -1.5. wonder why fbaswics package gives different result?
thanks!
use kurtosis
moments package instead.
> library(moments) > kurtosis(x) [1] 1.5
kurtosis
momments computes estimator of pearson's measure of kurtosis. function implemented (if x
numeric vector) follows:
n <- length(x) n * sum((x - mean(x))^4)/(sum((x - mean(x))^2)^2)
for excess of kurtosis use:
> kurtosis(x)-3 [1] -1.5
now, understand what's different in kurtosis
form fbasics, @ code, use:
library(fbasics) methods("kurtosis") getanywhere("kurtosis.default")
and if x
numeric vector, excess of kurtosis defined in kurtosis fbasics (actually timedate, see comment) as:
sum((x - mean(x))^4/as.numeric(var(x))^2)/length(x) - 3
i think you. question in comment looking basic statistical answer, i've pointed out r programming hints answer homework.
Comments
Post a Comment