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.
setup_PCoA(k = 2L, dist_method = "euclidean", features = NULL)PCoAConfig object.
Integer [1, Inf): Number of components. (passed to cmdscale k)
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.
Optional Character vector: Names of at least 2 distinct
feature columns to decompose. NULL decomposes all numeric features.
EDG
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.
pcoa_config <- setup_PCoA(k = 2L, dist_method = "bray")
pcoa_config
Run the code above in your browser using DataLab