Skip to contents

Computes the total (or metric) variance, a global measure of spread.

Usage

variance_total(x, ...)

# S4 method for class 'CompositionMatrix'
variance_total(x, sd = FALSE)

# S4 method for class 'LogRatio'
variance_total(x, row_weights = NULL, column_weights = TRUE)

Arguments

x

A CompositionMatrix object.

...

Currently not used.

sd

A logical scalar: should the metric standard deviation be returned instead of the metric variance?

row_weights

A numeric vector of row weights. If NULL (the default), equal weights are used.

column_weights

A logical scalar: should the weights of the log-ratio be used? If FALSE, equally-weighted parts are used. Alternatively, a positive numeric vector of weights can be specified.

Value

A numeric vector.

Details

Two methods are available, see below.

Methods (by class)

  • variance_total(CompositionMatrix): The total variance of compositional data is the trace of the centred log-ratio covariance matrix (i.e. totvar1 in Aitchison 1997).

  • variance_total(LogRatio): Computes the total log-ratio variance. This is identical to the weighted sum-of-squared distances between samples (i.e. totvar2 in Aitchison 1997).

References

Aitchison, J. (1986). The Statistical Analysis of Compositional Data. London: Chapman and Hall, p. 64-91.

Aitchison, J. (1997). The One-Hour Course in Compositional Data Analysis or Compositional Data Analysis Is Simple. In V. Pawlowsky-Glahn (ed.), IAMG'97. Barcelona: International Center for Numerical Methods in Engineering (CIMNE), p. 3-35.

Boogaart, K. G. van den & Tolosana-Delgado, R. (2013). Analyzing Compositional Data with R. Berlin Heidelberg: Springer-Verlag. doi:10.1007/978-3-642-36809-7 .

Greenacre, M. J. (2019). Compositional Data Analysis in Practice. Boca Raton: CRC Press.

Hron, K. & Kubáček. L. (2011). Statistical Properties of the Total Variation Estimator for Compositional Data. Metrika, 74 (2): 221-230. doi:10.1007/s00184-010-0299-3 .

Pawlowsky-Glahn, V. & Egozcue, J. J. (2001). Geometric Approach to Statistical Analysis on the Simplex. Stochastic Environmental Research and Risk Assessment, 15(5): 384-398. doi:10.1007/s004770100077 .

See also

Other statistics: aggregate(), condense(), covariance(), dist, mahalanobis(), margin(), mean(), pip(), quantile(), scale(), variance(), variation()

Author

N. Frerebeau

Examples

## Data from Aitchison 1986
data("hongite")

## Coerce to compositional data
coda <- as_composition(hongite)

## Total variance (1)
variance_total(coda)
#> [1] 1.691324

## Metric standard deviation
variance_total(coda, sd = TRUE)
#> [1] 0.6502546

## CLR transformation
clr <- transform_clr(coda)

## Individual log-ratio variances
variance(clr)
#>           A           B           C           D           E 
#> 0.012371857 0.106172753 0.188210073 0.009111225 0.008868299 

## Total log-ratio variance (2)
variance_total(clr)
#> [1] 0.3247342

## Proportionality between (1) and (2)
## See Aitchison 1997
variance_total(coda) * (1 / ncol(coda)) * (1 - (1 / nrow(coda)))
#> [1] 0.3247342