Computes log-ratio (weighted) variances.
Usage
variance(x, ...)
# S4 method for class 'LogRatio'
variance(x, row_weights = NULL, column_weights = TRUE)
Arguments
- x
A
CompositionMatrix
object.- ...
Currently not used.
- row_weights
A
numeric
vector of row weights. IfNULL
(the default), equal weights are used.- column_weights
A
logical
scalar: should the weights of the log-ratio be used? IfFALSE
, equally-weighted parts are used. Alternatively, a positivenumeric
vector of weights can be specified.
Value
A numeric
vector of individual variances.
See also
Other statistics:
aggregate()
,
condense()
,
covariance()
,
dist
,
mahalanobis()
,
margin()
,
mean()
,
pip()
,
quantile()
,
scale()
,
variance_total()
,
variation()
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