Learn R Programming

SciencesPo (version 1.3.9)

kurtosis: Compute the Kurtosis

Description

Return the kurtosis test for object x. For vectors, kurtosis(x) is the kurtosis of the elements in the vector x. For matrices kurtosis(x) returns the sample kurtosis for each column of x. For N-dimensional arrays, kurtosis operates along the first nonsingleton dimension of x.Returns the kurtosis test for object x. For vectors, kurtosis(x) is the kurtosis of the elements in the vector x. For matrices kurtosis(x) returns the sample kurtosis for each column of x. For N-dimensional arrays, kurtosis operates along the first nonsingleton dimension of x.

Usage

kurtosis(x, na.rm = FALSE, type = 2)

Arguments

x
a numeric vector
na.rm
a logical value for na.rm, default is na.rm=FALSE.
type
an integer between 1 and 3 selecting one of the algorithms for computing kurtosis detailed below

Value

  • An object of the same type as x.

encoding

UTF-8

Details

In a similar way of skewness, kurtosis measures the peakedness of a data distribution. A distribution with zero kurtosis has a shape as the normal curve. Such type of kurtosis is called mesokurtic, or mesokurtotic. A positive kurtosis has a curve more peaked about the mean and the its shape is narrower than the normal curve. Such type is called leptokurtic, or leptokurtotic. Finally, a distribution with negative kurtosis has a curve less peaked about the mean and the its shape is flatter than the normal curve. Such type is called platykurtic, or platykurtotic. To be consistent with classical use of kurtosis in political science analyses, the default type is the same equation used in SPSS and SAS, which is the bias-corrected formula: Type 2: G_2 = ((n + 1) g_2+6) * (n-1)/(n-2)(n-3). When you set type to 1, the following equation applies: Type 1: g_2 = m_4/m_2^2-3. When you set type to 3, the following equation applies: Type 3: b_2 = m_4/s^4-3 = (g_2+3)(1-1/n)^2-3. You must have at least 4 observations in your vector to apply this function.

References

Balanda, K. P. and H. L. MacGillivray. (1988) Kurtosis: A Critical Review. The American Statistician, 42(2), pp. 111--119.

Examples

Run this code
w<-sample(4,10, TRUE)
x <- sample(10, 1000, replace=TRUE, prob=w)

kurtosis(x, type=2)

kurtosis(x, type=3)

Run the code above in your browser using DataLab