STATISTICA







STATISTICA BASIC Program Schaha.stb

{ Schaich's and Hamerle's multiple comparison of rank sums
Dr. Stefan Funke, Braunschweig, Germany (funke@ibm.net)
11/1995
(nothing is guaranteed - use the program at your own risk)
Literature: Bortz, Lienert, and Boehnke: Verteilungsfreie Methoden in der Biostatistik, Springer 1990 p. 230
Generate the input scrollsheet from Nonparametrics: Kruskal-Wallis ANOVA, median test.
Its structure is:
  code valid n sum of ranks
group1
c1
n1
sum1
...
     
groupn
cn
nn
sumn
This table must be the ACTIVE scrollsheet when schaha.stb is run. }

RandomAccess;
NoDataFileVariableNames; 
 
handle:=GetScrollsheet(0); { get active scrollsheet } 
ScrollSheetGetTitle(handle,1,s$); 
s2$:=mid(s$,1,20); 
if (not(s2$='Kruskal-Wallis ANOVA')) and (not(s2$='Kruskal-Wallis-ANOVA')) then 
   begin 
      DisplayMessageBox(MB_OK,'Aborting!', 
             'Active scrollsheet is not a Kruskal-Wallis ANOVA by ranks!'); 
      exit; 
   end; 
ncols:=ScrollsheetGetNbCols(handle); 
nrows:=ScrollsheetGetNbRows(handle); 
groupnames$:=''; 
for i:=1 to nrows do  
  begin 
    ScrollsheetGetRowName (handle, i, s$); 
        groupnames$:=groupnames$+s$+'|'; 
    end; 
 
k:=nrows; 
df:=k-1; 
ReDim x(nrows,ncols); 
ReDim rsum(nrows),ni(nrows),diff(k,k),diffmat(k,k),crit(k,k); 
ReDim res(5),sigmat(k,k); 
ScrollsheetGetMatrix(handle, 1, 1, x); 
 
res(1):=0.05; 
DisplayNumericInputBox ('Select significance level', 'p = ', res); 
alpha:=res(1); 
 
n:=0; 
for i:=1 to nrows do  
   begin 
     rsum(i):=x(i,3); 
     n:=n+x(i,2); 
     ni(i):=x(i,2); 
   end; 
 
 
ck:=vchi2(1-alpha,df); 
 
for i:=1 to k do 
   begin 
      for j:=1 to k do 
        begin 
           if (i=j) then 
              begin 
                diff(i,j):=0; 
                crit(i,j):=0; 
              end 
           else 
              begin 
                 r1:=rsum(i)/ni(i); 
                 r2:=rsum(j)/ni(j); 
                 d:=Abs(r1-r2); 
                 diffmat(i,j):=r1-r2; 
                 diff(i,j):=d; 
                 cr:=sqrt(ck)*sqrt(n*(n+1)/12)*sqrt( (1/ni(i)) + (1/ni(j)) ); 
                 crit(i,j):=cr; 
                 if (d>cr) then sigmat(i,j):=1 else sigmat(i,j):=0; 
              end; 
        end; 
   end; 
 
shandle1:=NewScrollsheet(k,k,sigmat,'Significance matrix',groupnames$,groupnames$); 
for i:=1 to k do ScrollSheetSetColumnFormat(shandle1,i,SCF_INTEGER,1); 
for i:=1 to k do 
   begin 
      for j:=1 to k do 
         begin 
           if (sigmat(i,j)=1) then ScrollSheetSetTextValue(shandle1,i,j,'sig.') 
           else ScrollSheetSetTextValue(shandle1,i,j,'n. s.'); 
         end; 
   end; 
shandle2:=NewScrollsheet(k,k,diffmat,'Matrix of differences',groupnames$,groupnames$); 
 
res(1):=k; 
res(2):=n; 
res(3):=df; 
res(4):=cr; 
res(5):=alpha; 
drownames$:='samples|sum of observations|df|critical value|sig.level'; 
dcolnames$:='Parameters'; 
NewScrollsheet(5,1,res,'Schaich´s and Hamerle´s comparison of rank 
sums',drownames$,dcolnames$); 
Back to List of Programs



[StatSoft]
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217

[StatSoft]e-mail: info@statsoft.com

©Copyright StatSoft, Inc., 1984-2004.
StatSoft, StatSoft logo, STATISTICA, SEWSS, SEDAS, Data Miner, SEPATH and GTrees are trademarks of StatSoft, Inc.