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.
Arguments
- k
Integer [1, Inf): Number of components. (passed to
cmdscalek)- 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.
NULLdecomposes 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.