# median of two groups

15 messages
Open this post in threaded view
|

## median of two groups

 Dear all, What is the right test to test whether the median of two groups are statistically significant? Is it the wilcox.test, mood.test or the ks.test? In the text book I have got there is explanation for the Wilcoxon (Mann Whitney) test which tests ob the two variable are from the same population and also ks.test! Regards, Cheba         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: median of two groups

 None of them.   - mood.test() looks promising until you read the help page and see that it does not do Mood's test for equality of quantiles, it does Mood's test for equality of scale parameters.   - wilcox.test() is not a test for equal medians   - ks.test() is not a test for equal medians. Mood's test for the median involves dichotomizing the data at the pooled median and then doing Fisher's exact test to see if the binary variable has the same mean in the two samples. median.test<-function(x,y){     z<-c(x,y)     g <- rep(1:2, c(length(x),length(y)))     m<-median(z)     fisher.test(z Dear all, > > What is the right test to test whether the median of two groups are > statistically significant? Is it the wilcox.test, mood.test or the ks.test? > In the text book I have got there is explanation for the Wilcoxon (Mann > Whitney) test which tests ob the two variable are from the same population > and also ks.test! > > Regards, > Cheba > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > Thomas Lumley Assoc. Professor, Biostatistics [hidden email] University of Washington, Seattle ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: median of two groups

 Dear Thomas, Thank you very much for your answer! Can I use your function in my analysis? The wilcox.test() tests the differences in average ranks (H0: F(X)=F(Y)), why then do people  in many studies compare t.test() with wilcox.test()? This makes sometime people like me a bit confused! Regards, Cheba 2010/4/6 Thomas Lumley <[hidden email]> > > None of them. > >  - mood.test() looks promising until you read the help page and see that it > does not do Mood's test for equality of quantiles, it does Mood's test for > equality of scale parameters. >  - wilcox.test() is not a test for equal medians >  - ks.test() is not a test for equal medians. > > > Mood's test for the median involves dichotomizing the data at the pooled > median and then doing Fisher's exact test to see if the binary variable has > the same mean in the two samples. > > median.test<-function(x,y){ >   z<-c(x,y) >   g <- rep(1:2, c(length(x),length(y))) >   m<-median(z) >   fisher.test(z } > > Like most exact tests, it is quite conservative at small sample sizes. > >     -thomas > > > On Tue, 6 Apr 2010, cheba meier wrote: > >  Dear all, >> >> What is the right test to test whether the median of two groups are >> statistically significant? Is it the wilcox.test, mood.test or the >> ks.test? >> In the text book I have got there is explanation for the Wilcoxon (Mann >> Whitney) test which tests ob the two variable are from the same population >> and also ks.test! >> >> Regards, >> Cheba >> >>        [[alternative HTML version deleted]] >> >> ______________________________________________ >> [hidden email] mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help>> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html>> and provide commented, minimal, self-contained, reproducible code. >> >> > Thomas Lumley                   Assoc. Professor, Biostatistics > [hidden email]        University of Washington, Seattle > >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: median of two groups

Open this post in threaded view
|

## Re: median of two groups

 In reply to this post by Thomas Lumley Dear Thomas, I have been running simulations in order me to understand this problem! I have found something online where the absolute median difference is computed and permutations are ran to compute a p-value. Is such a test (if I can call it a test) tests the null hypothesis that median group 1 = median group 2? Thank you in advance for your help. Regards, Cheba 2010/4/6 Thomas Lumley <[hidden email]> > > > None of them. > >  - mood.test() looks promising until you read the help page and see that it > does not do Mood's test for equality of quantiles, it does Mood's test for > equality of scale parameters. >  - wilcox.test() is not a test for equal medians >  - ks.test() is not a test for equal medians. > > > Mood's test for the median involves dichotomizing the data at the pooled > median and then doing Fisher's exact test to see if the binary variable has > the same mean in the two samples. > > median.test<-function(x,y){ >   z<-c(x,y) >   g <- rep(1:2, c(length(x),length(y))) >   m<-median(z) >   fisher.test(z } > > Like most exact tests, it is quite conservative at small sample sizes. > >     -thomas > > > On Tue, 6 Apr 2010, cheba meier wrote: > >  Dear all, >> >> What is the right test to test whether the median of two groups are >> statistically significant? Is it the wilcox.test, mood.test or the >> ks.test? >> In the text book I have got there is explanation for the Wilcoxon (Mann >> Whitney) test which tests ob the two variable are from the same population >> and also ks.test! >> >> Regards, >> Cheba >> >>        [[alternative HTML version deleted]] >> >> ______________________________________________ >> [hidden email] mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help>> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html>> and provide commented, minimal, self-contained, reproducible code. >> >> > Thomas Lumley                   Assoc. Professor, Biostatistics > [hidden email]        University of Washington, Seattle > >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: median of two groups

 That's a robust way of obtaining a p-value, and can be classified as a test. The important trick here is to take into account that you have two tails in a distribution. If the p-value is calculated taking both tails into account, then it indeed tests the null hypothesis that median group1 - median group2 = 0 (which is equivalent to median group1 = median group2). Cheers Joris On Fri, May 7, 2010 at 2:00 PM, cheba meier <[hidden email]>wrote: > Dear Thomas, > > I have been running simulations in order me to understand this problem! I > have found something online where the absolute median difference is > computed > and permutations are ran to compute a p-value. Is such a test (if I can > call > it a test) tests the null hypothesis that median group 1 = median group 2? > > Thank you in advance for your help. > > Regards, > Cheba > > 2010/4/6 Thomas Lumley <[hidden email]> > > > > > > > None of them. > > > >  - mood.test() looks promising until you read the help page and see that > it > > does not do Mood's test for equality of quantiles, it does Mood's test > for > > equality of scale parameters. > >  - wilcox.test() is not a test for equal medians > >  - ks.test() is not a test for equal medians. > > > > > > Mood's test for the median involves dichotomizing the data at the pooled > > median and then doing Fisher's exact test to see if the binary variable > has > > the same mean in the two samples. > > > > median.test<-function(x,y){ > >   z<-c(x,y) > >   g <- rep(1:2, c(length(x),length(y))) > >   m<-median(z) > >   fisher.test(z > } > > > > Like most exact tests, it is quite conservative at small sample sizes. > > > >     -thomas > > > > > > On Tue, 6 Apr 2010, cheba meier wrote: > > > >  Dear all, > >> > >> What is the right test to test whether the median of two groups are > >> statistically significant? Is it the wilcox.test, mood.test or the > >> ks.test? > >> In the text book I have got there is explanation for the Wilcoxon (Mann > >> Whitney) test which tests ob the two variable are from the same > population > >> and also ks.test! > >> > >> Regards, > >> Cheba > >> > >>        [[alternative HTML version deleted]] > >> > >> ______________________________________________ > >> [hidden email] mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. > >> > >> > > Thomas Lumley                   Assoc. Professor, Biostatistics > > [hidden email]        University of Washington, Seattle > > > > > >        [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 [hidden email] ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php        [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: median of two groups

 In reply to this post by cheba meier Permutation tests are real tests (if done properly), but one subtle but important note:  The null hypothesis being tested is that the 2 distributions are identical, the medians being equal is part of that, but the null includes more than just that assumption. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [hidden email] 801.408.8111 > -----Original Message----- > From: [hidden email] [mailto:r-help-bounces@r- > project.org] On Behalf Of cheba meier > Sent: Friday, May 07, 2010 6:01 AM > To: Thomas Lumley > Cc: [hidden email] > Subject: Re: [R] median of two groups > > Dear Thomas, > > I have been running simulations in order me to understand this problem! > I > have found something online where the absolute median difference is > computed > and permutations are ran to compute a p-value. Is such a test (if I can > call > it a test) tests the null hypothesis that median group 1 = median group > 2? > > Thank you in advance for your help. > > Regards, > Cheba > > 2010/4/6 Thomas Lumley <[hidden email]> > > > > > > > None of them. > > > >  - mood.test() looks promising until you read the help page and see > that it > > does not do Mood's test for equality of quantiles, it does Mood's > test for > > equality of scale parameters. > >  - wilcox.test() is not a test for equal medians > >  - ks.test() is not a test for equal medians. > > > > > > Mood's test for the median involves dichotomizing the data at the > pooled > > median and then doing Fisher's exact test to see if the binary > variable has > > the same mean in the two samples. > > > > median.test<-function(x,y){ > >   z<-c(x,y) > >   g <- rep(1:2, c(length(x),length(y))) > >   m<-median(z) > >   fisher.test(z > } > > > > Like most exact tests, it is quite conservative at small sample > sizes. > > > >     -thomas > > > > > > On Tue, 6 Apr 2010, cheba meier wrote: > > > >  Dear all, > >> > >> What is the right test to test whether the median of two groups are > >> statistically significant? Is it the wilcox.test, mood.test or the > >> ks.test? > >> In the text book I have got there is explanation for the Wilcoxon > (Mann > >> Whitney) test which tests ob the two variable are from the same > population > >> and also ks.test! > >> > >> Regards, > >> Cheba > >> > >>        [[alternative HTML version deleted]] > >> > >> ______________________________________________ > >> [hidden email] mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. > >> > >> > > Thomas Lumley                   Assoc. Professor, Biostatistics > > [hidden email]        University of Washington, Seattle > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-> guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: median of two groups

 In reply to this post by cheba meier On Fri, 7 May 2010, cheba meier wrote: > Dear Thomas, > > I have been running simulations in order me to understand this problem! I > have found something online where the absolute median difference is computed > and permutations are ran to compute a p-value. Is such a test (if I can call > it a test) tests the null hypothesis that median group 1 = median group 2? No, that is testing whether the median of the differences is zero.  This is not the same as testing whether the difference of the medians is zero.      -thomas > Thank you in advance for your help. > > Regards, > Cheba > > 2010/4/6 Thomas Lumley <[hidden email]> > >> >> >> None of them. >> >>  - mood.test() looks promising until you read the help page and see that it >> does not do Mood's test for equality of quantiles, it does Mood's test for >> equality of scale parameters. >>  - wilcox.test() is not a test for equal medians >>  - ks.test() is not a test for equal medians. >> >> >> Mood's test for the median involves dichotomizing the data at the pooled >> median and then doing Fisher's exact test to see if the binary variable has >> the same mean in the two samples. >> >> median.test<-function(x,y){ >>   z<-c(x,y) >>   g <- rep(1:2, c(length(x),length(y))) >>   m<-median(z) >>   fisher.test(z> } >> >> Like most exact tests, it is quite conservative at small sample sizes. >> >>     -thomas >> >> >> On Tue, 6 Apr 2010, cheba meier wrote: >> >>  Dear all, >>> >>> What is the right test to test whether the median of two groups are >>> statistically significant? Is it the wilcox.test, mood.test or the >>> ks.test? >>> In the text book I have got there is explanation for the Wilcoxon (Mann >>> Whitney) test which tests ob the two variable are from the same population >>> and also ks.test! >>> >>> Regards, >>> Cheba >>> >>>        [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> [hidden email] mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help>>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html>>> and provide commented, minimal, self-contained, reproducible code. >>> >>> >> Thomas Lumley                   Assoc. Professor, Biostatistics >> [hidden email]        University of Washington, Seattle >> >> > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > Thomas Lumley Assoc. Professor, Biostatistics [hidden email] University of Washington, Seattle ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: median of two groups

Open this post in threaded view
|

## Re: median of two groups

Open this post in threaded view
|

## Re: median of two groups

Open this post in threaded view
|

## Re: median of two groups

Open this post in threaded view
|