• var() computes the log-ratio variance matrix.

• cov() computes the log-ratio covariance matrix.

## Usage

# S4 method for CompositionMatrix
var(x)

# S4 method for CompositionMatrix
cov(x)

## Arguments

x

A CompositionMatrix object.

## Value

A matrix.

## References

Aitchison, J. (1986). The Statistical Analysis of Compositional Data. London: Chapman and Hall, p. 64-91. doi:10.1007/978-94-009-4109-0 .

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

Other statistics: aggregate(), dist(), mahalanobis(), mean(), variation()

N. Frerebeau

## Examples

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

## Variance matrix
var(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

## Covariance matrix
cov(coda)
#>             A_B        A_C         A_D         A_E        B_C         B_D
#> A_B  0.25927416 -0.6042738 -0.10259133 -0.12558948 -0.8635479 -0.36186549
#> A_C -0.60427379  1.5328586  0.25211090  0.36189072  2.1371324  0.85638469
#> A_D -0.10259133  0.2521109  0.08281464  0.01715854  0.3547022  0.18540597
#> A_E -0.12558948  0.3618907  0.01715854  0.13856035  0.4874802  0.14274802
#> B_C -0.86354795  2.1371324  0.35470223  0.48748020  3.0006804  1.21825018
#> B_D -0.36186549  0.8563847  0.18540597  0.14274802  1.2182502  0.54727146
#> B_E -0.38486364  0.9661645  0.11974987  0.26414983  1.3510281  0.50461351
#> C_D  0.50168246 -1.2807477 -0.16929626 -0.34473217 -1.7824302 -0.67097871
#> C_E  0.47868431 -1.1709679 -0.23495236 -0.22333036 -1.6496522 -0.71363666
#> D_E -0.02299815  0.1097798 -0.06565610  0.12140181  0.1327780 -0.04265795
#>            B_E        C_D        C_E         D_E
#> A_B -0.3848636  0.5016825  0.4786843 -0.02299815
#> A_C  0.9661645 -1.2807477 -1.1709679  0.10977982
#> A_D  0.1197499 -0.1692963 -0.2349524 -0.06565610
#> A_E  0.2641498 -0.3447322 -0.2233304  0.12140181
#> B_C  1.3510281 -1.7824302 -1.6496522  0.13277797
#> B_D  0.5046135 -0.6709787 -0.7136367 -0.04265795
#> B_E  0.6490135 -0.8464146 -0.7020147  0.14439996
#> C_D -0.8464146  1.1114515  0.9360155 -0.17543592
#> C_E -0.7020147  0.9360155  0.9476375  0.01162200
#> D_E  0.1444000 -0.1754359  0.0116220  0.18705791

## Variation matrix
variation(coda)
#>           A         B           C          D         E
#> A 0.0000000 0.2592742  1.53285862 0.08281464 0.1385604
#> B 0.8011244 0.0000000  3.00068035 0.54727146 0.6490135
#> C 1.5999805 0.7988561  0.00000000 1.11145146 0.9476375
#> D 1.5483008 0.7471764 -0.05167973 0.00000000 0.1870579
#> E 1.7152103 0.9140859  0.11522977 0.16690950 0.0000000