Learn R Programming

nexus (version 0.3.0)

variance: Log-Ratios Variances

Description

Computes log-ratio (weighted) variances.

Usage

variance(x, ...)

# S4 method for LogRatio variance(x, row_weights = NULL, column_weights = TRUE)

Value

A numeric vector of individual variances.

Arguments

x

A CompositionMatrix object.

...

Currently not used.

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.

Author

N. Frerebeau

References

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_total(), variation()

Examples

Run this code
## Data from Aitchison 1986
data("hongite")

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

## Total variance (1)
variance_total(coda)

## Metric standard deviation
variance_total(coda, sd = TRUE)

## CLR transformation
clr <- transform_clr(coda)

## Individual log-ratio variances
variance(clr)

## Total log-ratio variance (2)
variance_total(clr)

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

Run the code above in your browser using DataLab