setup_PCoA: Setup PCoA config.

View source: R/150_DecompositionConfig.R

setup_PCoAR Documentation

Setup PCoA config.

Description

Principal coordinates analysis, also called classical or Torgerson multidimensional scaling: an eigendecomposition of the doubly centered squared dissimilarities between cases, with stats::cmdscale(). With dist_method = "euclidean" the components equal PCA scores of the centered, unscaled data, up to sign; other dissimilarities are what PCoA is for.

Usage

setup_PCoA(k = 2L, dist_method = "euclidean", features = NULL)

Arguments

k

Integer [1, Inf): Number of components. (passed to cmdscale k)

dist_method

Character {"euclidean", "manhattan", "chord", "bray", "canberra", "jaccard", "kulczynski", "hellinger"}: Dissimilarity between cases, computed with vegan::vegdist(). "bray", "canberra", "jaccard", "kulczynski" and "hellinger" require non-negative data.

features

Optional Character vector: Names of at least 2 distinct feature columns to decompose. NULL decomposes all numeric features.

Details

PCoA applies to new data with Gower's (1968) out-of-sample formula, from the dissimilarities between each new case and the training cases, so it can be used as the decomposition step in train. Applying a fit to its own training data reproduces the fitted components. Because those dissimilarities are needed, the fit keeps the training feature matrix, and its size grows with the number of training cases.

Dissimilarities other than "euclidean", "chord" and "hellinger" generally give some negative eigenvalues; only dimensions with positive eigenvalues are returned, and asking for more is an error that states how many there are. reconstruct does not apply.

Value

PCoAConfig object.

Author(s)

EDG

Examples

pcoa_config <- setup_PCoA(k = 2L, dist_method = "bray")
pcoa_config

rtemis documentation built on Oct. 20, 2026, 1:06 a.m.