Luis A. Afonso
Posts:
4,743
From:
LIsbon (Portugal)
Registered:
2/16/05


KrukalWallis by Fisher´s random shuffling
Posted:
Mar 18, 2013 7:58 AM


KrukalWallis by Fisher´s random shuffling Data copied from www.sussex.ac.uk/Users/.../KruskalWallis%20Handoout2011.pdf
The statistics, for k samples __H= 12/(N*(N+1))* [T(i)*T(i)/n(i)]  3*(N+1) _Where __N= total of values, T( ) sample i, n( ) size, total of ranks The KW follows approximately a Chi Square with k1 degrees of freedom. The symbol [ ] represents the sum of values from i=1 to k.
The algorithm Each pseudoTable is obtained distributing at random without replacement our observed ranks among the samples with regard to their sizes. This Table provides a generic H´. Repeating a huge number of times we get a set of values from which the 0.025 and 0.975 quantiles are calculated.
Results The test (prior to Fisher´s simulations) get H0= 7.271 which pvalue, Chisquare, 2 degrees of freedom, is 2.64%. The pseudo Tables show that with 400´000 of them, 3 times, there are 2.03%, 2.06%, 2.09% H´ values greater than H0, well in accordance with the former. Luis A. Afonso
REM "GRAHMIX" CLS DEFDBL AZ DIM ri(24), ribis(24) DATA 1,2,3,4 DATA 5.5,5.5 DATA 7,8,9,10,11,12 DATA 14,14,14 DATA 16 DATA 17.5,17.5 DATA 19,20,21,22,23,24 REM FOR i = 1 TO 24: READ ri(i): totr = totr + ri(i) ribis(i) = ri(i): NEXT i REM N = 24: C = 12 / (N * (N + 1)) INPUT " HOW MANY TABLES "; many REM FOR tb = 1 TO many REM LOCATE 10, 50: PRINT USING "########"; many  tb RANDOMIZE TIMER FOR t = 1 TO N: ribis(t) = ri(t): NEXT t SUM(1) = 0: SUM(2) = 0: SUM(3) = 0 FOR ix = 1 TO 8 1 gg = INT(24 * RND) + 1 IF ribis(gg) = 2013 THEN GOTO 1 SUM(1) = SUM(1) + ribis(gg) ribis(gg) = 2013 NEXT ix FOR iy = 1 TO 8 2 gg = INT(24 * RND) + 1 IF ribis(gg) = 2013 THEN GOTO 2 SUM(2) = SUM(2) + ribis(gg) ribis(gg) = 2013 NEXT iy SUM(3) = totr  (SUM(1) + SUM(2)) aa = SUM(1) * SUM(1) / 8 bb = SUM(2) * SUM(2) / 8 cc = SUM(3) * SUM(3) / 8 tsum = aa + bb + cc hh = C * tsum  3 * (N + 1) IF hh > 7.271 THEN sgni = sgni + 1 / many NEXT tb LOCATE 10, 50 PRINT USING "sgnif.% = ##.## "; sgni * 100 END

