Stata Help

Conducting Mann-Whitney U (Wilcoxon rank sum) Tests in Stata

Mann-Whitney U Tests are an option for when typical t-tests can't be used. Before you run one, learn more about the theory behind it. They do not require anything special from your data, just that there are two groups (therefore a grouping variable) and a dependent variable.

The basic syntax is ranksum [depvar], by ([grouping var])

For example, if I want to look at happiness scores for girls and boys at graduation, the command would look like ranksum happy, by(gender) and would produce the following output:

The output gives us a handy table displaying the two groups, their Ns (number of observations), the observed ranked sums and the rank sum that would be expected if the null hypothesis were retained (if there were no difference).  Tied ranks can be an issue, so below the table there is a variance adjustment to account for these ties. Then we are reminded of the null hypothesis, and given the z-statistic and p-value.


Back to Nonparametric Tests

Back to Home