Today we’re going to talk about another nonparametric test: the **Mann-Whitney U test**!

**When Would You Use It?**

The Mann-Whitney U test is a nonparametric test used to determine if two independent samples represent two populations with different medians.

**What Type of Data?**

The Mann-Whitney U test requires ordinal data.

**Test Assumptions**

- Each sample is a simple random sample from the population it represents.
- The two samples are independent.
- The original scores obtained are continuous random variables (which are later ranked).
- The underlying distributions of the samples are identical in shape (but do not necessarily have to be normal).

**Test Process**

Step 1: Formulate the null and alternative hypotheses. The null hypothesis claims that the two population medians are equal. The alternative hypothesis claims otherwise (one median is greater than the other, or that they are simply not equal).

Step 2: Compute the test statistics: U_{1} and U_{2}. Since this is best done with data, please see the example shown below to see how this is done.

Step 3: Obtain the critical value. Unlike most of the tests we’ve done so far, you don’t get a precise p-value when computing the results here. Rather, you calculate your U values and then compare them to a specific value. This is done using a table (such as the one here). Find the number at the intersection of your sample sizes for both samples at the specified alpha-level. Compare this value with the smaller of your U_{1} and U_{2} values.

Step 4: Determine the conclusion. If your test statistic is equal to or less than the table value, reject the null hypothesis. If your test statistic is greater than the table value, fail to reject the null (that is, claim that the medians are equal in the population).

**Example**

Today’s data come from my 2012 music selection. I wanted to see if the median play counts for two genres—pop and electronic—were the same. I chose these two because I think most of my favorite songs are of one of the two genres. To keep things relatively simple for the example, I sampled n = 8 electronic songs and n = 8 pop songs. Set α = 0.05.

H0: θ_{pop} = θ_{electronic}

Ha: θ_{pop }≠ θ_{electronic}

The following table shows several different columns of information. I will explain the columns below.

Column 1 is the genre of each song.

Column 2 is the play count for each song.

Column 3 is the overall rank of the play count, regardless of which genre it came from.

If there had been ties, I would have summed the number of ranks that were taken by the ties, and then divide that value by the number of ties.

To compute U_{1} and U_{2}, use the following equations:

So here,

The test statistic itself is the smaller of the above values; in this case, we get U = 28. In the table, the critical value for n_{1} = 8 and n_{2} = 8 and α = 0.05 for a two-tailed test is 13. Since U > 13, we fail to reject the null and retain the claim that the population medians are equal.

**Example in R**

No R example this week; most of this is easy enough to do by hand for a small-ish sample.