# [R] median test

Frank E Harrell Jr f.harrell at Vanderbilt.Edu
Fri May 28 18:53:00 CEST 2010

```Linda,

There are different views about whether someone doing statistical
analysis should first take a certain number of statistics course.  I
think for your issue some background information would certainly help.
You have not correctly interpreted the paper.  The main point is that
for most cases likely to be seen in practice, the median test is
is a good choice for a huge variety of situations.  Even if the data are
Gaussian it has efficiency 3/pi whereas the median test has efficiency
2/pi in that case.

Frank

On 05/28/2010 08:58 AM, linda Porz wrote:
> Hello,
>
> I can't have different data these data came from mice that have lived under
> certain condition in the lab! I have just read the mentioned publication
> "Should the median test be retired from general use?" It says in the
> conclusion "If one felt that the data could not come from a Cauchy or slash
> distribution, the Wilcoxon should be used."! What is this? Is there is any
> test in R for a Cauchy or slash distribution? Can I used the unpaired
> Wilcoxon, or I have a Cauchy distributed data?
>
> Many thanks,
> Linda
>
> 2010/5/27 Joshua Wiley<jwiley.psych at gmail.com>
>
>> Hello Linda,
>>
>> The "problem" is actually the median of your data.  What the function
>> median.test() does first is combine both groups.  Look at this:
>>
>> median(c(group1, group2))
>>
>> the median is 1, but the lowest value of the groups is also 1.  So
>> when the function does the logical check z<  m where z = c(group1,
>> group2) and m is the median, there are no values that are less than
>> the median value.  Therefore there is only 1 level, and the fisher
>> test fails.
>>
>> You would either need different data or adjust the function to be:
>>
>> fisher.test(z<= m, g)\$p.value
>>
>> that way it's less than or equal to the median.
>>
>> Hope that helps,
>>
>> Josh
>>
>> On Thu, May 27, 2010 at 7:24 AM, linda Porz<linda.porz at gmail.com>  wrote:
>>> Hi all,
>>>
>>> I have found the following function online
>>>
>>> median.test<-function(y1,y2){
>>>   z<-c(y1,y2)
>>>   g<- rep(1:2, c(length(y1),length(y2)))
>>>   m<-median(z)
>>>   fisher.test(z<m,g)\$p.value
>>> }
>>>
>>> in
>>>
>>> http://www.mail-archive.com/r-help@r-project.org/msg95278.html
>>>
>>> I have the following data
>>>
>>>> group1<- c(2, 2, 2, 1, 4, 3, 1, 1)
>>>> group2<- c(3, 1, 3, 1, 4, 1, 1, 1, 7, 1, 1, 1, 1, 1, 2)
>>>> median.test(w1,group1)
>>> [1] 1
>>>> median.test(group1,group2)
>>> Error in fisher.test(z<  m, g) : 'x' and 'y' must have at least 2 levels
>>>
>>> I am very thankful in advance for any suggestion and help.
>>>
>>> Regards,
>>> Linda
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>> --
>> Joshua Wiley
>> Senior in Psychology
>> University of California, Riverside
>> http://www.joshuawiley.com/
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help