ced: Compositional error distance

View source: R/ced.R

cedR Documentation

Compositional error distance

Description

Normalised Aitchison distance between an original and an imputed (or otherwise modified) compositional data set, used to evaluate imputation methods.

Usage

ced(x, y, ni)

Arguments

x

matrix or data frame with the original compositions: strictly positive values, no missing values.

y

matrix or data frame of the same dimensions as x, e.g. the imputed data set; an error is raised if the dimensions differ.

ni

positive number used for normalisation, typically the number of imputed or replaced values.

Details

The compositional error distance is the sum of the row-wise Aitchison distances between x and y, divided by ni,

\mathrm{ced}(X, Y) = \frac{1}{n_i}\sum_{i=1}^{n} d_a(x_i, y_i),

where d_a is the Aitchison distance (see aDist). Rows that are identical in x and y contribute zero. If ni is the number of imputed cells (e.g. sum(is.na(x)) before imputation, or the number of rounded zeros that were replaced), the result is the average error per imputed value, which makes results comparable across data sets with different numbers of missing values.

Columns are matched by position, not by name.

Value

The compositional error distance, a single non-negative number. If x and y are single-row data frames it is returned as a 1 x 1 matrix with the row names as dimnames, as in aDist.

Author(s)

Matthias Templ

References

Hron, K., Templ, M., Filzmoser, P. (2010). Imputation of missing values for compositional data using classical and robust methods. Computational Statistics and Data Analysis, 54 (12), 3095-3107. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.csda.2009.11.023")}

Templ, M., Hron, K., Filzmoser, P., Gardlo, A. (2016). Imputation of rounded zeros for high-dimensional compositional data. Chemometrics and Intelligent Laboratory Systems, 155, 183-190. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.chemolab.2016.04.011")}

See Also

aDist, rdcm, impKNNa, impCoda, imputeBDL

Examples

data(expenditures)
x <- expenditures
x[1, 3] <- NA
xi <- impKNNa(x)$xImp

# average Aitchison error per imputed value
ced(expenditures, xi, ni = sum(is.na(x)))

# without imputation error the distance is zero
ced(expenditures, expenditures, ni = 1)

robCompositions documentation built on Nov. 1, 2026, 1:06 a.m.