Learn R Programming

rEMM (version 0.1-2)

recluster: Reclustering EMM states

Description

Use various clustering methods to recluster states/clusters in an EMM. The centers of the clusters in the EMM object are used as data points by the reclustering algorithm. States/centers put by reclustering into the same cluster are merged to produce a new reclustered EMM.

Usage

## S3 method for class 'EMM':
recluster_hclust(x, k=NULL, h=NULL, method="average", prune=NULL)
## S3 method for class 'EMM':
recluster_kmeans(x, k, ..., prune=NULL)
## S3 method for class 'EMM':
recluster_pam(x, k, ..., prune=NULL)

Arguments

x
an "EMM" object.
prune
prune states/clusters with less than prune counts before reclustering.
k
number of clusters.
h
heights where the dendrogram tree should be cut.
method
clustering method used by hclust.
...
additional arguments passed on to the clustering algorithm.

Value

  • An object of class "EMM". Clustering information is available as the attribute "cluster_info". The information provided depends in the clustering algorithm (see hclust, kmeans and pam).

Details

For recluster_kmeans k can also be a set of initial cluster centers (see argument centers for kmeans in package stats).

For recluster_hclust k or h can also be a vector. The result is then a list with several (nested) EMMs, one for each value.

See Also

merge_states, prune, kmeans, hclust, pam

Examples

Run this code
data("EMMTraffic")
emm <- EMM(measure="eJaccard", threshold=0.2)
emm <- build(emm, EMMTraffic)

## do clustering and plot dendrogram
emm_hc <- recluster_hclust(emm, h=0.5)

attr(emm_hc, "cluster_info")

## compare original and clustered EMM
op <- par(mfrow = c(2, 2), pty = "m")   
plot(emm, main ="original EMM", data = EMMTraffic, 
	ylim=c(-0.5, 0.5), xlim=c(-0.5, 0.5))
plot(emm_hc, main ="clustered EMM", data = EMMTraffic, 
	ylim=c(-0.5, 0.5), xlim=c(-0.5, 0.5))
plot(attr(emm_hc, "cluster_info")$dendrogram)
abline(h=0.5, col="red")
par(op)

Run the code above in your browser using DataLab