[R] Bug in Kendall for n<4?

Stavros Macrakis macrakis at alum.mit.edu
Sat Nov 22 20:50:52 CET 2008


On Sat, Nov 22, 2008 at 9:04 AM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
>    SM> I believe Kendall tau is well-defined for this case...
>
> The real question is  *WHY* there needs to be a separate package 'Kendall'  when R itself does everything you want and does not show any problems?

Thanks for pointing me to cor(...,method="kendall"), which I did not
know about; I used the Kendall CRAN package out of pure ignorance.

In my defense, I think it is excusable ignorance, as Search on the R
Project home page finds the Kendall package (which only mentions cor
as a "See Also").  I only more recently discovered the advantages of
help.search.

By the way, is Kendall well-defined when the arguments are not
permutations of each other?  cor seems to return results even in this
case:

   a<-factor(c("Alice","Bob","Chris"))
   b<-a[1:2]
   c<-a[2:3]
   cor(a,b,method="kendall")
       =>  1

apparently interpreting b as c(1,2) and c as c(1,2) based on
alphabetical order (even though it is an UNordered factor), which
seems to make the value depend on the subjects' names, which I'd think
was wrong for a rank-order statistic.

Thanks again,

           -s



More information about the R-help mailing list