# This function produces a scree plot of dimensions against stress of a k-dimensional nonmetrical MDS solution. Arguments are: # d: a distance matrix # k: the maximum number of dimensions to be considered, must be # smaller than the number of taxa/objects. # To use this founction, source this file into R or simply copy the code below and then type scree.plot(d, k) to get the plot. scree.plot = function(d, k) { stresses=isoMDS(d, k=k)$stress for(i in rev(seq(k-1))) stresses=append(stresses,isoMDS(d, k=i)$stress) plot(seq(k),rev(stresses), type="b", xaxp=c(1,k, k-1), ylab="Stress", xlab="Number of dimensions") }