Mann-Whitman: critical values by Monte Carlo



Using Random Numbers we can easily simulate pairs of samples, X, Y, and then, by ordering all values, we find their ranks as a preliminary step to perform the Mann-Whitney test.
The *test statistic W* is obtained by summing the ranks of the shorter size sample values (X) - symbol r(X).
The program below (MANN) provides the follow cumulative values (sizes 12 + 12).


____r(Y)__freq.________r(X)
____201__.9991________99
____194__.9958_______106
____190__.9913_______110
____184__.9773_______116
____179__.9956_______121
____172__.9909_______128

If we compare these values with those finding in literature (W. J. Conover, Practical Nonparametric Statistics):_98, 106, 110, 116, 110, 121, 128_we will see that this method to find them seems safe though slow in the case of personal computers.

_____licas (Luis A. Afonso)


REM "MANN"
CLS
INPUT " size shorter "; na
INPUT " size larger "; nb: n = na + nb
nna = (1 + n) * n / 2
DIM x(nb), y(nb), join(na + nb), has(nna)
vv = 10000
FOR rpt = 1 TO vv
LOCATE 6, 50
PRINT USING "###########"; vv - rpt
RANDOMIZE TIMER
FOR i = 1 TO na
x(i) = RND: join(i) = x(i)
NEXT i
FOR ii = 1 TO nb
y(ii) = RND: join(na + ii) = y(ii)
NEXT ii
FOR jo = 1 TO na
w = join(jo): order = 1
FOR j1 = 1 TO na + nb
IF join(j1) < w THEN order = order + 1
NEXT j1
xorder = xorder + order
NEXT jo
has(xorder) = has(xorder) + 1
xorder = 0
aa = INT(rpt / 10000): a = rpt / 10000
IF aa <> a THEN GOTO 100
u(1) = .999 * rpt: u(2) = .995 * rpt
u(3) = .99 * rpt: u(4) = .975 * rpt
u(5) = .95 * rpt: u(6) = .9 * rpt
FOR e = 1 TO 6: sum = 0
FOR ij = 0 TO nna
sum = sum + has(ij)
IF sum > u(e) THEN GOTO 111
NEXT ij
LOCATE 7, 12
111 wy(e) = sum / rpt: iab = na * (n + 1) - ij
PRINT USING "### #.#### ###";
ij; wy(e); iab
NEXT e
100 NEXT rpt : END
.



Relevant Pages


Loading