Classical Multidimensional Scaling¶
In general, Multidimensional Scaling (MDS) refers to techniques that transforms samples into lower dimensional space while preserving the intersample distances as well as possible.
Overview of Classical MDS¶
Classical MDS is a specific technique in this family that accomplishes the embedding in two steps:
Convert the distance matrix to a Gram matrix.
This conversion is based on the following relations between a distance matrix
D
and a Gram matrixG
:Here, indicates the elementwise square of , and is the diagonal elements of . This relation is itself based on the following decomposition of squared Euclidean distance:
Perform eigenvalue decomposition of the Gram matrix to derive the coordinates.
Functions¶
This package provides functions related to classical MDS.

gram2dmat
(G)¶ Convert a Gram matrix
G
to a distance matrix.

gram2dmat!(D, G)
Convert a Gram matrix
G
to a distance matrix, and write the results toD
.

dmat2gram
(D)¶ Convert a distance matrix
D
to a Gram matrix.

dmat2gram!(G, D)
Convert a distance matrix
D
to a Gram matrix, and write the results toG
.

classical_mds
(D, p[, dowarn=true])¶ Perform classical MDS. This function derives a
p
dimensional embedding based on a given distance matrixD
.It returns a coordinate matrix of size
(p, n)
, where each column is the coordinates for an observation.Note
The Gramian derived from
D
may have nonpositive or degenerate eigenvalues. The subspace of nonpositive eigenvalues is projected out of the MDS solution so that the strain function is minimized in a leastsquares sense. If the smallest remaining eigenvalue that is used for the MDS is degenerate, then the solution is not unique, as any linear combination of degenerate eigenvectors will also yield a MDS solution with the same strain value. By default, warnings are emitted if either situation is detected, which can be suppressed withdowarn=false
.If the MDS uses an eigenspace of dimension
m
less thanp
, then the MDS coordinates will be padded withpm
zeros each.Reference:
@inbook{Borg2005, Author = {Ingwer Borg and Patrick J. F. Groenen}, Title = {Modern Multidimensional Scaling: Theory and Applications}, Edition = {2}, Year = {2005}, Chapter = {12}, Doi = {10.1007/038728981X}, Pages = {201268}, Series = {Springer Series in Statistics}, Publisher = {Springer}, }