as.vegclust: Turns into vegclust objects

View source: R/as.vegclust.R

as.vegclustR Documentation

Turns into vegclust objects

Description

Attempts to turn its arguments into a vegclust object

Usage

as.vegclust(x, y, method="KM", m=1.0, dnoise=NULL, eta=NULL)

Arguments

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 x belongs to. Alternatively, a fuzzy/hard site-by-group matrix of membership values.

method

A clustering model from which y was obtained (normally "KM"). Current accepted models are:

  • "KM": K-means or hard c-means (MacQueen 1967)

  • "KMdd": Hard c-medoids (Krishnapuram et al. 1999)

  • "FCM": Fuzzy c-means (Bezdek 1981)

  • "FCMdd": Fuzzy c-medoids (Krishnapuram et al. 1999)

  • "NC": Noise clustering (Dave and Krishnapuram 1997)

  • "NCdd": Noise clustering with medoids

  • "HNC": Hard noise clustering

  • "HNCdd": Hard noise clustering with medoids

  • "PCM": Possibilistic c-means (Krishnapuram and Keller 1993)

  • "PCMdd": Possibilistic c-medoids

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).

Details

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.

Value

An object of class vegclust.

Author(s)

Miquel De Cáceres, CREAF.

See Also

vegclust, vegclass

Examples

## 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)

emf-creaf/vegclust documentation built on July 27, 2024, 7:32 a.m.