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


Re: KrukalWallis by Fisher´s random shuffling
Posted:
Mar 28, 2013 2:06 AM


Oneway Anova: shuffling, CI and pvalue
Via Table Items Permutations, without replication and exhaustive, we aim to obtain a Confidence Interval along to pvalue for the test statistics H given by _____H = c*sum (Ri(j)^2/n(j)  3*(N+1) where c = 12/(N*N+1), N the total number of Table items, Ri(j) the sum of ranks concerning the j sample, size n(j). (Oneway Anova). Data The sourceTable is _________1___2___3___4___ ________11___5___6___7___ ________12___8___9__14___ ________19__10__13__15___ ________20__17__16__18___
H= 1.606
As it was said we intend to get a 5% significance CI, [u, v] that do contain H. The Procedure is: a) at random, without replication the N=20 items are disposed as a pseudo Table, the respective H(g) calculated, b) A very large sample M of Hs is obtained, then c) The 0.025, 0.975 quantiles do define the interval bounds u and v. By the other hand the pvalue is obtained by computing the proportion of pseudo Tables gives H(g)>H. A comparison with the Chisquared Distribution is made.
Results
M=400´000, 2 attempts: _________1) 0.234(.027)_8.463(.975)__pvalue=0.684 _________2) 0.234(.027)_8.529(.975)_________0.679 The Chisquared values leads to [0.216, 9.348], 0.342
Luis A. Afonso
REM "GALA0" REM CLS : ns = 4 REM DIM along(34), blong(34), clong(34) DIM W(9001) REM N(1) = 5: N(2) = 5: N(3) = 5: N(4) = 5 DATA 1,11,12,19,20 FOR i = 1 TO N(1): READ R(i, 1): v = v + 1 along(v) = R(i, 1) rt(1) = rt(1) + R(i, 1): NEXT i REM DATA 2,5,8,10,17 FOR i = 1 TO N(2): READ R(i, 2): v = v + 1 along(v) = R(i, 2) rt(2) = rt(2) + R(i, 2): NEXT i REM DATA 3,6,9,13,16 FOR i = 1 TO N(3): READ R(i, 3): v = v + 1 along(v) = R(i, 3) rt(3) = rt(3) + R(i, 3): NEXT i REM DATA 4,7,14,15,18 FOR i = 1 TO N(4): READ R(i, 4): v = v + 1 along(v) = R(i, 4) rt(4) = rt(4) + R(i, 4): NEXT i REM FOR k = 1 TO ns: total = total + N(k): NEXT k
FOR k = 1 TO ns Rin = Rin + rt(k) * rt(k) / N(k): NEXT k REM ct = 12 / (total * (total + 1)) REM H = ct * Rin  3 * (total + 1) LOCATE 4, 20 PRINT USING "SOURCE H= ##.### "; H FOR u = 1 TO total PRINT USING "###"; along(u); : NEXT u PRINT : PRINT REM REM COLOR 14 REM cc(1) = N(1): cc(2) = cc(1) + N(2) cc(3) = cc(2) + N(3): cc(4) = cc(3) + N(4) INPUT " How many K_Wallis "; alli REM FOR rpt = 1 TO alli: vi = 0 REM refresh FOR j = 1 TO total blong(j) = along(j) NEXT j REM REM LOCATE 14, 50 PRINT USING "############"; alli  rpt RANDOMIZE TIMER FOR y = 1 TO total 15 ju = INT(total * RND) + 1 IF blong(ju) = 1 THEN GOTO 15 clong(y) = along(ju) REM blong(ju) = 1 NEXT y REM REM REM SR(1) = 0: SR(2) = 0: SR(3) = 0: SR(4) = 0 FOR i1 = 1 TO cc(1) SR(1) = SR(1) + clong(i1) NEXT i1 FOR i2 = cc(1) + 1 TO cc(2) SR(2) = SR(2) + clong(i2) NEXT i2 FOR i3 = cc(2) + 1 TO cc(3) SR(3) = SR(3) + clong(i3) NEXT i3 FOR i4 = cc(3) + 1 TO cc(4) SR(4) = SR(4) + clong(i4) NEXT i4 si = 0 FOR ti = 1 TO ns si = si + SR(ti) * SR(ti) / N(ti) NEXT ti HH = ct * si  3 * (total + 1) IF HH > 1.606 THEN outt = outt + 1 / alli hh1 = INT(1000 * HH + .5) IF hh1 > 9000 THEN hh1 = 9000 W(hh1) = W(hh1) + 1 REM NEXT rpt REM cv(1) = .025: cv(2) = 1  cv(1) FOR tp = 1 TO 2 suum = 0 FOR i = 0 TO 9000 suum = suum + W(i) / alli IF suum > cv(tp) THEN GOTO 45 NEXT i 45 PRINT USING "#.### #.### "; i / 1000; suum NEXT tp: COLOR 13: PRINT PRINT USING " pvalue #.### "; outt COLOR 7 END

