Hi! I've been working on this Mann-Whitney U test program, but after a few seconds, the program just ends. Does anybody have any advice on how to fix this? Thanks!
Code:
I'll update this post if I figure out something else. My calculations for the Mann-Whitney U test are based on the formulae provided on pages 782-786 of the PDF in the link below:
https://github.com/chqngh-berkeley/personal/blob/master/Mathematical%20Statistics%20-%207th%20Edition%20-%20Wackerly.pdf
Code:
ClrHome
Output(5,8,"MANN-WHITNEY")
Output(6,11,"U TEST")
Output(10,8,"By StatManan")
Pause
ClrHome
Disp "Input both lists of sam-","ple data below."
Disp ""
Disp "To input your list,","press [2nd][stat] to find","it and press [enter]."
Disp ""
Input "Samp1List: ",⌊SAMP1
Input "Samp2List: ",⌊SAMP2
SortA(⌊SAMP1)
SortA(⌊SAMP2)
((dim(⌊SAMP1))*(dim(⌊SAMP2)))+(dim(⌊SAMP1)*(dim(⌊SAMP1)+1))2→U
augment(⌊SAMP1,⌊SAMP2)→⌊SAMPX
SortA(⌊SAMPX)
0→W
For(I,1,dim(⌊SAMPX)):
I→⌊RANK(I)
If ⌊SAMPX(I)=⌊SAMP1(I):Then
⌊RANK(I)→Y
W+Y→W
Else
W+0→W
End
U-W→U
If dim(⌊SAMP1)>10 and dim(⌊SAMP2)>20:Then
Disp "The sample sizes allow","for the use of a simpli-","fied large sample test.","","Press 1 for a one-tailed","test or 2 for a two-","tailed test.",""
Input "Which test? ",A
getKey→A
If A=92:Then
U-(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2)→T
√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12)→B
T/B→Z
Disp "Press if you wish to test","if Population 1 is","shifted to the right of","Population 2, or if","you wish to test if Popu-","lation 1 is shifted to","left of Population 2.",""
Input "Which alt. hypothesis?",A
getKey→A
If A=26:Then
normalcdf(199,(Z),(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))→P
ClrHome
Disp "Please input the desired","α-level below.",""
Input "α=?",A
If P<A:Then
ClrHome
Disp "Hypothesis rejected."
Disp ""
Disp "U"
Disp U
Disp "p="
Disp P
Disp "N₁"
Disp dim(⌊SAMP1)
Disp "N₂"
Disp dim(⌊SAMP2)
Else
ClrHome
Disp "Failed to reject."
Disp ""
Disp "U"
Disp U
Disp "p="
Disp P
Disp "N1"
Disp dim(⌊SAMP1)
Disp "N2"
Disp dim(⌊SAMP2)
Stop
Else:If A=24:Then
normalcdf(Z,199,(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))→P
ClrHome
Disp "Please input the desired","α-level below.",""
Input "α=?",A
If P<A:Then
ClrHome
Disp "Hypothesis rejected."
Disp ""
Disp "U"
Disp U
Disp "p="
Disp P
Disp "N₁"
Disp dim(⌊SAMP1)
Disp "N₂"
Disp dim(⌊SAMP2)
Else
ClrHome
Disp "Failed to reject."
Disp ""
Disp "U"
Disp U
Disp "p="
Disp P
Disp "N1"
Disp dim(⌊SAMP1)
Disp "N2"
Disp dim(⌊SAMP2)
Stop
Else:If A=93:Then
U-(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2)→T
√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12)→B
T/B→Z
normalcdf(Z,199,(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))+normalcdf(199,(Z),(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))→P
ClrHome
Disp "Please input the desired","α-level below.",""
Input "α=?",A
If P<A:Then
ClrHome
Disp "Hypothesis rejected."
Disp ""
Disp "U"
Disp U
Disp "p="
Disp P
Disp "N₁"
Disp dim(⌊SAMP1)
Disp "N₂"
Disp dim(⌊SAMP2)
Else
ClrHome
Disp "Failed to reject."
Disp ""
Disp "U"
Disp U
Disp "p="
Disp P
Disp "N1"
Disp dim(⌊SAMP1)
Disp "N2"
Disp dim(⌊SAMP2)
Stop
Else
ClrHome
Disp "U=",U,"","N₁=",dim(⌊SAMP1),"N₂=",dim(⌊SAMP2),"Press [enter] for inter-","pretation."
Pause
Disp ""
Disp "To find the p-value, use","a table of Mann-Whitney","U values given the above","values."
Stop
I'll update this post if I figure out something else. My calculations for the Mann-Whitney U test are based on the formulae provided on pages 782-786 of the PDF in the link below:
https://github.com/chqngh-berkeley/personal/blob/master/Mathematical%20Statistics%20-%207th%20Edition%20-%20Wackerly.pdf