Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


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


No Tables and rigorously, Chisquare Goodnessoffit Test
Posted:
Oct 3, 2013 1:27 PM


No Tables and rigorously, Chisquare Goodnessoffit Test
It worth to emphasize that through the simulation of the interval contents we are able to calculate model rigorous pvalues of the Chisquare Test, therefore avoiding both the rule that each interval must contain at least 5 (6?) observations and the use of the approximation the Chi.square Distribution does provide. Suppose that 100 observations are distributed among the intervals as, ___14, 4, 11, 14, 14, 16, 21, 6_____ Uniformity as Null Hypotheses: Expected 12.5 by each interval.Test: 16.640, 7 df. Pvalue = 0.0199.
Method
By the statement INT(8*rnd)+1 the current value is directed to the memory 1, 2, ..., 8 and to the respective content a unit is added; performing 100 times the sample is simulated and the statistics Chi is calculated: if is larger than the sample one, 16.640 a significant value is found. Repeating a great number of times, say 40´000 the fraction of significant pvalues is obtained, say 0.01961 (see below). I had performed 5 times this procedure.
Results
__0.01961 / 40´000 samples __0.01983 __0.01976 __0.01956 __0.01980
It is shown that the experimental sample is no uniform at the ordinary 5% significance level.
Luis A. Afonso
REM "FREE" CLS COLOR 12 DEFDBL AZ DATA 14,4,11,14,14,16,21,6 FOR i = 1 TO 8: READ n(i) s = s + n(i): NEXT i E = s / 8 FOR i = 1 TO 8: chii = (n(i)  E) ^ 2 / E chi = chi + chii: NEXT i LOCATE 8, 50 PRINT USING " SAMPLE chi= ###.### "; chi REM REM COLOR 7 LOCATE 11, 48: PRINT " pvalue = " RANDOMIZE TIMER all = 40000 FOR rpt = 1 TO 5 FOR j = 1 TO all LOCATE 10, 50: PRINT USING "########"; all  j FOR kk = 1 TO 8: inn(kk) = 0: NEXT kk REM FOR nn = 1 TO 100 REM kr = INT(8 * RND) + 1 inn(kr) = inn(kr) + 1 NEXT nn REM FOR i = 1 TO 8: c = (inn(i)  E) ^ 2 / E chiR = chiR + c: NEXT i IF chiR > chi THEN outt = outt + 1 / all chiR = 0 NEXT j LOCATE 11 + rpt, 50 PRINT USING "##.### "; outt outt = 0 NEXT rpt END



