perturbation: Perturbation of compositional data

View source: R/compositional_ops.R

perturbationR Documentation

Perturbation of compositional data

Description

The perturbation operation combines two compositions by component-wise multiplication and then applies closure to ensure the result remains a valid composition.

Usage

perturbation(X, Y)

Arguments

X

A numeric vector, matrix or data.frame containing compositions.

Y

A numeric vector, matrix or data.frame with the same number of parts as X. If one input is a matrix or data.frame and the other is a vector, the vector is applied to every row. If both inputs are matrices or data.frames, they must have the same dimensions, or Y may contain a single composition to be applied to all rows of X.

Details

Perturbation is the analogue of addition in the simplex. Each part of X is multiplied by the corresponding part of Y, and the result is closed with closure so that each composition has constant sum.

Value

An object with the same format as X containing the perturbed compositions, except that vector X with matrix or data.frame Y returns the same rectangular format as Y.

Examples

x <- c(a = 1, b = 2, c = 3)
y <- c(a = 1, b = 1, c = 2)
perturbation(x, y)

X <- rbind(
  c(1, 2, 3),
  c(4, 5, 6)
)
perturbation(X, c(1, 1, 2))
perturbation(c(1, 1, 2), X)


coda.base documentation built on May 8, 2026, 5:10 p.m.