forked from vegandevs/vegan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonoMDS.Rd
245 lines (191 loc) · 9.65 KB
/
monoMDS.Rd
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
\name{monoMDS}
\alias{monoMDS}
\alias{scores.monoMDS}
\alias{plot.monoMDS}
\alias{points.monoMDS}
\alias{text.monoMDS}
\title{ Global and Local Non-metric Multidimensional Scaling and
Linear and Hybrid Scaling }
\description{ Function implements Kruskal's (1964a,b) non-metric
multidimensional scaling (NMDS) using monotone regression and
primary (\dQuote{weak}) treatment of ties. In addition to
traditional global NMDS, the function implements local NMDS, linear
and hybrid multidimensional scaling.
}
\usage{
monoMDS(dist, y, k = 2, model = c("global", "local", "linear", "hybrid"),
threshold = 0.8, maxit = 200, weakties = TRUE, stress = 1,
scaling = TRUE, pc = TRUE, smin = 1e-4, sfgrmin = 1e-7,
sratmax=0.999999, ...)
\method{scores}{monoMDS}(x, choices = NA, ...)
\method{plot}{monoMDS}(x, choices = c(1,2), type = "t", ...)
\method{points}{monoMDS}(x, choices = c(1,2), select, ...)
\method{text}{monoMDS}(x, labels, choices = c(1,2), select, ...)
}
\arguments{
\item{dist}{Input dissimilarities.}
\item{y}{Starting configuration. A random configuration will be
generated if this is missing.}
\item{k}{Number of dimensions. NB., the number of points \eqn{n}
should be \eqn{n > 2k + 1}{n > 2*k + 1}, and preferably higher in
non-metric MDS.}
\item{model}{MDS model: \code{"global"} is normal non-metric MDS
with a monotone regression, \code{"local"} is non-metric MDS with
separate regressions for each point, \code{"linear"} uses linear
regression, and \code{"hybrid"} uses linear regression for
dissimilarities below a threshold in addition to monotone
regression. See Details.}
\item{threshold}{Dissimilarity below which linear regression is
used alternately with monotone regression. }
\item{maxit}{Maximum number of iterations.}
\item{weakties}{Use primary or weak tie treatment, where equal
observed dissimilarities are allowed to have different fitted
values. if \code{FALSE}, then secondary (strong) tie treatment is
used, and tied values are not broken.}
\item{stress}{Use stress type 1 or 2 (see Details).}
\item{scaling}{Scale final scores to unit root mean squares.}
\item{pc}{Rotate final scores to principal components.}
\item{smin, sfgrmin, sratmax}{Convergence criteria: iterations stop
when stress drops below \code{smin}, scale factor of the gradient
drops below \code{sfgrmin}, or stress ratio between two iterations
goes over \code{sratmax} (but is still \eqn{< 1}).}
\item{x}{A \code{monoMDS} result.}
\item{choices}{Dimensions returned or plotted. The default \code{NA}
returns all dimensions. }
\item{type}{The type of the plot: \code{"t"} for text, \code{"p"}
for points, and \code{"n"} for none.}
\item{select}{Items to be displayed. This can either be a logical
vector which is \code{TRUE} for displayed items or a vector of
indices of displayed items.}
\item{labels}{Labels to be use used instead of row names.}
\item{\dots}{Other parameters to the functions (ignored in
\code{monoMDS}, passed to graphical functions in \code{plot}.).}
}
\details{ There are several versions of non-metric multidimensional
scaling in \R, but \code{monoMDS} offers the following unique
combination of features:
\itemize{
\item \dQuote{Weak} treatment of ties (Kruskal 1964a,b), where tied
dissimilarities can be broken in monotone regression. This is
especially important for cases where compared sites share no species
and dissimilarities are tied to their maximum value of one. Breaking
ties allows these points to be at different distances and can help
in recovering very long coenoclines (gradients). Functions in the
\CRANpkg{smacof} package also hav adequate tie treatment.
\item Handles missing values in a meaningful way.
\item Offers \dQuote{local} and \dQuote{hybrid} scaling in
addition to usual \dQuote{global} NMDS (see below).
\item Uses fast compiled code (\code{\link[MASS]{isoMDS}} of the
\pkg{MASS} package also uses compiled code).
}
Function \code{monoMDS} uses Kruskal's (1964b) original monotone
regression to minimize the stress. There are two alternatives of
stress: Kruskal's (1964a,b) original or \dQuote{stress 1} and an
alternative version or \dQuote{stress 2} (Sibson 1972). Both of
these stresses can be expressed with a general formula
\deqn{s^2 = \frac{\sum (d - \hat d)^2}{\sum(d - d_0)^2}}{stress^2 = sum (d-dhat)^2/ sum (d-dnull)^2}
where \eqn{d} are distances among points in ordination configuration,
\eqn{\hat d}{dhat} are the fitted ordination distances, and
\eqn{d_0}{dnull} are the ordination distances under null model. For
\dQuote{stress 1} \eqn{d_0 = 0}{dnull = 0}, and for \dQuote{stress 2}
\eqn{d_0 = \bar{d}}{dnull = dbar} or mean distances. \dQuote{Stress 2}
can be expressed as \eqn{s^2 = 1 - R^2}{stress^2 = 1 - R2},
where\eqn{R^2}{R2} is squared correlation between fitted values and
ordination distances, and so related to the \dQuote{linear fit} of
\code{\link{stressplot}}.
Function \code{monoMDS} can fit several alternative NMDS variants that
can be selected with argument \code{model}. The default \code{model =
"global"} fits global NMDS, or Kruskal's (1964a,b) original NMDS
similar to \code{\link[MASS]{isoMDS}} (\pkg{MASS}). Alternative
\code{model = "local"} fits local NMDS where independent monotone
regression is used for each point (Sibson 1972). Alternative
\code{model = "linear"} fits a linear MDS. This fits a linear
regression instead of monotone, and is not identical to metric scaling
or principal coordinates analysis (\code{\link{cmdscale}}) that
performs an eigenvector decomposition of dissimilarities (Gower
1966). Alternative \code{model = "hybrid"} implements hybrid MDS that
uses monotone regression for all points and linear regression for
dissimilarities below or at a \code{threshold} dissimilarity in
alternating steps (Faith et al. 1987). Function
\code{\link{stressplot}} can be used to display the kind of regression
in each \code{model}.
Scaling, orientation and direction of the axes is arbitrary.
However, the function always centres the axes, and the default
\code{scaling} is to scale the configuration of unit root mean
square and to rotate the axes (argument \code{pc}) to principal
components so that the first dimension shows the major variation.
It is possible to rotate the solution so that the first axis is
parallel to a given environmental variable using function
\code{\link{MDSrotate}}.
}
\section{Convergence Criteria}{
NMDS is iterative, and the function stops when any of its
convergence criteria is met. There is actually no criterion of
assured convergence, and any solution can be a local optimum. You
should compare several random starts (or use \code{monoMDS} via
\code{\link{metaMDS}}) to assess if the solutions is likely a global
optimum.
The stopping criteria are:
\describe{
\item{\code{maxit}:}{ Maximum number of iterations. Reaching this
criterion means that solutions was almost certainly not found,
and \code{maxit} should be increased.}
\item{\code{smin}:}{ Minimum stress. If stress is nearly zero,
the fit is almost perfect. Usually this means that data set is
too small for the requested analysis, and there may be several
different solutions that are almost as perfect. You should reduce
the number of dimensions (\code{k}), get more data (more
observations) or use some other method, such as metric scaling
(\code{\link{cmdscale}}, \code{\link{wcmdscale}}).}
\item{\code{sratmax}:}{ Change in stress. Values close to one
mean almost unchanged stress. This may mean a solution, but it
can also signal stranding on suboptimal solution with flat stress
surface.}
\item{\code{sfgrmin}:}{ Minimum scale factor. Values close to
zero mean almost unchanged configuration. This may mean a
solution, but will also happen in local optima.}
}
}
\value{ Returns an object of class \code{"monoMDS"}. The final scores
are returned in item \code{points} (function \code{scores} extracts
these results), and the stress in item \code{stress}. In addition,
there is a large number of other items (but these may change without
notice in the future releases). }
\references{
Faith, D.P., Minchin, P.R and Belbin, L. 1987. Compositional
dissimilarity as a robust measure of ecological
distance. \emph{Vegetatio} 69, 57--68.
Gower, J.C. (1966). Some distance properties of latent root and
vector methods used in multivariate analysis. \emph{Biometrika}
53, 325--328.
Kruskal, J.B. 1964a. Multidimensional scaling by optimizing
goodness-of-fit to a nonmetric hypothesis. \emph{Psychometrika}
29, 1--28.
Kruskal, J.B. 1964b. Nonmetric multidimensional scaling: a numerical
method. \emph{Psychometrika} 29, 115--129.
Minchin, P.R. 1987. An evaluation of relative robustness of
techniques for ecological ordinations. \emph{Vegetatio} 69,
89--107.
Sibson, R. 1972. Order invariant methods for data
analysis. \emph{Journal of the Royal Statistical Society B} 34,
311--349.
}
\author{
Peter R. Michin (Fortran core) and Jari Oksanen (R interface).
}
\note{ This is the default NMDS function used in
\code{\link{metaMDS}}. Function \code{\link{metaMDS}} adds support
functions so that NMDS can be run like recommended by Minchin
(1987).
}
\seealso{ \code{\link{metaMDS}} for the \pkg{vegan} way of running NMDS,
and \code{\link[MASS]{isoMDS}} and \CRANpkg{smacof} for some
alternative implementations of NMDS. }
\examples{
data(dune)
dis <- vegdist(dune)
m <- monoMDS(dis, model = "loc")
m
plot(m)
}
\keyword{ multivariate }