as.vegclust | R Documentation |
Attempts to turn its arguments into a vegclust
object
as.vegclust(x, y, method="KM", m=1.0, dnoise=NULL, eta=NULL)
x |
A site-by-species data matrix (raw mode), or a site-by-site distance matrix (distance mode). |
y |
A vector indicating the cluster that each object in |
method |
A clustering model from which
|
m |
The fuzziness exponent to be used, relevant for all fuzzy models (FCM, FCMdd, NC, NCdd, PCM and PCMdd) |
dnoise |
The distance to the noise cluster, relevant for noise clustering models (NC, HNC, NCdd and HNCdd). |
eta |
A vector of reference distances, relevant for possibilistic models (PCM and PCMdd). |
This function is used to generate vegclust
objects which can then be used in vegclass
to classify new data. If the input classification is hard (i.e. yes/no membership), cluster centers are calculated as multivariate means, and the method for assigning new data is assumed to be k-means ("KM"
), i.e. plots will be assigned to the nearest cluster center. If community data is given as site-by-species data matrix the cluster centroids are added as mobileCenters
in the vegclust
object. Centroids will not be computed if community data is given as a site-by-site dissimilarity matrix. Moreover, current implementation does not allow y
to be a membership matrix when x
is a distance matrix.
An object of class vegclust
.
Miquel De Cáceres, CREAF.
vegclust
, vegclass
## Loads data
data(wetland)
## This equals the chord transformation
## (see also \code{\link{decostand}} in package vegan)
wetland.chord = as.data.frame(sweep(as.matrix(wetland), 1,
sqrt(rowSums(as.matrix(wetland)^2)), "/"))
## Splits wetland data into two matrices of 30x27 and 11x22
wetland.30 = wetland.chord[1:30,]
wetland.30 = wetland.30[,colSums(wetland.30)>0]
dim(wetland.30)
wetland.11 = wetland.chord[31:41,]
wetland.11 = wetland.11[,colSums(wetland.11)>0]
dim(wetland.11)
## Performs a K-means clustering of the data set with 30 sites
wetland.km = kmeans(wetland.30, centers=3, nstart=10)
## Transforms the 'external' classification of 30 sites into a 'vegclust' object
wetland.30.vc = as.vegclust(wetland.30, wetland.km$cluster)
## Assigns the second set of sites according to the (k-means) membership rule
## That is, sites are assigned to the cluster whose cluster centroids is nearest.
wetland.11.km = vegclass(wetland.30.vc, wetland.11)
## A similar 'vegclust' object is obtained when using the distance mode...
wetland.d.vc = as.vegclust(dist(wetland.30), wetland.km$cluster)
## which can be also used to produce the assignment of the second set of objects
wetland.d.11 = as.data.frame(as.matrix(dist(wetland.chord)))[31:41,1:30]
wetland.d.11.km = vegclass(wetland.d.vc,wetland.d.11)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.