.
. Perform a Wilcoxon rank sum (also called a Mann-Whitney U)
. non-parametric 2-sample t-test.
.
. The data for the 2 variables should be previously created and
. saved in X1 and X2 before calling this macro.
.
LET N1 = SIZE X1
LET N2 = SIZE X2
LET N = MIN(N1,N2)
.
LET TAG1 = 1 FOR I = 1 1 N1
LET TAG2 = 2 FOR I = 1 1 N2
LET X = X1
LET TAG = TAG1
EXTEND X X2
EXTEND TAG TAG2
.
LET X = SORTC X TAG
LET X = RANK X
LET W1 = SUM X SUBSET TAG = 1
LET W2 = SUM X SUBSET TAG = 2
LET U1 = W1 - N1*(N1+1)/2
LET U2 = W2 - N2*(N2+1)/2
LET U = MIN(U1,U2)
.
FEEDBACK OFF
IF N > 8
LET UU = N1*N2/2
LET SIGMA = SQRT(N1*N2*(N1+N2+1)/12)
LET Z = (U - UU)/SIGMA
LET ALPHA = 0.05
LET ALPHA2 = 1.0 - ALPHA/2
LET CRITICAL = NORPPF(ALPHA2)
PRINT " "
PRINT "H0: U1 = U2"
PRINT "HA: U1 <> U2"
PRINT "WILCOXON SIGNED RANK U STATISTIC = ^U"
PRINT "NORMAL APPROXIMATION FOR WILCOXON SIGNED RANK U STATISTIC = ^Z"
PRINT "NORMAL CRITICAL VALUE = +/- ^CRITICAL"
LET Z2 = ABS(Z)
IF Z2 <= CRITICAL
PRINT "ACCEPT NULL HYPOTHESIS AT THE ^ALPHA SIGNIFICANCE LEVEL"
END OF IF
IF Z2 > CRITICAL
PRINT "REJECT NULL HYPOTHESIS AT THE ^ALPHA SIGNIFICANCE LEVEL"
END OF IF
END OF IF
IF N <= 8
PRINT " "
PRINT "H0: U1 = U2"
PRINT "HA: U1 <> U2"
PRINT "WILCOXON SIGNED RANK U STATISTIC = ^U"
PRINT "COMPARE THIS VALUE TO TABLES FOR THE WILCOXON"
PRINT "SIGNED RANK TEST."
END OF IF
.