Learn R Programming

fastmatrix (version 0.5-7721)

moments: Central moments

Description

It calculates up to fourth central moments (or moments about the mean), and the skewness and kurtosis coefficients using an online algorithm.

Usage

moments(x)

Value

A list containing second, third and fourth central moments, and skewness and kurtosis coefficients.

Arguments

x

a numeric vector containing the sample observations.

Details

The \(k\)-th central moment is defined as $$m_k = \frac{1}{n}\sum_{i=1}^n (x_i - \overline{x})^k.$$ In particular, the second central moment is the variance of the sample. The sample skewness and kurtosis are defined, respectively, as $$b_1 = \frac{m_3}{m_2^{3/2}}, \qquad b_2 = \frac{m_4}{m_2^2}.$$

References

Spicer, C.C. (1972). Algorithm AS 52: Calculation of power sums of deviations about the mean. Applied Statistics 21, 226-227.

See Also

Examples

Run this code
set.seed(149)
x <- rnorm(1000)
z <- moments(x)
z

Run the code above in your browser using DataLab