I have 2 groups of persons with repeated measures (the order of the measures does not matter [1,2] is the same as [2,1]). The data could look like that (3 persons per group, 6 measures each):
groupA = [1 3 6 5 2 9; 2 5 3 4 5 8; 8 7 3 6 2 4];
groupB = [3 4 5 4 4 1; 2 8 4 2 1 2; 3 2 5 5 1 2];
A straightforward way would be to compare the 2 groups via a ranksum test of the mean values of each person:
meansA = mean(groupA, 2); % => [4.3 4.5 5.0]
meansB = mean(groupB, 2); % => [3.5 3.2 3.0]
[p, h] = ranksum(meansA, meansB)
However, this type of analysis neglects that each of the mean values consists of several measures (and therefore underestimates the significance).
A statistician told me to use a "repeated measure ANOVA" instead but none of the ANOVA functions of MatLab seems to do exactly what I want. The closest thing that I could find was:
>> [p, atab] = anovan([1 3 6 5 2 9 2 5 3 4 5 8 8 7 3 6 2 4 3 4 5 4 4 1 2 8 4 2 1 2 3 2 5 5 1 2], {[zeros(1,18) ones(1,18)],[1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 5 6 6 6 6 6 6]}, 'varnames', {'individual', 'groupAorB'}, 'display', 'off')
p =
NaN
0.9774
But this seems not to work in the way I want it (NaN value and unrealistic p-value). I would be happy for any suggestions on how to perform an appropriate statistical test on these data in MatLab.
You should have a look at this FileExchange entry that deals with the one-way repeated measure ANOVA:
http://www.mathworks.com/matlabcentral/fileexchange/5576-rmaov1
The author (Antonio Trujillo-Ortiz) made some other nice entries for different designs (2 and 3 way anovas with repeated measures).
Unfortunately, the regular statistical functions in Matlab do not allow for repeated measure designs.