#The Wilcoxon Rank Sum Test, also known as the Mann-Whitney Test, is the non-parametric analogue to the two sample t-test #This test answers the same type of question in which you wish to compare two different samples to determine if they are significantly different from eachother #As this is a non-parametric test the assumption that the data follows a normal distribution is relaxed #At times the question of normality can be ambiguous when the data follows a nearly normal distribution so at times it is useful to compare this test to a two-sample t-test #Assumptions: #The observed values represent a random sampling of the population #The two variables are independent #The underlying distributions are continuous #The measurements have an ordinal scale, in other words the data can be ranked from lowest to highest #Hypotheses: #Ho: No ordinal difference in median for the population #H1: There is an ordinal difference in the medians for the populations #For this example we will use a dataset of plant growth under different treatments that comes pre-loaded with R PlantGrowth #There are three different groups, a control and two different treatment groups: ctrl, trt1, trt2 #As such we would like to compare the control group to each of the treatment groups attach(PlantGrowth) control=weight[group=="ctrl"] treatment1=weight[group=="trt1"] treatment2=weight[group=="trt2"] #For a Wilcoxon Rank Sum test the decision rule is very similar to most tests of significance #You must set an alpha value and compare that to your p-value #For this test we will use a=.05, if p < a then the results are significant #Running a Wilcoxon Rank Sum test in R is very simple using the wilcox.test function. wilcox.test(control,treatment1,exact=T,alternative="two.sided",paried=F) #Since the default settings are for a two sided test for unpaired data it is not necessary to include these #exact=T specifies that you want the test to compute exact p-values #We obtained a p-value greater than .05 so we cannot reject the null that treatment 1 is significantly different from the control wilcox.test(control,treatment2,exact=T) #The p-value is greater than alpha, however it is so close that it is worth further investigation wilcox.test(treatment1,treatment2,exact=T) #The p-value is less than alpha, treatment 1 is significantly different from treatment 2 #The results for the wilcox.test can be very similar to that for the two-sample t.test, but different in very significant ways. #To compare lets run two sample t.tests for the same data, using the same value of a=.05 and a very similar null and alternative hypothesis. t.test(control,treatment1,alternative="two.sided",conf.level=.95) #The p-value is greater than alpha so we reject the null for this test as well t.test(control,treatment2,alternative="two.sided",conf.level=.95) #The p-value is less than alpha so we cannot reject the null. Treatment 2 is significantly different from the control. #This conflicts directly with the results of the wilcox.test. Notice that both are very close the the alpha value; surrounding it on both above and below. #At times like this the question of normality becomes the principal concern. To determine which test we should use it is necessary to investigate how closely the data follows a normal distribution. t.test(treatment1,treatment2,alternative="two.sided",conf.level=.95) #The p-value is less than alpha so we reject the null. This agrees with the wilcox.test. qqnorm(control,main="Control Group") qqnorm(treatment2,main="Treatment Group Two")