Learn R Programming

RiemBaseExt (version 0.1.2)

rclust.hclust: Hierarchical Agglomerative Clustering for Manifold-valued Data

Description

Hierarchical clustering is a generally applicable clustering algorithm as long as we have concept of dissimilarity. We adopt hclust algorithm by fastcluster package. See hclust for more details.

Usage

rclust.hclust(
  input,
  type = c("extrinsic", "intrinsic"),
  method = c("single", "complete", "average", "mcquitty", "ward.D", "ward.D2",
    "centroid", "median"),
  members = NULL
)

Arguments

input

a S3 object of riemdata class. See riemfactory for more details.

type

type of distance, either "intrinsic" or "extrinsic".

method

the agglomeration method to be used. This must be (an unambiguous abbreviation of) one of "single", "complete", "average", "mcquitty", "ward.D", "ward.D2", "centroid" or "median".

members

NULL or a vector whose length equals the number of observations. See hclust for details.

Value

an object of class hclust. See hclust for details.

References

mullner_fastcluster_2013RiemBaseExt

Examples

Run this code
# NOT RUN {
## generate 50 points near (0,0,1)  and
##          50 points near (0,0,-1) on Sphere S^2 
ndata = 50
theta = seq(from=-0.99,to=0.99,length.out=ndata)*pi
tmpx  = cos(theta) + rnorm(ndata,sd=0.1)
tmpy  = sin(theta) + rnorm(ndata,sd=0.1)

## wrap it as 'riemdata' class
data  = list()
for (i in 1:ndata){
  tgt = c(tmpx[i],tmpy[i],1)
  data[[i]] = tgt/sqrt(sum(tgt^2)) # project onto Sphere
}
for (i in 1:ndata){
  tgt = c(tmpx[i],tmpy[i],-1)
  data[[i+ndata]] = tgt/sqrt(sum(tgt^2)) # project onto Sphere
}
data = RiemBase::riemfactory(data, name="sphere")

## compare extrinsic and intrinsic hierarchical clustering
hext <- rclust.hclust(data, type="extrinsic")
hint <- rclust.hclust(data, type="intrinsic")

## visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,2), pty="s")
plot(hext, main="extrinsic+single")
plot(hint, main="intrinsic+single")
par(opar)

# }

Run the code above in your browser using DataLab