centredist | R Documentation |
Function finds Euclidean or squared Mahalanobis distances of points
to class centroids in betadisper
or ordination results.
## Default S3 method:
centredist(x, group, distance = c("euclidean",
"mahalanobis"), display = "sites", w, ...)
## S3 method for class 'betadisper'
centredist(x, ...)
## S3 method for class 'cca'
centredist(x, group, distance = c("euclidean", "mahalanobis"),
display = c("sites", "species"), rank = 2, ...)
## S3 method for class 'rda'
centredist(x, group, distance = c("euclidean", "mahalanobis"),
display = "sites", rank = 2, ...)
## S3 method for class 'dbrda'
centredist(x, group, distance = c("euclidean","mahalanobis"),
display = "sites", rank = 2, ...)
## S3 method for class 'wcmdscale'
centredist(x, group, distance= c("euclidean","mahalanobis"),
display = "sites", rank = 2, ...)
x |
An ordination result object, or a matrix for the default
method or a |
group |
Factor to define classes for which centroids are found. |
distance |
Use either simple Euclidean distance or squared Mahalanobis distances that take into account the shape of covariance ellipses. |
display |
Kind of |
w |
Weights. If |
rank |
Number of axes used in ordination methods. |
... |
Other arguments to functions (ignored). |
Function finds either simple Euclidean distances of all points to
their centroid as given by argument group
or squared
Mahalanobis distances of points to the centroid. In addition to the
distances, it returns information of the original group and the
nearest group for each point.
Currently the distances are scaled so that the sum of squared
Euclidean distance will give the residual (unexplained) eigenvalue
in constrained ordination with given group. The distances may not
correspond to the distances in ordination plots with specific
scaling
and setting argument scaling
gives an
error. Due to restriction of this scaling, Euclidean distances for
species scores are only allowed in ca
and
cca
. These restrictions may be relaxed in the future
versions of the method.
Squared Mahalanobis distances (mahalanobis
) are scaled
by the within group covariance matrix, and they are consistent with
ordiellipse
.
Mahalanobis distances can only be calculated for group
that
are larger than rank
. For rank = 2
, minimum
permissible group
has three points. However, even this can
fail in degenerate cases, such as three points on a line. Euclidean
distances can be calculated for any rank
. With rank = "full"
distance-based methods wcmdscale
, pco
,
dbrda
and betadisper
will handle
negative eigenvalues and associated eigenvectors, but with numeric
rank they will only use real eigenvectors with positive eigenvalues.
There are specific methods for some ordination models, but many will
be handled by the default method (including metaMDS
and monoMDS
).
The specific method for betadisper
ignores most
arguments and calculates the distances as specified in model
fitting. The betadisper
result with argument
type = "centroid"
is equal to wcmdscale
,
pco
or dbrda
with the same
group
and rank = "full"
.
Function returns a list with components
centre |
Centre to which a point was originally allocated. |
nearest |
Nearest centre to a point. |
distances |
Distance matrix where each observation point is a row, and column gives the distance of the point to that centre. |
centerdist
is a synonym of centredist
.
Jari Oksanen
betadisper
, goodness.cca
,
mahalanobis
and various ordination methods.
data(dune, dune.env)
d <- vegdist(dune) # Bray-Curtis
mod <- with(dune.env, betadisper(d, Management))
centredist(mod)
## equal to metric scaling when using centroids instead of medians
modc <- with(dune.env, betadisper(d, Management, type = "centroid"))
ord <- pco(d)
all.equal(centredist(modc), centredist(ord, dune.env$Management, rank="full"),
check.attributes = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.