########################################################################## #########multiple-sample Rank-Sum Test for clustered data ####################### ########################################################################## ###Note: this function works for m groups and M clusters ###Note: the input is Cluster(from 1 to M), X(the value), ### and grp(the Groups are from 1 to m) ### Data must be arranged in the way illustrated in the sample below ### the output of the function is S.j, E(S.j), the chisq-statistic ### with degree of freedom of m-1, and p-values ### Written by: Xu, Ping ### Distributed "as is" without warrantee of any kind; use at your own risk! ########################################################################## clus.rank.sum<-function(Cluster,X,grp) { #####calculate quantity 2 (using the pooled estimate of F) n<-length(X) F.hat<-numeric(n) for (i in 1:n){ F.hat[i]<-(sum(X<=X[i])+sum(X clus.rank.sum(Cluster,X,grp) $S [1] 0.578125 0.921875 $E.S [1] 0.6666667 0.8333333 $Chisq.stat [,1] [1,] 1.392647 $df [1] 1 $p.value [,1] [1,] 0.2379586