Description Usage Arguments Details Value Author(s) See Also Examples
Construct a top-down hierarchical clustering, recursively using k-means with k=2 (kmeans is also known as “vector quantization”).
1 2 |
x |
A data matrix whose rows (i.e., observations) are to be clustered |
K |
The number of terminal nodes that the tree should have. This must be less than or equal the number of rows of x. If the number of rows of x is used, then the resultant tree will have one data point in each terminal node of the tree. |
row.labs |
Observation labels. Must be numeric in |
ntry |
The number of attempts of 2-means used to subdivide each node into two children. For each attempt, two data points are randomly selected as initial centres. Since 2-means cannot guarantee a globally optimal partition into 2 clusters, multiple tries often will improve the quality of the clustering. |
verbose |
Should details of the growing be printed? |
as.hclust |
Should the tree be returned as a |
obj |
an object created by |
trace |
Flag indicating brief iteration count should be printed. Useful for large problems to indicate status. |
To construct a top-down hierarchical clustering, the data must be recursively subdivided into two clusters. 2-means is used to find a "good" (but seldom optimal) subdivision. Multiple restarts of kmeans tend to increase the quality of the clustering. Because random seeds are used to select initial centres, two different runs of tsvq are not guaranteed to produce an identical clustering.
The use of k-means implies that the top-down clustering is trying to minimize with-cluster sums of squared Euclidean distances.
If as.hclust=FALSE
, then tsvq
will return a list
that recursively represents the tree structure. If as.hclust=TRUE
,
an object compatible with hclust
is returned. Methods such as
plot
and cutree
can be applied to hclust objects.
The helper function
tsvq2hclust
will convert a tsvq object to hclust format.
Hugh Chipman; Trevor Hastie wrote the original tsvq code
hybridHclust
1 2 3 4 5 6 7 8 9 10 | x <- cbind(c(-1.4806,1.5772,-0.9567,-0.92,-1.9976,-0.2723,-0.3153),
c( -0.6283,-0.1065,0.428,-0.7777,-1.2939,-0.7796,0.012))
t1 <- tsvq(x)
par(mfrow=c(1,2))
plot(x,pch=as.character(1:nrow(x)),asp=1)
plot(t1)
cbind(x,cutree(t1,2))
# below also works although you don't need to do it this way.
t2 <- tsvq(x,as.hclust=FALSE)
t2 <- tsvq2hclust(t2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.