Skip to contents

Computes the variation matrix (Aitchison 1986, definition 4.4).

Usage

variation(x, ...)

# S4 method for class 'CompositionMatrix'
variation(x)

Arguments

x

A CompositionMatrix object.

...

Currently not used.

Value

A matrix.

References

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

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

See also

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

Author

N. Frerebeau

Examples

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

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

## Variation matrix
## (Aitchison 1986, definition 4.4)
(varia <- variation(coda))
#>            A         B         C          D         E
#> A 0.00000000 0.2592742 1.5328586 0.08281464 0.1385604
#> B 0.25927416 0.0000000 3.0006804 0.54727146 0.6490135
#> C 1.53285862 3.0006804 0.0000000 1.11145146 0.9476375
#> D 0.08281464 0.5472715 1.1114515 0.00000000 0.1870579
#> E 0.13856035 0.6490135 0.9476375 0.18705791 0.0000000

## Cluster dendrogram
d <- as.dist(varia)
h <- hclust(d, method = "ward.D2")
plot(h)


## Heatmap
stats::heatmap(
  varia,
  distfun = stats::as.dist,
  hclustfun = function(x) stats::hclust(x, method = "ward.D2"),
  symm = TRUE,
  scale = "none"
)