Last data update: 2014.03.03

R: Plot clusters with different colors.
hard.hmacR Documentation

Plot clusters with different colors.

Description

Plot clusters with colors obtained from hard density. Plot one dimensional data with density plot. Plot two dimensional data with scatter plot. Pairwise scatter plot will be provided for data with more than two dimensions.

Usage

hard.hmac(hmacobj,level=NULL, n.cluster=NULL,plot=TRUE,colors=1:6,...)

Arguments

hmacobj

The output of HMAC analysis. An object of class 'hmac'.

level

The specified level of HMAC output

n.cluster

The specified number of clusters. If neither level nor n.cluster is specified, hard clustering output is shown for each level.

plot

Get the plot of the clusters with different colors. Default value is TRUE, draws a plot on the current graphics device; plot=FALSE indicates do not get the plot and returns the membership of data.

colors

Colors used to represent different clusters.

...

Further graphical parameters

Value

Returns the membership of each observation of the specified level if plot=FALSE

Author(s)

Surajit Ray and Yansong Cheng

References

Li. J, Ray. S, Lindsay. B. G, "A nonparametric statistical approach to clustering via mode identification," Journal of Machine Learning Research , 8(8):1687-1723, 2007.

Lindsay, B.G., Markatou M., Ray, S., Yang, K., Chen, S.C. "Quadratic distances on probabilities: the foundations," The Annals of Statistics Vol. 36, No. 2, page 983–1006, 2008.

See Also

phmac for front end of using modal clustering and also for parallel implementation of modal clustering soft.hmac for soft clustering at specified levels. See plot.hmac.

Examples

data(disc2d.hmac)
#disc2d.hmac is the output of phmac(disc2d,npart=1)

hard.hmac(disc2d.hmac,level=3)

#returns the membership of each observation
disc2d.2clus=hard.hmac(hmacobj=disc2d.hmac,n.cluster=2,plot=FALSE)
table(disc2d.2clus)

#hard.hmac(disc2d.hmac)

iris.hmac=phmac(iris[,-5])
# For more than two dimensions it produces the pairs plot
hard.hmac(iris.hmac,n.cluster=2)

 

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Modalclust)
Loading required package: mvtnorm
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: class
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Modalclust/hard.HMAC.Rd_%03d_medium.png", width=480, height=480)
> ### Name: hard.hmac
> ### Title: Plot clusters with different colors.
> ### Aliases: hard.hmac
> ### Keywords: cluster, hierarchical, nested, modal
> 
> ### ** Examples
> 
> data(disc2d.hmac)
> #disc2d.hmac is the output of phmac(disc2d,npart=1)
> 
> hard.hmac(disc2d.hmac,level=3)
> 
> #returns the membership of each observation
> disc2d.2clus=hard.hmac(hmacobj=disc2d.hmac,n.cluster=2,plot=FALSE)
The level at which there are 2 clusters is 3 
> table(disc2d.2clus)
disc2d.2clus
  1   2 
201 199 
> 
> #hard.hmac(disc2d.hmac)
> 
> iris.hmac=phmac(iris[,-5])
Performing initial Modal clusteringLoading required package: parallel
..........
Building hierarchical Modal clusters at 
level  1 ...level  2 ...level  3 ...level  4 ...level  5 ...
level  6 ...level  7 ...level  8 ...level  9 ...level  10 ...

> # For more than two dimensions it produces the pairs plot
> hard.hmac(iris.hmac,n.cluster=2)
The level at which there are 2 clusters is 3 
> 
>  
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>