[R] agglomerative coefficient in agnes (cluster)

Weiguang Shi wgshi2001 at yahoo.ca
Fri Jan 28 05:23:33 CET 2005


Thanks very much Andy for the code and the
explanation.
The meaning of AC is much more clear now.

I did notice, when I tried the code, the results were
not exactly the same as yours.
  > sapply(c(.25,.5), testAC, x=x[1:4],
method="single")
  Loading required package: cluster 
  Error in FUN(X[[1]], ...) : Object "x" not found
  > x=rnorm(50)
  > sapply(c(.25,.5), testAC, x=x[1:4],
method="single")
  [1] 0.7450599 0.9926918

  > version
         _                
  platform i686-pc-linux-gnu
  arch     i686             
  os       linux-gnu        
  system   i686, linux-gnu  
  status                    
  major    2                
  minor    0.1              
  year     2004             
  month    11               
  day      15                 
  language R                

Regards,
Weiguang

 --- "Liaw, Andy" <andy_liaw at merck.com> wrote: 
> It has to do with sample sizes.  Consider the
> following:
> 
> testAC <- function(prop1=0.5, x=rnorm(50),
> center=c(0, 100), ...) {
>     stopifnot(require(cluster))
>     n <- length(x)
>     n1 <- ceiling(n * prop1)
>     n2 <- n - n1
>     agnes(x + rep(center, c(n1, n2)), ...)$ac
> }
> 
> Now some tests:
> 
> > sapply(c(.25, .5), testAC, x=x[1:4],
> method="single")
> [1] 0.7427591 0.9862944
> > sapply(1:5 / 10, testAC, x=x[1:10],
> method="single")
> [1] 0.8977139 0.9974224 0.9950061 0.9946366
> 0.9946366
> > sapply(1:5 / 10, testAC, x=x, method="single")
> [1] 0.9982955 0.9969757 0.9971114 0.9971127
> 0.9975111
> 
> So it seems like AC does not consider isolated
> singletons as cluster
> structures.  This is only discernable in small
> sample size, though.
> 
> Andy
> 
> 
>  
> >  --- "Liaw, Andy" <andy_liaw at merck.com> wrote: 
> > > BTW, I checked the book.  You're not going find
> much
> > > more than that.
> > > 
> > Thanks for checking.
> > 
> > Weiguang
> > 
> >
>
______________________________________________________________
> > ________ 
> > Post your free ad now! http://personals.yahoo.ca
> > 
> > 
> 
> 
>
------------------------------------------------------------------------------
> Notice:  This e-mail message, together with any
> attachments, contains information of Merck & Co.,
> Inc. (One Merck Drive, Whitehouse Station, New
> Jersey, USA 08889), and/or its affiliates (which may
> be known outside the United States as Merck Frosst,
> Merck Sharp & Dohme or MSD and in Japan, as Banyu)
> that may be confidential, proprietary copyrighted
> and/or legally privileged. It is intended solely for
> the use of the individual or entity named on this
> message.  If you are not the intended recipient, and
> have received this message in error, please notify
> us immediately by reply e-mail and then delete it
> from your system.
>
------------------------------------------------------------------------------
>




More information about the R-help mailing list