moments: Sample-generated moments.

Description Usage Arguments Value Note Examples

View source: R/moments.R

Description

Moments describe the shape of distributions, and the four most familiar are generally known by their plebeian names: Mean, Variance, Skewness, and Kurtosis. For the further initiated, these might be recognized as the first, second, third, and fourth order moments, respectively. The potential number of orders is infinite, but only the first four are commonly taken into account.

In addition to orders, moments can be further classified into types, most commonly labelled the "Raw", "Central", and "Standardized" moments. The most familiar moments are usually not expressed in the same types. That is, the first-order moment (mean) is expressed as Raw-, the second-order (variance) as Central-, and the third- and fourth-order (skewness and kurtosis, respectively) as Standardized-type.

Usage

1
2
moments(x, type = c("raw", "central", "standardized"), orders = 4,
  correct = TRUE)

Arguments

x

A vector of numerical values (i.e., a variable).

type

A character vector indicating which types of moments are to be calculated. Permissible values are "raw", "central", and "standardized". The default is to compute all types.

orders

A numeric value indicating the number of moment orders are to be calculated for each type (e.g., 1 yields mean, 2 yields mean and variance). The default is to compute the first four moments.

correct

A logical value indicating whether the calculations for central- and standardized moments should take degrees of freedom into account (i.e., bias correction).

Value

A list of up to three elements (depending on how many moment types were asked for), each containing one entry for every type-moment order that was to be calculated.

Note

Missing values are treated by way of na.omit.

Examples

1
2
3
4
5
data <- expand.table(LSAT7)
var1_moments <- moments(data[, 1])
# Retrieve the third-order standardized moment (i.e., skewness) for the
# first variable of the LSAT7 data-set.
var1_moments$standardized[[3]]

hthaa/cacPlot documentation built on Dec. 18, 2019, 4:34 a.m.