cmdscale {stats} | R Documentation |
Classical multidimensional scaling (MDS) of a data matrix. Also known as principal coordinates analysis (Gower, 1966).
cmdscale(d,
k = 2,
.list = FALSE);
Multidimensional scaling takes a set of dissimilarities and returns a set of points such that the distances between the points are approximately equal to the dissimilarities. (It is a major part of what ecologists call ‘ordination’.) A set of Euclidean distances on n points can be represented exactly in at most n−1 dimensions. cmdscale follows the analysis of Mardia (1978), and returns the best-fitting k-dimensional representation, where k may be less than the argument k. The representation is only determined up to location (cmdscale takes the column means of the configuration to be at the origin), rotations and reflections. The configuration returned is given in principal-component axes, so the reflection chosen may differ between R platforms (see prcomp). When add = TRUE, a minimal additive constant c∗ is computed such that the dissimilarities dij +c∗ are Euclidean and hence can be represented in n - 1 dimensions. Whereas S (Becker et al, 1988) computes this constant using an approximation suggested by Torgerson, R uses the analytical solution of Cailliez (1983), see also Cox and Cox (2001). Note that because of numerical errors the computed eigenvalues need not all be non-negative, and even theoretically the representation could be in fewer than n - 1 dimensions.
If .list
is false (as per default), a matrix with k columns whose rows give the coordinates of the points chosen to represent the dissimilarities.
Otherwise, a list containing the following components.
+ points: a matrix with up to k columns whose rows give the coordinates of the points chosen to represent the dissimilarities.
+ eig: the n eigenvalues computed during the scaling process if eig is true. NB: versions of R before 2.12.1 returned only k but were documented to return n−1.
+ x: the doubly centered distance matrix if x.ret is true.
+ ac: the additive constant c∗, 0 if add = FALSE.
+ GOF: a numeric vector of length 2, equal to say (g1 ,g2), where gi =(∑j=1,k λj )/(∑j=1,n Ti (λj )), where
λj are the eigenvalues (sorted in decreasing order), T1 (v)=∣v∣, and T2 (v)=max(v,0).