Stat Lab
Analysis Of Variance
A Wachtel
ANOVA is an acronym for Analysis of Variance. It calculates the F-statistic which is the ratio of variances between the data of individual "treatment" groups and the means which belong to these groups. Depending on the "degree of freedom" (DF) associated with each, a confidence limit can be obtained from tables of F-values. The "1" stands for "one way" which means that different tratments are compared with each other under presumably equal (more accurately randomized) conditions. This is not the place to present an exhaustive treatment on ANOVA. Suppose, however, that you wished to compare the average prices of a few different makes of cars, and went to several dealers. Enter the prices for each make followed by 999, then go on to the next make. Finally, enter 999,9999. Type RUN and obtain the F-statistic for x and y degrees of freedom where x = number of makes -1, and y = total number of data -1. Suppose now, that you wish to be 95% confident of these results. Look up a table for F at the 95% confidence level and go into x and y degrees of freedom. Compare the F value obtained by the program with that shown in that place in the table. If it is higher, then you can be 95% sure that the difference between any two means (average prices) for different makes is real rather than due to the differences charged by different dealers for a particular make.
In this program, I have provided for the entry of the data in DATA statements rather than by INPUT (or worse, INPUT#). DATA become part of the program and are therefore portable. They can be edited and appended as needed. I strongly believe that counting is a job for computers, not people, so you won't have to create a FOR-NEXT loop for an array to permit you to correct an input error which usually occurs near the end of a long series of entries. There is lots of room, and if you need more, you can provide it by renumbering the program. Instead of using tables, the confidence limit (percentile) can also be obtained from a program by Lon Poole and Mary Borchers ("Some Common Basic Programs") - Osborne Associates.
0 PRINT "L" : GOTO480 100 REM ONE WAY ANALYSIS OF VARIANCE 110 REM A. WACHTEL, PITTSBURGH, PA 152:5 120 PRINT "L" 130 PRINT "TREATMENT MEANS" 140 PRINT "__________" 150 DEF FNA(X) = INT (X * 100 + .5)/100 160 S1 = 0 : Q1 = 0: T1 = 0: N1 = 0: K = 0 170 N = 0: S = 0: Q = 0 180 READ Y 190 IF Y = 999 THEN 250 200 IF Y = 9999 THEN 320 210 S = S + Y 220 Q = Q + Y * Y 230 N = N + 1 240 GOTO 180 250 S1 = S1 + S: Q1 = Q1 + Q: N1 = N1 + N 260 H = S/N 270 T = S * S/N 280 T1 = T1 + T 290 K = K + 1 300 PRINT "T"K"=" FNA(H) 310 GOTO 170 320 G=S1 * S1/N1 330 C = Q1 - G: T2 = T1 - G: E = C - T2 340 D1 = K - 1: D2 = N1 - K 350 M1 = T2/D1: M2 = E/D2: F = M1/M2 360 PRINT 370 PRINT "SOURCE"; SPC(6); "SSQ"; SPC (9);"DF"SPC(7);"MS" 380 PRINT "______"; SPC(6);"______"; SPC(9)"___";SPC(7);"___" 390 PRINT 400 PRINT" CRUDE"; TAB(8)Q1;TAB(23)N1 410 PRINT" COR.F"; TAB(8)G;TAB(24)"1" 420 PRINT" TOTAL"; TAB(8)C;TAB(23)N1-1 430 PRINT" TREAT"; TAB(8)T2;TAB(23)D1;TAB(31)FNA(M1) 440 PRINT" ERROR"; TAB(8)E; TAB(23)D2; TAB (31)FNA(M2) 450 PRINT 460 PRINT "F("D1"AND"D2"DEGREES OF FREED OM)="FNA(F) 470 GOTO 530 480 PRINT "USE LINE 0 AND LINES UP TO 11 9 TO 490 PRINT "ENTER DATA. PLACE 999 AT THE END 500 PRINT "OF EACH TREATMENT SERIES. 510 PRINT "PLACE 9999 AFTER THE LAST 999. 520 PRINT "(AVOID 999 OR 9999 AS DATA). 530 END READY.