moments | R Documentation |
It calculates up to fourth central moments (or moments about the mean), and the skewness and kurtosis coefficients using an online algorithm.
moments(x)
x |
a numeric vector containing the sample observations. |
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}.
A list containing second
, third
and fourth
central moments,
and skewness
and kurtosis
coefficients.
Spicer, C.C. (1972). Algorithm AS 52: Calculation of power sums of deviations about the mean. Applied Statistics 21, 226-227.
var
.
set.seed(149)
x <- rnorm(1000)
z <- moments(x)
z
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.