# comembership: Calculates the comemberships of all pairs of a vector of... In clusteval: Evaluation of Clustering Algorithms

## Description

For a set of clustering labels, this function computes the comembership of all pairs of observations. Basically, two observations are said to be comembers if they are clustered together.

## Usage

 `1` ``` comembership(labels) ```

## Arguments

 `labels` a vector of `n` clustering labels

## Details

Tibshirani and Walther (2005) use the term 'co-membership', which we shorten to 'comembership'. Some authors instead use the terms 'connectivity' or 'co-occurrence'.

We use the `Rcpp` package to improve the runtime speed of this function.

## Value

a vector of `choose(n, 2)` comembership bits

## References

Tibshirani, R. and Walther, G. (2005), Cluster Validation by Prediction Strength, _Journal of Computational and Graphical Statistics_, 14, 3, 511-528. http://amstat.tandfonline.com/doi/abs/10.1198/106186005X59243.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```# We generate K = 3 labels for each of n = 10 observations and compute the # comembership for all 'n choose 2' pairs. set.seed(42) K <- 3 n <- 10 labels <- sample.int(K, n, replace = TRUE) comembership_out <- comembership(labels) comembership_out # Notice that the number of comemberships is 'n choose 2'. length(comembership_out) == choose(n, 2) ```

### Example output

``` [1] 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 1 1 0 0 1 0 0 0 1
[39] 0 0 0 1 0 0 0
[1] TRUE
```

clusteval documentation built on May 29, 2017, 11:45 p.m.