Skip to contents

Scaling and Centering of Compositional Data

Usage

# S4 method for CompositionMatrix
scale(x, center = TRUE, scale = TRUE)

Arguments

x

A CompositionMatrix object.

center

A logical scalar or a numeric vector giving the center to be substracted.

scale

A logical scalar or a length-one numeric vector giving a scaling factor for multiplication.

Value

A CompositionMatrix object.

References

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

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 .

See also

Other statistics: aggregate(), covariance(), dist, mahalanobis(), margin(), mean(), metric_var(), quantile(), variation()

Author

N. Frerebeau

Examples

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

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

## Center and scale
scaled <- scale(coda, center = TRUE, scale = TRUE)
mean(scaled)
#>   A   B   C   D   E 
#> 0.2 0.2 0.2 0.2 0.2 
head(scaled)
#> <CompositionMatrix: 6 x 5>
#>             A          B          C          D          E
#> H1 0.21634296 0.40851878 0.04204451 0.09427149 0.23882226
#> H2 0.19541817 0.23027129 0.17084651 0.16234092 0.24112312
#> H3 0.05406075 0.01921842 0.73935593 0.07477711 0.11258779
#> H4 0.23277503 0.24975389 0.12625644 0.20672500 0.18448965
#> H5 0.17430188 0.54016862 0.02523291 0.12375232 0.13654426
#> H6 0.25315982 0.30580853 0.05187680 0.30958887 0.07956597