[Rd] small bug in ansari.test

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Mar 29 21:39:16 CEST 2007


The help page for ansari.test() says (emphasis added):

	By default (if exact is not specified), an exact p-value is computed if both 	
samples contain less than 50 finite values **and there are no ties**. 
Otherwise, a normal approximation is used.

However, this does not appear to be the case in R 2.4.1 or R 2.5.0. In fact, 
even

	example(ansari.test)

produces a warning

	Warning message:
	cannot compute exact p-value with ties in: ansari.test.default(ramsay, 
jung.parekh)

although the "exact" parameter is omitted.

Patch:

Index: src/library/stats/R/ansari.test.R
===================================================================
--- src/library/stats/R/ansari.test.R   (revision 40902)
+++ src/library/stats/R/ansari.test.R   (working copy)
@@ -29,7 +29,7 @@
     TIES <- (length(r) != length(unique(r)))

     if(is.null(exact))
-        exact <- ((m < 50) && (n < 50))
+        exact <- ((m < 50) && (n < 50) && (!TIES))

     if(exact && !TIES) {
         pansari <- function(q, m, n) {


Regards
Thomas Friedrichsmeier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-devel/attachments/20070329/16ab7353/attachment.bin 


More information about the R-devel mailing list