R Programming/Ordination

Overview
This page provides basic code for creating a distance matrix and running and plotting a Non-metric Multidimensional Scaling (NMDS) ordination.

Read more about Ordination on Wikipedia.

This code relies on package vegan in R by Jari Oksanen.

Data
First, import data and load required libraries:

Distance matrix
= Unconstrained Ordination =

Displaying dissimilarity using NMDS
NMDS analysis and plotting:



In the metaMDS function, k is user-defined and relates to how easily the projection fits the dataframe when constrained to k dimensions. Conventional wisdom seems to suggest that stress should not exceed 10-12%. Stress is reduced by increasing the number of dimensions. However, increasing dimensionality might decrease the "realism" of a 2-dimensional plot of the first two NMDS axes.

We can also run a nMDS with 3 dimensions, fit environmental vectors and create a dynamic graph:

Running a principle component analysis (PCA) on environmental data


= Constrained Ordination =