EVOLUTION-MANAGER
Edit File: cmdscale.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Classical (Metric) Multidimensional Scaling</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for cmdscale {stats}"><tr><td>cmdscale {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Classical (Metric) Multidimensional Scaling</h2> <h3>Description</h3> <p>Classical multidimensional scaling (MDS) of a data matrix. Also known as <em>principal coordinates analysis</em> (Gower, 1966). </p> <h3>Usage</h3> <pre> cmdscale(d, k = 2, eig = FALSE, add = FALSE, x.ret = FALSE, list. = eig || add || x.ret) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>d</code></td> <td> <p>a distance structure such as that returned by <code>dist</code> or a full symmetric matrix containing the dissimilarities.</p> </td></tr> <tr valign="top"><td><code>k</code></td> <td> <p>the maximum dimension of the space which the data are to be represented in; must be in <i>{1, 2, …, n-1}</i>.</p> </td></tr> <tr valign="top"><td><code>eig</code></td> <td> <p>indicates whether eigenvalues should be returned.</p> </td></tr> <tr valign="top"><td><code>add</code></td> <td> <p>logical indicating if an additive constant <i>c*</i> should be computed, and added to the non-diagonal dissimilarities such that the modified dissimilarities are Euclidean.</p> </td></tr> <tr valign="top"><td><code>x.ret</code></td> <td> <p>indicates whether the doubly centred symmetric distance matrix should be returned.</p> </td></tr> <tr valign="top"><td><code>list.</code></td> <td> <p>logical indicating if a <code><a href="../../base/html/list.html">list</a></code> should be returned or just the <i>n * k</i> matrix, see ‘Value:’.</p> </td></tr> </table> <h3>Details</h3> <p>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’.) </p> <p>A set of Euclidean distances on <i>n</i> points can be represented exactly in at most <i>n - 1</i> dimensions. <code>cmdscale</code> follows the analysis of Mardia (1978), and returns the best-fitting <i>k</i>-dimensional representation, where <i>k</i> may be less than the argument <code>k</code>. </p> <p>The representation is only determined up to location (<code>cmdscale</code> 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 <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> platforms (see <code><a href="prcomp.html">prcomp</a></code>). </p> <p>When <code>add = TRUE</code>, a minimal additive constant <i>c*</i> is computed such that the dissimilarities <i>d[i,j] + c*</i> are Euclidean and hence can be represented in <code>n - 1</code> dimensions. Whereas S (Becker <em>et al</em>, 1988) computes this constant using an approximation suggested by Torgerson, <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> 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 <code>n - 1</code> dimensions. </p> <h3>Value</h3> <p>If <code>.list</code> is false (as per default), a matrix with <code>k</code> columns whose rows give the coordinates of the points chosen to represent the dissimilarities. </p> <p>Otherwise, a <code><a href="../../base/html/list.html">list</a></code> containing the following components. </p> <table summary="R valueblock"> <tr valign="top"><td><code>points</code></td> <td> <p>a matrix with up to <code>k</code> columns whose rows give the coordinates of the points chosen to represent the dissimilarities.</p> </td></tr> <tr valign="top"><td><code>eig</code></td> <td> <p>the <i>n</i> eigenvalues computed during the scaling process if <code>eig</code> is true. <strong>NB</strong>: versions of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> before 2.12.1 returned only <code>k</code> but were documented to return <i>n - 1</i>.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>the doubly centered distance matrix if <code>x.ret</code> is true.</p> </td></tr> <tr valign="top"><td><code>ac</code></td> <td> <p>the additive constant <i>c*</i>, <code>0</code> if <code>add = FALSE</code>.</p> </td></tr> <tr valign="top"><td><code>GOF</code></td> <td> <p>a numeric vector of length 2, equal to say <i>(g.1,g.2)</i>, where <i>g.i = (sum{j=1..k} λ[j]) / (sum{j=1..n} T.i(λ[j]))</i>, where <i>λ[j]</i> are the eigenvalues (sorted in decreasing order), <i>T.1(v) = abs(v)</i>, and <i>T.2(v) = max(v, 0)</i>. </p> </td></tr> </table> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988). <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <p>Cailliez, F. (1983). The analytical solution of the additive constant problem. <em>Psychometrika</em>, <b>48</b>, 343–349. doi: <a href="https://doi.org/10.1007/BF02294026">10.1007/BF02294026</a>. </p> <p>Cox, T. F. and Cox, M. A. A. (2001). <em>Multidimensional Scaling</em>. Second edition. Chapman and Hall. </p> <p>Gower, J. C. (1966). Some distance properties of latent root and vector methods used in multivariate analysis. <em>Biometrika</em>, <b>53</b>, 325–328. doi: <a href="https://doi.org/10.2307/2333639">10.2307/2333639</a>. </p> <p>Krzanowski, W. J. and Marriott, F. H. C. (1994). <em>Multivariate Analysis. Part I. Distributions, Ordination and Inference.</em> London: Edward Arnold. (Especially pp. 108–111.) </p> <p>Mardia, K.V. (1978). Some properties of classical multidimensional scaling. <em>Communications on Statistics – Theory and Methods</em>, <b>A7</b>, 1233–41. doi: <a href="https://doi.org/10.1080/03610927808827707">10.1080/03610927808827707</a> </p> <p>Mardia, K. V., Kent, J. T. and Bibby, J. M. (1979). Chapter 14 of <em>Multivariate Analysis</em>, London: Academic Press. </p> <p>Seber, G. A. F. (1984). <em>Multivariate Observations</em>. New York: Wiley. </p> <p>Torgerson, W. S. (1958). <em>Theory and Methods of Scaling</em>. New York: Wiley. </p> <h3>See Also</h3> <p><code><a href="dist.html">dist</a></code>. </p> <p><code><a href="../../MASS/html/isoMDS.html">isoMDS</a></code> and <code><a href="../../MASS/html/sammon.html">sammon</a></code> in package <a href="https://CRAN.R-project.org/package=MASS"><span class="pkg">MASS</span></a> provide alternative methods of multidimensional scaling. </p> <h3>Examples</h3> <pre> require(graphics) loc <- cmdscale(eurodist) x <- loc[, 1] y <- -loc[, 2] # reflect so North is at the top ## note asp = 1, to ensure Euclidean distances are represented correctly plot(x, y, type = "n", xlab = "", ylab = "", asp = 1, axes = FALSE, main = "cmdscale(eurodist)") text(x, y, rownames(loc), cex = 0.6) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>