Computes the variation in community composition (i.e. beta diversity) found within the sites of a set of hard or fuzzy clusters.

1 |

`x` |
Community data. Either a site-by-species matrix or a site-by-site matrix of compositional distances between sites (i.e., an object of class |

`cluster` |
A vector indicating the hard membership of each object in |

`defuzzify` |
A flag indicating whether fuzzy memberships should be defuzzified (see function |

`...` |
Additional parameters for function |

This function can be used in two ways:

if

`x`

is a data matrix (site by species or distances among sites) and`cluster`

is`null`

, the function assumes a single cluster of all points in`x`

. When`cluster`

is provided, the function computes cluster variance for each (hard) group and this computation implies setting the centroid of the group. Cluster variance is defined as the average squared distance to the centroid.-
If

`x`

is an object of class`vegclust`

or`vegclass`

, the function uses the information contained there (distances to cluster centers, memberships and exponent of fuzziness) in order to compute cluster variances. Cluster centers do not need to be recomputed, and the distances to cluster centers are used directly. For centroid-based cluster models (KM, FCM, NC, HNC and PCM) the variance is defined as the average squared distance to the centroid. For medoid-based cluster models (KMdd, FCMdd, NCdd, HNCdd and PCMdd) the variance is defined as average distance to the medoid. The variance for both mobile and fixed clusters is returned. Additionally, membership matrices may be defuzzified if`defuzzify=TRUE`

.

A double value (for one cluster) or a vector of values, one per each cluster.

Miquel De Cáceres, Forest Science Center of Catalonia

`vegclust`

, `kmeans`

,`defuzzify`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ```
## 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)), "/"))
## Create noise clustering with 3 clusters. Perform 10 starts from random seeds
## and keep the best solution
wetland.nc = vegclust(wetland.chord, mobileCenters=3, m = 1.2, dnoise=0.75,
method="NC", nstart=10)
## Gets cluster variance of fuzzy clusters
clustvar(wetland.nc)
## Gets cluster variance of fuzzy clusters after defuzzification
clustvar(wetland.nc, defuzzify=TRUE)
## Similar to the previous, this gets cluster variance of defuzzified (i.e. hard) clusters
clustvar(wetland.chord, cluster=defuzzify(wetland.nc)$cluster)
## Gets cluster variance of K-means (i.e. hard) clusters
clustvar(wetland.chord, cluster=kmeans(wetland.chord, centers=3, nstart=10)$cluster)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.