setup_MDS: Setup MDS config.

View source: R/150_DecompositionConfig.R

setup_MDSR Documentation

Setup MDS config.

Description

Stress-minimizing multidimensional scaling with vegan::monoMDS(): finds k coordinates per case whose distances match the dissimilarities between cases as closely as possible, measured by Kruskal's stress-1. For classical (Torgerson) scaling, which solves an eigenproblem instead, see setup_PCoA.

Usage

setup_MDS(
  k = 2L,
  dist_method = "euclidean",
  model = "global",
  nstart = 20L,
  max_iter = 200L,
  features = NULL
)

Arguments

k

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

model

Character {"global", "local", "linear"}: "global" is nonmetric MDS (one monotone regression); "local" fits one monotone regression per case; "linear" is metric MDS. (passed to monoMDS model)

nstart

Integer [1, Inf): Number of starting configurations. 1 starts from the classical scaling solution only.

max_iter

Integer [1, Inf): Maximum number of iterations per start. (passed to monoMDS maxit)

features

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

Details

Each start runs vegan::monoMDS() from its own initial configuration, and the one with the lowest stress is kept. The first start is the classical scaling solution, stats::cmdscale(); if that has fewer than k dimensions with positive eigenvalues, the missing ones are random. Every other start is uniform on [-1, 1]. The random values come from R's random number generator, so the execution config's seed reproduces the fit. The final configuration is centered, scaled and rotated to its principal axes, so its components are uncorrelated, but the first j components of a k-dimensional solution are not the j-dimensional solution.

MDS cannot be applied to new data, so it cannot be used as the decomposition step in train, and reconstruct does not apply.

Value

MDSConfig object.

Author(s)

EDG

Examples

mds_config <- setup_MDS(k = 2L, dist_method = "manhattan")
mds_config

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