From ripley at stats.ox.ac.uk  Wed Jan  2 09:19:11 2008
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 2 Jan 2008 08:19:11 +0000 (GMT)
Subject: [Rd] Error from wilcox.test
In-Reply-To: <Pine.LNX.4.64.0801020708590.6430@gannet.stats.ox.ac.uk>
References: <477AB642.6070201@ebi.ac.uk>
	<Pine.LNX.4.64.0801020708590.6430@gannet.stats.ox.ac.uk>
Message-ID: <Pine.LNX.4.64.0801020810030.8354@gannet.stats.ox.ac.uk>

On Wed, 2 Jan 2008, Prof Brian Ripley wrote:

> Try exact = TRUE: the default switches to a normal approximation that will
> not be adequate in your extreme example.

I've modified the code in R-devel to give an answer in such extreme cases, 
but note that the p-value is pretty inaccurate, and so is the coverage of 
the reported CI.

> On Tue, 1 Jan 2008, Wolfgang Huber wrote:
>
>> When one of the two groups has only one member and the other one more
>> than 49, wilcox.test will exit with the below error message,
>>
>>  n=51; wilcox.test(1:n ~ 1:n==1, conf.int=TRUE)
>>
>>  Error in uniroot(wdiff, c(mumin, mumax), tol = 1e-04, zq =
>> qnorm(alpha/2,  :
>>   f() values at end points not of opposite sign
>>
>>
>> whereas with n=50 a result is returned:
>>
>>  n=50; wilcox.test(1:n ~ 1:n==1, conf.int=TRUE)
>>
>>         Wilcoxon rank sum test
>>
>> data:  1:n by 1:n == 1
>> W = 49, p-value = 0.04
>> alternative hypothesis: true location shift is not equal to 0
>> 95 percent confidence interval:
>>   1 49
>> sample estimates:
>> difference in location
>>                     25
>>
>>
>> I wonder whether it would be worthwhile to make the wilcox.test function
>> handle such (admittedly pathologic) cases more gracefully.
>>
>>
>> Happy New Year to all -
>>   Wolfgang
>>
>> ------------------------------------------------------------------
>> Wolfgang Huber  EBI/EMBL  Cambridge UK  http://www.ebi.ac.uk/huber


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Error from wilcox.test
Prof Brian Ripley