Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After a cluster analysis I´m trying to plot for each cluster the Index plot of the Silhouette value instead of for the complete dataset (like in the WeightedCluster Library Manual by Matthias Studer). First of all, is that theoretically correct? If yes...

I create the object "sil" with the wcSilhouetteObs command:

sil <- wcSilhouetteObs(distance.matrix, cluster.object)

Then I plot the Index Plot for the complete dataset (this line works, even if I can´t label the clusters, but for now I don´t care):

seqIplot(, group = group.p(cluster.object), sortv = sil)

But when I try to plot the Index plot sorted by the silhouette I don´t know (but as I said I´m not sure that it´s theoretically correct...) how to impose the restriction for the group argument selecting only the silhouette values e.g. for the first cluster.I have created a sequence object for each cluster separately (let´s say cluster1.seq), but what should I do then?

Thank you! Emanuela

share|improve this question
I'm totally unfamiliar to the program you use, but theoretically it is correct to compute silhouette statistic for a separate cluster - the statistic is basically computed for each object and serve as an index how "well" or "poorly" that specific object was clustered – ttnphns Jan 9 '13 at 13:02
Thank you very much for your comment! – emanuela.struffolino Jan 9 '13 at 13:45
up vote 4 down vote accepted

The silhouette is computed for each observation $i$ as

$s(i) = \frac{b(i) - a(i)}{\max(a(i), b(i))}$

where $a(i)$ is the average dissimilarity with members of the cluster to which $i$ belongs, and $b(i)$ the minimum average dissimilarity to members of another cluster.

The silhouette values of members of a cluster $k$ are at the same position as the values $k$ in the cluster membership vector cluster.object. So you do not have anything to do. Your seqIplot command will automatically produce one index plot for each cluster with the sequences sorted by their silhouette values in each cluster.

Sequences will be sorted bottom up from the lower to the highest silhouette value, meaning that the sequences with the best silhouette values for each cluster are at the top of the plots.

Hope this helps.

share|improve this answer
Thank you Gilbert, I´ve got it...but what if I would like to plot only one graph, say the Index Plot for the cluster 1, separately from the others? Thank you again! – emanuela.struffolino Jan 9 '13 at 13:50
Then you can do for instance: sel <- which(cluster.object==1) and then seqIplot(seqdata[sel,], sortv=sil[sel]) – Gilbert Jan 9 '13 at 13:57
Thank you, this is exacly what I want to do! – emanuela.struffolino Jan 9 '13 at 14:33
@Gilbert your comment saved my day! I tried to figure out how to subset the list produced by wcSilhouetteObs but could not see the obvious... – non-numeric_argument Nov 12 '13 at 13:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.