Sign up ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I have a very basic question concerning how to compare the responses of two groups of subjects, group = A and group = B, to a same test. The responses are stored in x.

My starting dataset is in the following form:

id    group    x 
1       A     15
2       A     17
3       A     22

50      B     22
51      B     12
52      B     13


My initial idea was to split x into two variables xA and xB, and then to sort both of them according to their group, like this:

    xA      xB
    15      12
    17      13     
    22      22     
   ...     ...

Then I wanted to run a simple Pearson's test between the newly created xA and xB.

To me this strategy seems rather artificial: I am sorting the variables before making the comaparison, which makes very likely to find some sort of linear dependence...

I am interested in evaluating whether there is some sort of accordance between the subjects of the two grous in answering to the test. I also thought to adopt a Wilcoxon test on the equality of the medians of the two variables.

Which strategy would you suggest?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

So the main methods available would be an independent samples t-test (unpaired t-test) -- which asks whether the sample means for the two groups were likely to arise from two populations with the same means -- or a Wilcoxon-Mann-Whitney test, (which doesn't technically test whether medians are equivalent in two groups -- see e.g. Why is the Mann–Whitney U test significant when the medians are equal? which links through to a detailed explanation at

Both of these approaches are about asking whether the distribution of scores differs by group, which seems to accord with your question.

When you say you might do a Pearson's test to look at the relationship, do you mean a correlation? That wouldn't make sense, due to arbitrary pairing (which you've kind of identified already). I can't think of any variation on this which would be appropriate for your data, and the above methods would suffice if they match your analysis aims.

share|improve this answer
Thank you very much for the answer. It is a rank-sum test indeed. My very last doubt is: the two groups are of unequal sample size. Stata requires two variables of equal length, otherwise it automatically drops observations (from the upper tail of the longer variable) accordingly. Also, the two distributions are very skewed, hence the normality assumption required by the t-test is not met.. –  lando.carlissian Jan 14 '13 at 23:57
I think the problem you describe might be due to putting the data into two "columns" -- Stata (and many other stats packages) then presumes that the ordering of rows is informative (i.e. represent paired data, which as discussed is not appropriate here). So Stata is probably trying to do a Wilcoxon signed-ranks test (analog to a paired t-test) whereas you actually want a Wilcoxon ranked-sums test (aka Mann-Whitney test). So your original data format would work -- command in Stata would be ranksum x, by(group) –  James Stanley Jan 15 '13 at 0:17
Thank you very much for the help! –  lando.carlissian Jan 15 '13 at 0:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.