[R] silhoutte.default bugs

Martin Maechler maechler at stat.math.ethz.ch
Thu Jan 22 10:51:24 CET 2004


>>>>> "Murad" == Murad Nayal <mn216 at columbia.edu>
>>>>>     on Wed, 21 Jan 2004 15:19:28 -0500 writes:

    Murad> This might have been fixed in later versions (I am
    Murad> using R1.7.0),

yes, the bug has been fixed "long ago", 
from my ChangeLog (!), it was 2003-07-18.

    Murad>  r-help archive contains messages reporting similar
    Murad> problems but no reports of codes fixes. I have
    Murad> encountered a couple of problems using the silhouette
    Murad> function. one occurs when the clustering contains
    Murad> clusters composed of 1 element (Martin Maechler
    Murad> posted code few months ago that fixes a similar
    Murad> problem that occurs when clusters have only 2
    Murad> elements but not the case with 1 element). the other
    Murad> problem is due to silhouette's assumption that the
    Murad> clusters are numbered sequentially starting at 1. 

which is what  ?silhouette  tells you as well:

>> Arguments:
>> 
>>        x: an object of appropriate class; for the 'default' method an
>>           integer vector with cluster codes in '1:k' or a list with
>>           such an 'x$clustering' component.

So, definitely not a bug, 
but it's your problem of using silhouette() on an object that is
not of appropriate structure.

    Murad> one of the clustering programs I use (snob) assigns
    Murad> more or less arbitrary integer ids to clusters
    Murad> starting from 3! (clusters 1 and 2 have special
    Murad> meaning in snob). the modified code fixing both
    Murad> problems is included below, changes are commented.

Thank you for the good attempt,
but really you should work from the source where
silhouette.default does also contain comments, and as said, has
long been fixed for the case of 1-element clusters
{a better fix is not to use cbind() but to use the ominous 
 ", drop = FALSE" when  subsetting matrices!}

I'm still willing to consider your *feature request* (as opposed
to bug fix) of allowing inputs where the grouping vector does
contain other than "1:g" .

I'll send you the current source of silhouette.default in a
private mail.

Thanks for your collaboration on improving R!
Regards,

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><




More information about the R-help mailing list