Compute Skewness and Kurtosis

DESCRIPTION:

Compute skewness and kurtosis statistics.

USAGE:

skewness(x, na.rm=F, method="fisher", weights=NULL, freq=NULL) 
kurtosis(x, na.rm=F, method="fisher", weights=NULL, freq=NULL)

REQUIRED ARGUMENTS:

x
any numerical object. Missing values (NA) are allowed.

OPTIONAL ARGUMENTS:

na.rm
logical flag: if na.rm=TRUE, missing values are removed from x before doing the computations. If na.rm=FALSE and x contains missing values, then the return value is NA.
method
character string specifying the computation method. The two possible values are "fisher" for Fisher's g1 (skewness) and g2 (kurtosis) versions, and "moment" for the functional forms of the statistics. Only the first character of the string needs to be supplied.
weights
vector the same length as x; if supplied then skewness or kurtosis for a weighted distribution is calculated, and method="moments"is used.
freq
vector the same length as x, giving frequencies. If supplied then results are equivalent to supplying rep(x, freq) instead of x.

VALUE:

a single value of skewness or kurtosis.

If y = x - mean(x), then the "moment" method computes the skewness as mean(y^3)/mean(y^2)^1.5 and the kurtosis as mean(y^4)/mean(y^2)^2 - 3. To see the "fisher" calculations, print out the default methods skewness.default or kurtosis.default.

DETAILS:

The "moment" forms are based on the definitions of skewness and kurtosis for distributions; these forms should be used when resampling (bootstrap or jackknife). The "fisher" forms correspond to the usual "unbiased" definition of sample variance, though in the case of skewness and kurtosis exact unbiasedness is not possible.

freq affects the Fisher adjustment but weights does not.

SEE ALSO:

.

EXAMPLES:

x <- runif(30) 
skewness(x) 
skewness(x, method="moment") 
skewness(x, weights = 1:30) 
skewness(x, freq = 1:30) 
kurtosis(x) 
kurtosis(x, method="moment")