0

My statistics professor wants us to perform a manual Wilcoxon Rank-Sum Test using Matlab. Unfortunately, I have no experience with Matlab whatsoever, and I have been discovering as I go along. In short, we are given a list of 24 paired observations:

33 53 54 84 69 34 60 34 50 56 64 50 76 47 58 63 55 66 58 43 28 80 45 55

66 62 54 58 60 74 54 68 64 60 53 59 61 49 63 55 61 64 54 59 64 46 70 82

I've gotten to the point where I have a matrix with the absolute differences in the first column, the sign of the difference (indicated by a 1 for positive and -1 for negative) in the second column and the rank of the difference (1 through 24) in the third column.

I am struggling with finding a quick and efficient way to "break the ties" between the differences of equal size and allocating the average rank to each of these differences. I expect that some loops and logical statements may be required, but I am having a hard time with them as I have no prior experience.

Any suggestions on how to do this would be much appreciated.

Buck Thorn
  • 5,024
  • 2
  • 17
  • 27

1 Answers1

0

One way to average over the ranks for entries with matching differences is as follows:

irankavg=zeros(length(dp),1);
[dpu,ix,iclass]=unique(dp);
for ii=1:length(dpu)
    irankavg(iclass(ii)==iclass) = mean(irank(iclass(ii)==iclass));    
end

where dp is a column array that contains the differences

Buck Thorn
  • 5,024
  • 2
  • 17
  • 27