[Rd] kendall tau correlation test for ties: Potential error (PR#8076)

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Aug 18 15:07:07 CEST 2005


dkoschuetzki at gmx.de writes:

>                 } else {
>                     STATISTIC <- c(z = r / sqrt((4 * n + 10) / (9 * n*(n-1))))
>                     p <- pnorm(STATISTIC)
>                     if(exact && TIES)
>                         warning("Cannot compute exact p-value with ties")
>                 }
>             }
> 	} else {
> 	// OMITTED
>         }
>     }
> 
>     if(is.null(PVAL)) # for "pearson" only, currently
> 	PVAL <- switch(alternative,
> 		       "less" = p,
> 		       "greater" = 1 - p,
> 		       "two.sided" = 2 * min(p, 1 - p))
...
> 
> Please look at the computation of the p-value for Kendalls tau. There is an
> assignment to "p" right above the warning. In the bottom of the function there
> is a comment that for the pearson case we have to use the modification and set
> PVAL. 
> 
> The problem is: 
> * Either the comment is wrong because the modification should be done with
> kendall too, or
> * The variable PVAL has to be assigned in the kendall block.
> 
> I hope this is clear so far.

I think it is the comment that is wrong. The calculation of
opposite-side one-sided and two-sided alternatives make OK sense when
the normal approximation of the test statistic is being used. It's
when you use a discrete distribution that you need to be careful.

(As brought up recently, the normal approximation itself is not too
hot in the tied case, but that's another matter.)

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-devel mailing list