[R] skewness, kurtosis
Wolfgang Koller
koller2 at fgr.wu-wien.ac.at
Wed Jul 28 10:57:25 CEST 1999
Dear R-Users and Developpers,
Currently R does not include functions to compute the skewness and
kurtosis. I programmed it myself in the following way, but probably
*real* programmers/statisticians can do that better:
mykurtosis <- function(x) {
m4 <- mean((x-mean(x))^4)
kurt <- m4/(sd(x)^4)-3
kurt
}
myskewness <- function(x) {
m3 <- mean((x-mean(x))^3)
skew <- m3/(sd(x)^3)
skew
}
I would also suggest to include the quartile-coefficient of skewness
(sorry if this translation from German is not correct). This measure
is confined to the interval [0,1] and much easier to interpret.
My try:
myqcskewness <- function(x) {
x25 <- as.double(quantile(x,prob=0.25))
x75 <- as.double(quantile(x,prob=0.75))
qcsk <- (x25+x75-2*mean(x))/(x75-x25)
qcsk
}
Finally a question which actually is not R-related (please excuse
this misuse of the list):
Is there something like a "quantile-coefficient of kurtosis"??
Maybe:
k = (2b-a)/a with a = x_{p} - x_{1-p}, b = x_{q} - x_{1-q},
x_{} are quantiles, and p and q are chosen so that k=0 for the normal
distribution.
Thanks for help!!
WK
----------------------------------------------------------
Wolfgang Koller, koller2 at fgr.wu-wien.ac.at
Research Institute for European Affairs
Vienna University of Economics and Business Administration
Althanstrasse 39-45, 1090 Vienna, Austria
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list