metaMDS: Nonmetric Multidimensional Scaling with Stable Solution from...

Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples

Description

Function metaMDS performs Nonmetric Multidimensional Scaling (NMDS), and tries to find a stable solution using several random starts. In addition, it standardizes the scaling in the result, so that the configurations are easier to interpret, and adds species scores to the site ordination. The metaMDS function does not provide actual NMDS, but it calls another function for the purpose. Currently monoMDS is the default choice, and it is also possible to call the isoMDS (MASS package).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
metaMDS(comm, distance = "bray", k = 2, trymax = 20, 
    engine = c("monoMDS", "isoMDS"), autotransform =TRUE,
    noshare = (engine == "isoMDS"), wascores = TRUE, expand = TRUE, 
    trace = 1, plot = FALSE, previous.best,  ...)
## S3 method for class 'metaMDS'
plot(x, display = c("sites", "species"), choices = c(1, 2),
    type = "p", shrink = FALSE,  ...)
## S3 method for class 'metaMDS'
points(x, display = c("sites", "species"),
    choices = c(1,2), shrink = FALSE, select, ...)
## S3 method for class 'metaMDS'
text(x, display = c("sites", "species"), labels, 
    choices = c(1,2), shrink = FALSE, select, ...)
## S3 method for class 'metaMDS'
scores(x, display = c("sites", "species"), shrink = FALSE, 
    choices, ...)
metaMDSdist(comm, distance = "bray", autotransform = TRUE, 
    noshare = TRUE, trace = 1, commname, zerodist = "ignore", 
    distfun = vegdist, ...)
metaMDSiter(dist, k = 2, trymax = 20, trace = 1, plot = FALSE, 
    previous.best, engine = "monoMDS", maxit = 200,
    parallel = getOption("mc.cores"), ...)   
initMDS(x, k=2)
postMDS(X, dist, pc=TRUE, center=TRUE, halfchange, threshold=0.8,
    nthreshold=10, plot=FALSE, ...)
metaMDSredist(object, ...)

Arguments

comm

Community data. Alternatively, dissimilarities either as a dist structure or as a symmetric square matrix. In the latter case all other stages are skipped except random starts and centring and pc rotation of axes.

distance

Dissimilarity index used in vegdist.

k

Number of dimensions. NB., the number of points n should be n > 2*k + 1, and preferably higher in non-metric MDS.

trymax

Maximum number of random starts in search of stable solution.

engine

The function used for MDS. The default is to use the monoMDS function in vegan, but for backward compatibility it is also possible to use isoMDS of MASS.

autotransform

Use simple heuristics for possible data transformation of typical community data (see below). If you do not have community data, you should probably set autotransform = FALSE.

noshare

Triggering of calculation step-across or extended dissimilarities with function stepacross. The argument can be logical or a numerical value greater than zero and less than one. If TRUE, extended dissimilarities are used always when there are no shared species between some sites, if FALSE, they are never used. If noshare is a numerical value, stepacross is used when the proportion of site pairs with no shared species exceeds noshare. The number of pairs with no shared species is found with no.shared function, and noshare has no effect if input data were dissimilarities instead of community data.

wascores

Calculate species scores using function wascores.

expand

Expand weighted averages of species in wascores.

trace

Trace the function; trace = 2 or higher will be more voluminous.

plot

Graphical tracing: plot interim results. You may want to set par(ask = TRUE) with this option.

previous.best

Start searches from a previous solution.

x

metaMDS result (or a dissimilarity structure for initMDS.

choices

Axes shown.

type

Plot type: "p" for points, "t" for text, and "n" for axes only.

display

Display "sites" or "species".

shrink

Shrink back species scores if they were expanded originally.

labels

Optional test to be used instead of row names.

select

Items to be displayed. This can either be a logical vector which is TRUE for displayed items or a vector of indices of displayed items.

X

Configuration from multidimensional scaling.

commname

The name of comm: should not be given if the function is called directly.

zerodist

Handling of zero dissimilarities: either "fail" or "add" a small positive value, or "ignore". monoMDS accepts zero dissimilarities and the default is zerodist = "ignore", but with isoMDS you may need to set zerodist = "add".

distfun

Dissimilarity function. Any function returning a dist object and accepting argument method can be used (but some extra arguments may cause name conflicts).

maxit

Maximum number of iterations in the single NMDS run; passed to the engine function monoMDS or isoMDS.

parallel

Number of parallel processes or a predefined socket cluster. If you use pre-defined socket clusters (say, clus), you must issue clusterEvalQ(clus, library(vegan)) to make available internal vegan functions. With parallel = 1 uses ordinary, non-parallel processing. The parallel processing is done with parallel package.

dist

Dissimilarity matrix used in multidimensional scaling.

pc

Rotate to principal components.

center

Centre the configuration.

halfchange

Scale axes to half-change units. This defaults TRUE when dissimilarities were evaluated within metaMDS and the dissimilarity index has an upper limit of 1. If FALSE, the ordination dissimilarities are scaled to the same range as the input dissimilarities.

threshold

Largest dissimilarity used in half-change scaling.

nthreshold

Minimum number of points in half-change scaling.

object

A result object from metaMDS.

...

Other parameters passed to functions. Function metaMDS passes all arguments to its component functions metaMDSdist, metaMDSiter, postMDS, and to distfun and engine.

Details

Non-metric Multidimensional Scaling (NMDS) is commonly regarded as the most robust unconstrained ordination method in community ecology (Minchin 1987). Function metaMDS is a wrapper function that calls several other functions to combine Minchin's (1987) recommendations into one command. The complete steps in metaMDS are:

  1. Transformation: If the data values are larger than common abundance class scales, the function performs a Wisconsin double standardization (wisconsin). If the values look very large, the function also performs sqrt transformation. Both of these standardizations are generally found to improve the results. However, the limits are completely arbitrary (at present, data maximum 50 triggers sqrt and >9 triggers wisconsin). If you want to have a full control of the analysis, you should set autotransform = FALSE and standardize and transform data independently. The autotransform is intended for community data, and for other data types, you should set autotransform = FALSE. This step is perfomed using metaMDSdist.

  2. Choice of dissimilarity: For a good result, you should use dissimilarity indices that have a good rank order relation to ordering sites along gradients (Faith et al. 1987). The default is Bray-Curtis dissimilarity, because it often is the test winner. However, any other dissimilarity index in vegdist can be used. Function rankindex can be used for finding the test winner for you data and gradients. The default choice may be bad if you analyse other than community data, and you should probably select an appropriate index using argument distance. This step is performed using metaMDSdist.

  3. Step-across dissimilarities: Ordination may be very difficult if a large proportion of sites have no shared species. In this case, the results may be improved with stepacross dissimilarities, or flexible shortest paths among all sites. The default NMDS engine is monoMDS which is able to break tied values at the maximum dissimilarity, and this often is sufficient to handle cases with no shared species, and therefore the default is not to use stepacross with monoMDS. Function isoMDS does not handle tied values adequately, and therefore the default is to use stepacross always when there are sites with no shared species with engine = "isoMDS". The stepacross is triggered by option noshare. If you do not like manipulation of original distances, you should set noshare = FALSE. This step is skipped if input data were dissimilarities instead of community data. This step is performed using metaMDSdist.

  4. NMDS with random starts: NMDS easily gets trapped into local optima, and you must start NMDS several times from random starts to be confident that you have found the global solution. The strategy in metaMDS is to first run NMDS starting with the metric scaling (cmdscale which usually finds a good solution but often close to a local optimum), or use the previous.best solution if supplied, and take its solution as the standard (Run 0). Then metaMDS starts NMDS from several random starts (maximum number is given by trymax). Function monoMDS defaults random starts, but isoMDS defaults to cmdscale, and there random starts are generated by initMDS. If a solution is better (has a lower stress) than the previous standard, it is taken as the new standard. If the solution is better or close to a standard, metaMDS compares two solutions using Procrustes analysis (function procrustes with option symmetric = TRUE). If the solutions are very similar in their Procrustes rmse and the largest residual is very small, the solutions are regarded as convergent and the better one is taken as the new standard. Please note that the conditions are stringent, and you may have found good and relatively stable solutions although the function is not yet satisfied. Setting trace = TRUE will monitor the final stresses, and plot = TRUE will display Procrustes overlay plots from each comparison. This step is performed using metaMDSiter. This is the only step performed if input data (comm) were dissimilarities.

  5. Scaling of the results: metaMDS will run postMDS for the final result. Function postMDS provides the following ways of “fixing” the indeterminacy of scaling and orientation of axes in NMDS: Centring moves the origin to the average of the axes; Principal components rotate the configuration so that the variance of points is maximized on first dimension (with function MDSrotate you can alternatively rotate the configuration so that the first axis is parallel to an environmental variable); Half-change scaling scales the configuration so that one unit means halving of community similarity from replicate similarity. Half-change scaling is based on closer dissimilarities where the relation between ordination distance and community dissimilarity is rather linear (the limit is set by argument threshold). If there are enough points below this threshold (controlled by the parameter nthreshold), dissimilarities are regressed on distances. The intercept of this regression is taken as the replicate dissimilarity, and half-change is the distance where similarity halves according to linear regression. Obviously the method is applicable only for dissimilarity indices scaled to 0 … 1, such as Kulczynski, Bray-Curtis and Canberra indices. If half-change scaling is not used, the ordination is scaled to the same range as the original dissimilarities.

  6. Species scores: Function adds the species scores to the final solution as weighted averages using function wascores with given value of parameter expand. The expansion of weighted averages can be undone with shrink = TRUE in plot or scores functions, and the calculation of species scores can be suppressed with wascores = FALSE.

Value

Function metaMDS returns an object of class metaMDS. The final site ordination is stored in the item points, and species ordination in the item species, and the stress in item stress (NB, the scaling of the stress depends on the engine: isoMDS uses percents, and monoMDS proportions in the range 0 … 1). The other items store the information on the steps taken and the items returned by the engine function. The object has print, plot, points and text methods. Functions metaMDSdist and metaMDSredist return vegdist objects. Function initMDS returns a random configuration which is intended to be used within isoMDS only. Functions metaMDSiter and postMDS returns the result of NMDS with updated configuration.

Warning

metaMDS uses monoMDS as its NMDS engine from vegan version 2.0-0, when it replaced the isoMDS function. You can set argument engine to select the old engine.

Note

Function metaMDS is a simple wrapper for an NMDS engine (either monoMDS or isoMDS) and some support functions (metaMDSdist, stepacross, metaMDSiter, initMDS, postMDS, wascores). You can call these support functions separately for better control of results. Data transformation, dissimilarities and possible stepacross are made in function metaMDSdist which returns a dissimilarity result. Iterative search (with starting values from initMDS with monoMDS) is made in metaMDSiter. Processing of result configuration is done in postMDS, and species scores added by wascores. If you want to be more certain of reaching a global solution, you can compare results from several independent runs. You can also continue analysis from previous results or from your own configuration. Function may not save the used dissimilarity matrix (monoMDS does), but metaMDSredist tries to reconstruct the used dissimilarities with original data transformation and possible stepacross.

The metaMDS function was designed to be used with community data. If you have other type of data, you should probably set some arguments to non-default values: probably at least wascores, autotransform and noshare should be FALSE. If you have negative data entries, metaMDS will set the previous to FALSE with a warning.

Author(s)

Jari Oksanen

References

Faith, D. P, Minchin, P. R. and Belbin, L. (1987). Compositional dissimilarity as a robust measure of ecological distance. Vegetatio 69, 57–68.

Minchin, P.R. (1987) An evaluation of relative robustness of techniques for ecological ordinations. Vegetatio 69, 89–107.

See Also

monoMDS (and isoMDS), decostand, wisconsin, vegdist, rankindex, stepacross, procrustes, wascores, MDSrotate, ordiplot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## The recommended way of running NMDS (Minchin 1987)
##
data(dune)
# Global NMDS using monoMDS
sol <- metaMDS(dune)
sol
plot(sol, type="t")
## Start from previous best solution
sol <- metaMDS(dune, previous.best = sol)
## Local NMDS and stress 2 of monoMDS
sol2 <- metaMDS(dune, model = "local", stress=2)
sol2
## Use Arrhenius exponent 'z' as a binary dissimilarity measure
sol <- metaMDS(dune, distfun = betadiver, distance = "z")
sol

Example output

Loading required package: permute
Loading required package: lattice
This is vegan 2.5-3
Run 0 stress 0.1192678 
Run 1 stress 0.1183186 
... New best solution
... Procrustes: rmse 0.02026643  max resid 0.06493824 
Run 2 stress 0.1809581 
Run 3 stress 0.1192684 
Run 4 stress 0.1192679 
Run 5 stress 0.1183186 
... New best solution
... Procrustes: rmse 3.284034e-05  max resid 0.0001016958 
... Similar to previous best
Run 6 stress 0.1900952 
Run 7 stress 0.1922241 
Run 8 stress 0.1192682 
Run 9 stress 0.1183186 
... Procrustes: rmse 2.312336e-05  max resid 5.004743e-05 
... Similar to previous best
Run 10 stress 0.1183186 
... Procrustes: rmse 5.152987e-05  max resid 0.0001674166 
... Similar to previous best
Run 11 stress 0.1192678 
Run 12 stress 0.1183186 
... Procrustes: rmse 4.700085e-05  max resid 0.0001532556 
... Similar to previous best
Run 13 stress 0.1808911 
Run 14 stress 0.1192678 
Run 15 stress 0.1808912 
Run 16 stress 0.1886532 
Run 17 stress 0.2014899 
Run 18 stress 0.1183187 
... Procrustes: rmse 8.223801e-05  max resid 0.0002632648 
... Similar to previous best
Run 19 stress 0.1192678 
Run 20 stress 0.1183186 
... Procrustes: rmse 2.262838e-05  max resid 7.071146e-05 
... Similar to previous best
*** Solution reached

Call:
metaMDS(comm = dune) 

global Multidimensional Scaling using monoMDS

Data:     dune 
Distance: bray 

Dimensions: 2 
Stress:     0.1183186 
Stress type 1, weak ties
Two convergent solutions found after 20 tries
Scaling: centring, PC rotation, halfchange scaling 
Species: expanded scores based on 'dune' 

Starting from 2-dimensional configuration
Run 0 stress 0.1183186 
Run 1 stress 0.2064897 
Run 2 stress 0.1886532 
Run 3 stress 0.1192678 
Run 4 stress 0.1922241 
Run 5 stress 0.1183186 
... Procrustes: rmse 1.524661e-05  max resid 4.423256e-05 
... Similar to previous best
Run 6 stress 0.180958 
Run 7 stress 0.1889695 
Run 8 stress 0.1183186 
... Procrustes: rmse 5.04242e-06  max resid 1.732066e-05 
... Similar to previous best
Run 9 stress 0.1192679 
Run 10 stress 0.1183186 
... Procrustes: rmse 3.08804e-05  max resid 9.75761e-05 
... Similar to previous best
Run 11 stress 0.1886532 
Run 12 stress 0.1183186 
... Procrustes: rmse 1.530748e-05  max resid 4.600359e-05 
... Similar to previous best
Run 13 stress 0.119268 
Run 14 stress 0.1192679 
Run 15 stress 0.119268 
Run 16 stress 0.1192687 
Run 17 stress 0.1183186 
... Procrustes: rmse 1.22934e-05  max resid 3.928424e-05 
... Similar to previous best
Run 18 stress 0.1183186 
... Procrustes: rmse 1.449603e-05  max resid 4.350774e-05 
... Similar to previous best
Run 19 stress 0.1183187 
... Procrustes: rmse 0.0001125548  max resid 0.0003743474 
... Similar to previous best
Run 20 stress 0.1183186 
... New best solution
... Procrustes: rmse 5.779235e-06  max resid 1.427433e-05 
... Similar to previous best
*** Solution reached
Run 0 stress 0.1928489 
Run 1 stress 0.1928553 
... Procrustes: rmse 0.002074309  max resid 0.005926884 
... Similar to previous best
Run 2 stress 0.1928478 
... New best solution
... Procrustes: rmse 0.0002671695  max resid 0.0008127636 
... Similar to previous best
Run 3 stress 0.1928545 
... Procrustes: rmse 0.001615089  max resid 0.004520956 
... Similar to previous best
Run 4 stress 0.1928497 
... Procrustes: rmse 0.0009625039  max resid 0.002752307 
... Similar to previous best
Run 5 stress 0.1928476 
... New best solution
... Procrustes: rmse 8.643678e-05  max resid 0.0002011102 
... Similar to previous best
Run 6 stress 0.1928503 
... Procrustes: rmse 0.001004832  max resid 0.002859493 
... Similar to previous best
Run 7 stress 0.1928632 
... Procrustes: rmse 0.002298101  max resid 0.006385815 
... Similar to previous best
Run 8 stress 0.1928479 
... Procrustes: rmse 7.97721e-05  max resid 0.000230955 
... Similar to previous best
Run 9 stress 0.1928495 
... Procrustes: rmse 0.000843676  max resid 0.002425392 
... Similar to previous best
Run 10 stress 0.1928491 
... Procrustes: rmse 0.0003993467  max resid 0.0011391 
... Similar to previous best
Run 11 stress 0.1928482 
... Procrustes: rmse 0.0002190605  max resid 0.0007421945 
... Similar to previous best
Run 12 stress 0.1928479 
... Procrustes: rmse 0.0001374998  max resid 0.000479423 
... Similar to previous best
Run 13 stress 0.1928504 
... Procrustes: rmse 0.001007542  max resid 0.002894066 
... Similar to previous best
Run 14 stress 0.1928477 
... Procrustes: rmse 0.0002321811  max resid 0.0006293896 
... Similar to previous best
Run 15 stress 0.1928517 
... Procrustes: rmse 0.001215199  max resid 0.003501334 
... Similar to previous best
Run 16 stress 0.1928476 
... Procrustes: rmse 5.341047e-05  max resid 0.0001390815 
... Similar to previous best
Run 17 stress 0.1928481 
... Procrustes: rmse 0.000176783  max resid 0.0005115752 
... Similar to previous best
Run 18 stress 0.1928492 
... Procrustes: rmse 0.0007701665  max resid 0.002239855 
... Similar to previous best
Run 19 stress 0.1928493 
... Procrustes: rmse 0.0007674665  max resid 0.002234152 
... Similar to previous best
Run 20 stress 0.1928477 
... Procrustes: rmse 4.584552e-05  max resid 0.0001362277 
... Similar to previous best
*** Solution reached

Call:
metaMDS(comm = dune, model = "local", stress = 2) 

local Multidimensional Scaling using monoMDS

Data:     dune 
Distance: bray 

Dimensions: 2 
Stress:     0.1928476 
Stress type 2, weak ties
Two convergent solutions found after 20 tries
Scaling: centring, PC rotation, halfchange scaling 
Species: expanded scores based on 'dune' 

Run 0 stress 0.1067169 
Run 1 stress 0.186851 
Run 2 stress 0.1713724 
Run 3 stress 0.1073148 
Run 4 stress 0.1067169 
... Procrustes: rmse 7.081953e-06  max resid 1.488374e-05 
... Similar to previous best
Run 5 stress 0.1067169 
... Procrustes: rmse 2.327852e-05  max resid 6.14164e-05 
... Similar to previous best
Run 6 stress 0.1067169 
... Procrustes: rmse 2.897338e-05  max resid 6.754949e-05 
... Similar to previous best
Run 7 stress 0.1069785 
... Procrustes: rmse 0.006770749  max resid 0.02382939 
Run 8 stress 0.1067169 
... New best solution
... Procrustes: rmse 1.071188e-05  max resid 2.54279e-05 
... Similar to previous best
Run 9 stress 0.1073149 
Run 10 stress 0.1067169 
... Procrustes: rmse 4.230639e-05  max resid 0.0001020295 
... Similar to previous best
Run 11 stress 0.1736849 
Run 12 stress 0.1067169 
... Procrustes: rmse 1.833258e-05  max resid 5.209806e-05 
... Similar to previous best
Run 13 stress 0.107471 
Run 14 stress 0.1067169 
... Procrustes: rmse 8.694278e-06  max resid 1.921253e-05 
... Similar to previous best
Run 15 stress 0.1069789 
... Procrustes: rmse 0.006873787  max resid 0.02429489 
Run 16 stress 0.1868506 
Run 17 stress 0.1067169 
... Procrustes: rmse 1.284203e-05  max resid 3.290147e-05 
... Similar to previous best
Run 18 stress 0.1073148 
Run 19 stress 0.1067169 
... Procrustes: rmse 1.132978e-05  max resid 3.222019e-05 
... Similar to previous best
Run 20 stress 0.1073148 
*** Solution reached

Call:
metaMDS(comm = dune, distance = "z", distfun = betadiver) 

global Multidimensional Scaling using monoMDS

Data:     dune 
Distance: beta.z 

Dimensions: 2 
Stress:     0.1067169 
Stress type 1, weak ties
Two convergent solutions found after 20 tries
Scaling: centring, PC rotation, halfchange scaling 
Species: expanded scores based on 'dune' 

vegan documentation built on May 2, 2019, 5:51 p.m.