Learn R Programming

rtemis (version 1.4.3)

setup_PCoA: 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)

Value

PCoAConfig object.

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.

Author

EDG

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.

Examples

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

Run the code above in your browser using DataLab