[R] Bug in Kendall for n<4?
Martin Maechler
maechler at stat.math.ethz.ch
Sat Nov 22 15:04:52 CET 2008
>>>>> "SM" == Stavros Macrakis <macrakis at alum.mit.edu>
>>>>> on Fri, 21 Nov 2008 14:44:37 -0500 writes:
>> library(Kendall) Kendall(1:3,1:3)
SM> WARNING: Error exit, tauk2. IFAULT = 12 <<<<<< tau = 1,
SM> 2-sided pvalue =1
SM> I believe Kendall tau is well-defined for this case and
SM> the reported value is correct; isn't it a bug to give a
SM> warning? (And if, e.g., the pvalue is not well-defined
SM> in this case, wouldn't it be better to return NA or NaN
SM> or something?) Also, shouldn't the error code be given
SM> in plain English -- or at least the meaning of "IFAULT =
SM> 12" documented on the help page?
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 ?
cor()
cov()
cor.test()
all have a method = "kendall" and seem to work alright,
even for n=2
> cor(1:3, c(3,1,2), method="kendall")
[1] -0.3333333
> cov(1:3, c(3,1,2), method="kendall")
[1] -2
> cor(1:3, 1:3, method="kendall")
[1] 1
> cor.test(1:3, 1:3, method="kendall")
Kendall's rank correlation tau
data: 1:3 and 1:3
T = 3, p-value = 0.3333
alternative hypothesis: true tau is not equal to 0
sample estimates:
tau
1
Questions about the 'Kendall' package should typically first go
to its author ...
But those on cor(), cor.test() etc do belong here.
Best regards,
Martin Maechler, ETH Zurich
SM> A somewhat less clear case is Kendall(1:2,1:2), which
SM> gives the same error. Though the usual formula for
SM> Kendall tau has a zero in the denominator in this case,
SM> I'd think the correct generalization is 1 if the two
SM> elements are in the same order, and -1 if they are not
SM> (the only possibilities). But perhaps I don't fully
SM> understand the interpretation of this statistic.
SM> -s
SM> ______________________________________________
SM> R-help at r-project.org mailing list
SM> https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
SM> read the posting guide
SM> http://www.R-project.org/posting-guide.html and provide
SM> commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list