Theory, Examples & Exercises
This is an old revision of the document!
This method is also known as MDS (Metric Multidimensional Scaling). While PCA preserves Euclidean distances among samples and CA chi-square distances, PCoA provides Euclidean representation of a set of objects whose relationship is measured by any similarity or distance measure chosen by the user. As well as PCA and CA, PCoA returns a set of orthogonal axes whose importance is measured by eigenvalues. This means that calculating PCoA on Euclidean distances among samples yields the same results as PCA calculated on covariance matrix of the same dataset (if scaling 1 is used).
vegan) - calculates PCoA on matrix of distances among samples (this could be calculated e.g. by function
vegan). Use function
ordiplotto project the ordination diagram.
ape) - another way how to achieve PCoA analysis. Use
biplot.pcoafunction to project ordination diagram.
Non-metric alternative to PCoA analysis - it can use any distance measure among samples, and the main focus is on projecting the relative position of sample points into low dimensional ordination space (two or three axes). The method is distance based, not eigenvalue based - it means that it does not attempt to maximize the variance preserved by particular ordination axes and resulting projection could therefore be rotated in any direction.
The algorithm goes like this (simplified):
vegan) - rather advanced function, composed of many subroutine steps. See example below for details.
vegan) - draws Shepards stress plot, which is the relationship between real distances between samples in resulting m dimensional ordination solution, and their particular compositional dissimilarities expressed by selected dissimilarity measure.
vegan) - returns goodness-of-fit of particular samples. See example how can be this result visualized (inspired by Borcard et al. 2011).
vltava.spe <- read.delim ('http://www.davidzeleny.net/anadat-r/data-download/vltava-spe.txt', row.names = 1) NMDS <- metaMDS (vltava.spe) NMDS
Call: metaMDS(comm = vltava.spe) Nonmetric Multidimensional Scaling using isoMDS (MASS package) Data: wisconsin(sqrt(vltava.spe)) Distance: bray Dimensions: 2 Stress: 21.66520 Two convergent solutions found after 3 tries Scaling: centring, PC rotation, halfchange scaling Species: expanded scores based on ‘wisconsin(sqrt(vltava.spe))’
If the default setting of metaMDS function is used, the data are automatically (if necessary) transformed (in this case, combination of wisconsin and sqrt transformation was used). In this case, stress value is 21.7.
par (mfrow = c(1,2)) # this function divides plotting window into two columns stressplot (NMDS) plot (NMDS, display = 'sites', type = 't', main = 'Goodness of fit') # this function draws NMDS ordination diagram with sites points (NMDS, display = 'sites', cex = goodness (NMDS)*2) # and this adds the points with size reflecting goodness of fit (bigger = worse fit)
Use data from the variable
eurodist, which is available in R (you don't need to install any library, just type
eurodist). This variable contains real geographical distances among big European cities (in km).
Use data about confusion of different Morse codes, originating from Rothkopf's experiment with Morse codes. This is a classical data set, used by Shepard (1962)1) to demonstrate the use of NMDS analysis.
Check the example Betadiversity of coral reefs after disturbance to apply NMDS analysis on community data from coral reefs.