Dear Rmetrics Core Team members,

I suspect functions skewness and kurtosis supplied in package timeDate, which I downloaded a while ago but no earlier than August, 2010, return results which I believe are incorrect, and would like to ask you to have the codes checked.

When the method= "moment" is specified, the code calculates skewness as

skewness = sum((x – mean(x))^3/sqrt(as.numeric(var(x)))^3)/length(x),

where x is a numeric vector or object and n = length(x). However, if this skewness is supposed to calculate skewness for distributions, i.e., biased skewness, var(x) in the denominator should be corrected as var(x)*(n-1)/n to convert it to the biased variance.

When the method =”fisher” is specified, the skewness is calculated as

skewness = ((sqrt(n * (n - 1))/(n - 2)) * (sum(x^3)/n))/((sum(x^2)/n)^(3/2)).

The summations in the numerator and the denominator, however, should be 

sum((x-mean(x))^3)/n) and ((sum((x-mean(x))^2)/n), respectively, if the “fisher” skewness corresponds to the usual “unbiased” skewness. 

Subtraction of mean(x) from the vector x apparently is missing.

The same “anomalities” are found in the code for function kurtosis, as follows.

if (method == "excess") {

kurtosis = sum((x - mean(x))^4/as.numeric(var(x))^2)/length(x) - 3

}

if (method == "moment") {

kurtosis = sum((x - mean(x))^4/as.numeric(var(x))^2)/length(x)

}

if (method == "fisher") {

kurtosis = ((n + 1) * (n - 1) * ((sum(x^4)/n)/(sum(x^2)/n)^2 - (3 * (n - 1))/(n + 1)))/((n - 2) * (n - 3))

}

When I made those correcions mentioned above, both skewness and kurtosis returened results in agreement with those returened by the corresponding functions supplied with some other software.

With thanks.

Hiroshi Sawada

	[[alternative HTML version deleted]]

