Skip to content

Multidimensional scaling

Recover coordinates from pairwise distances with classical MDS, diagnose non-Euclidean dissimilarities and distinguish Gram reconstruction from stress fitting.

Multidimensional scaling (MDS) places objects in a coordinate space so that their separation represents supplied pairwise dissimilarities. For a quant researcher, this provides a map of assets or strategies when the starting information is a distance table rather than a convenient set of plotting coordinates. The usefulness of that map depends on the distance definition and how much distortion the chosen dimension introduces.
MDS is a family of dimensionality-reduction methods. Classical MDS, the focus here, reconstructs inner products from squared distances and uses an eigendecomposition to obtain coordinates. A dissimilarity need not come from an actual Euclidean geometry; that distinction becomes visible in the eigenvalues.

Recovering three points from distances

Imagine three fictional objects, A, B and C, with dimensionless distances

D=(013102320).D=\begin{pmatrix} 0&1&3\\ 1&0&2\\ 3&2&0 \end{pmatrix}.

One configuration producing these distances is 0,1,30,1,3 on a line. Suppose those original coordinates are unavailable. Classical MDS can recover a centred configuration directly from DD.

First square each entry to make D∘2D^{\circ 2}, so its first row is (0,1,9)(0,1,9). This is not the matrix product DDD D. With nn objects, define the centring matrix and the doubly centred result
J=I−1n11T,B=−12JD∘2J.J=I-\frac{1}{n}\mathbf{1}\mathbf{1}^{\mathsf T}, \qquad B=-\frac12 J D^{\circ 2}J.
Here II is the identity and 1\mathbf{1} is the all-ones column vector. Equivalently, each BijB_{ij} is minus one half of the squared distance after subtracting its row mean and column mean and adding the grand mean. For Euclidean distances, BB is the Gram matrix of the centred points: B=XXTB=XX^{\mathsf T}. The standard reconstruction is described in Lichtenberg and Tasissa’s introduction.

For the three objects,

B=19(164−2041−5−20−525)=xxT,x=(−4/3−1/35/3).B=\frac19\begin{pmatrix} 16&4&-20\\ 4&1&-5\\ -20&-5&25 \end{pmatrix} =\mathbf{x}\mathbf{x}^{\mathsf T}, \qquad \mathbf{x}=\begin{pmatrix}-4/3\\-1/3\\5/3\end{pmatrix}.
The sole nonzero eigenvalue is
λ1=xTx=16+1+259=143.\lambda_1=\mathbf{x}^{\mathsf T}\mathbf{x} =\frac{16+1+25}{9}=\frac{14}{3}.

Thus BB has rank one. If u1\mathbf{u}_1 is its unit eigenvector for λ1\lambda_1, the coordinate column λ1u1\sqrt{\lambda_1}\mathbf{u}_1 equals either x\mathbf{x} or −x-\mathbf{x}. Its distances are exactly 1,2,31,2,3 for A–B, B–C and A–C.

Three dimensionless configurations have identical A–B, B–C and A–C distances of 1, 2 and 3. Original positions are 0, 1, 3; centred positions are minus 4/3, minus 1/3, 5/3; reflected positions are 4/3, 1/3, minus 5/3. Gram eigenvalues are 14/3, 0, 0.
Three dimensionless configurations have identical A–B, B–C and A–C distances of 1, 2 and 3. Original positions are 0, 1, 3; centred positions are minus 4/3, minus 1/3, 5/3; reflected positions are 4/3, 1/3, minus 5/3. Gram eigenvalues are 14/3, 0, 0.
Original dimensionless toy geometry on a common coordinate scale. Centring and reflection change the coordinates while preserving every pairwise distance; the rank-one Gram matrix requires only one dimension.
The original origin cannot be recovered from distances. Neither can an absolute orientation: a translated, rotated or reflected configuration has the same separations. Classical MDS conventionally centres the coordinates. A sign reversal between two one-dimensional software outputs is therefore compatible with an identical result. R’s classical MDS documentation makes these invariances explicit.

What happens when one dimension is insufficient?

For a general BB, take its eigenvectors and corresponding eigenvalues in descending order. Keeping kk positive eigenvalues gives

Xk=UkΛk1/2,X_k=U_k\Lambda_k^{1/2},
where UkU_k holds the selected unit eigenvectors and Λk\Lambda_k their eigenvalues on the diagonal. Each row of XkX_k gives one object’s coordinates. If the distances are Euclidean and all positive eigenvalues are retained, reconstruction is exact. Keeping fewer dimensions generally changes distances. Classical truncation approximates the centred Gram matrix in squared Frobenius error; it does not generally minimise squared error in the original distances. With ordinary Euclidean distances calculated from a feature table, classical MDS produces the centred PCA configuration, up to the usual coordinate ambiguities. Scikit-learn’s ClassicalMDS reference explains this PCA equivalence.
For a symmetric, nonnegative dissimilarity matrix with zero diagonal, exact Euclidean representability requires BB to be positive semidefinite. A materially negative eigenvalue signals a failure of that condition. Tiny negative values near numerical precision can instead be rounding error; examine their scale relative to the spectrum.

Even a valid distance metric need not be Euclidean. Consider four corners of a unit square, using Manhattan distance: neighbouring corners are distance 11 apart and opposite corners distance 22. The resulting BB has eigenvalues 2,2,0,−12,2,0,-1. These distances obey the triangle inequality but cannot all be reproduced as Euclidean separations. Dropping the negative eigenvalue gives an approximation, rather than repairing the input without changing its meaning.

Classical, metric stress and nonmetric MDS

The label “metric MDS” is sometimes used broadly enough to include classical scaling. When comparing algorithms, state the objective:

MethodWhat is fitted
Classical MDSA low-rank positive-semidefinite approximation to the doubly centred squared-distance matrix.
Metric stress MDSEmbedding distances fitted directly to numerical dissimilarities, for example by minimising raw stress.
Nonmetric MDSEmbedding distances fitted to monotone transformations of the dissimilarities, emphasising their ordering.

For the unweighted raw-stress convention in the middle row,

Stress⁡(Z)=∑i<j(Dij−∥zi−zj∥)2.\operatorname{Stress}(Z)=\sum_{i<j} \left(D_{ij}-\lVert\mathbf{z}_i-\mathbf{z}_j\rVert\right)^2.
Nonmetric fitting replaces DijD_{ij} by fitted disparities constrained to be monotone in the input dissimilarities. It seeks to preserve ranks; it does not promise exact rank preservation in a constrained low-dimensional fit. Normalisation, weights and treatment of ties vary, so a reported “stress” number needs its definition. These distinctions follow the scikit-learn MDS guide.

Read an asset map as a description of a chosen distance

Before interpreting a financial embedding, record what an object represents, the observation window, the missing-data rule and the distance construction. Distances between raw return vectors can be dominated by volatility; distances after standardisation answer a different question. Changing the construction changes the map’s economic interpretation.

Check reconstructed distances against the input, including which pairs are distorted. A low-dimensional plot alone does not establish clusters, causal relationships or a trading opportunity. In a rolling analysis, even a rotation or reflection can make unchanged geometry appear to move; align configurations before interpreting coordinate changes, then distinguish alignment effects from changes in the underlying distances.
The Nonlinear Dimensionality Reduction: t-SNE and Manifold Learning lesson compares global distance preservation with local manifold methods and discusses visualisation limits. Its public page is a preview; the full lesson requires membership.

Sources

Last updated
  • multidimensional scaling
  • distance
  • dimensionality reduction
  • eigendecomposition
← Back to the glossaryBack to top ↑