Web pdp-10.trailing-edge.com

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0020/anovar.sta
There are 2 other files named anovar.sta in the archive. Click here to see a list.
```100'  NAME--ANOVAR
110'
120'  DESCRIPTION-- COMPLETE FACTORIAL ANALYSIS OF VARIANCE FOR UP
130'  TO 14 FACTORS. THE ANALYSIS OF VARIANCE IS PERFORMED BY THE
140'  USE OF THREE SPECIAL OPERATORS. THE ANALYSIS OF MOST OTHER
150'  DESIGNS CAN BE DERIVED BY REDUCING THEM FIRST TO THE FACTORAL
160'  DESIGNS,AND THEN POOLING CERTAIN COMPONENTS OF THE ANALYSIS
170'  OF VARIANCE TABLE.
180'
190'  SOURCE--H.O.HARTLEY,"MATHEMATICAL MODELS FOR COMPUTERS"
200'
210'  INSTRUCTIONS--THE PROGRAM REQUIRES CERTAIN DATA STATEMENTS ON
220'  INPUT AND PRODUCES A COMPLETE ANALYSIS OF VARIANCE TABLE FOR
230'  OUTPUT.DATA REQUIRED ON INPUT SHOULD BE INSERTED IN THE PROGRAM
240'  AS DATA STATEMENTS BEGINNING WITH LINE NUMBERS 2640.THE ORDER
250'  OF THE DATA SHOULD BE AS FOLLOWS:
260'
270'     T\$= TITLE OF ANALYSIS
280'     K = NUMBER OF FACTORS
290'     L\$= VECTOR CONTAINING AN ALPHABETIC LABEL FOR EACH VECTOR
300'     V = VECTOR CONTAINING LEVELS WITHIN EACH FACTOR
310'     N = TOTAL NUMBER OF DATA POINTS
320'     X = VECTOR CONTAINING DATA IN POSITIONS X(1) TO X(N)
330'
340'  THE DATA SHOULD BE STORED AS A FUNCTION OF THE ORDER IN
350'  WHICH THE FACTORS ARE LISTED IN L\$. THE FIRST FACTOR LISTED
360'  SHOULD CHANGE MOST RAPIDLY AND THE LAST FACTOR LISTED SHOULD
370'  CHANGE LEAST RAPIDLY. FOR EXAMPLE,WITH FOUR FACTORS OF 2
380'  LEVELS EACH, THE DATA SHOULD BE LISTED IN THE DATA STATEMENTS
390'  IN THE FOLLOWING ORDER:
400'
410'  X    , X    , X    , X    , X    , X    , X    , X    ,ETC.
420'   1111   2111   1211   2211   1121   2121   1221   2221
430'
440'  THE USER MUST ALSO SUPPLY THE FOLLOWING DIMENSION STATEMENTS
450'  WITH THE CORRECT NUMBERS IN THE PLACE OF THE VARIABLES GIVEN:
460'
470' DIMQ((2^K)-1),D((2^K)-1),M((2^K)-1)
480' DIM X( (V(1)+1)*(V(2)+1)*........*(V(K)+1) )
490'
500'  *  *  *  *  *  *  MAIN PROGRAM  *  *  *  *  *  *  *
510'
520'
530'
540'    *  *  MAIN PROGRAM   *  *
550 DIM V(14),T(14),S(14),U(14),P(14),Z(15),L\$(14)
560'LOCATION OF DIM STATEMENT
570'LOCATION OF DIM STATEMENT
600 FOR I=1 TO K
620 NEXT I
630 FOR I=1 TO K
650 NEXT I
670 FOR I=1 TO N
690 NEXT I
700 PRINT
710 PRINT
720 PRINT
730 PRINT
740 PRINT "ANALYSIS OF VARIANCE"
750 PRINT "      ";T\$
760 PRINT
770 PRINT
780 PRINT "LEVELS OF FACTORS"
790 FOR I=1 TO K
800 PRINT L\$(I),V(I)
810 NEXT I
820 PRINT
830 PRINT
840 PRINT
850PRINT"SOURCE OF";TAB(19);"SUMS OF";TAB(34);"DEGREES OF";TAB(53);"MEAN"
860PRINT"VARIATION";TAB(19);"SQUARES";TAB(35);"FREEDOM";TAB(52);"SQUARES"
870 GOSUB 1220
880 MAT S=ZER
890 LET L2=(2^K)-1
900 LET S(1)=1
910 FOR I=1 TO 14
920 LET Z(I)=0
930 NEXT I
940 LET Z(0)=K
950 LET O=S0=0
960 LET O=O+1
970 LET L=0
980 FOR I=1 TO K
990 LET Z(I)=0
1000 IF S(I)=0 THEN 1040
1010 LET L=L+1
1020 CHANGE L\$(I) TO R
```
```1030 LET Z(I)=R(1)
1040 NEXT I
1050 CHANGE Z TO F\$
1060 DEF FNS(C,W)=C-3-INT(FNP(LOG(ABS(W))/LOG(10)))
1070 DEF FNP(Y)=(ABS(Y)+Y)/2
1080 PRINT F\$;TAB(FNS(23,Q(O)));Q(O);TAB(38);D(O);TAB(FNS(55,M(O)));M(O)
1090 LET S0=S0+Q(O)
1100 IF O>=L2 THEN 1180
1110 FOR I=1 TO K
1120 IF S(I)=0 THEN 1150
1130 LET S(I)=0
1140 GO TO 1170
1150 LET S(I)=1
1160 GO TO 960
1170 NEXT I
1180 LET N=N-1
1190 PRINT "TOTAL";TAB(FNS(23,S0));S0;TAB(38);N
1200 STOP
1210REM
1220REM    SUBROUTINE AVDAT
1230REM
1240REM    CALCULATE TOTAL DATA AREA REQUIRED
1250 LET M1=V(1)+1
1260 FOR I=2 TO K
1270 LET M1=M1*(V(I)+1)
1280 NEXT I
1290REM    MOVE DATA IN X FOR REARRANGEMENT
1300 LET N1=M1+1
1310 LET N2=N+1
1320 FOR I=1 TO N
1330 LET N1=N1-1
1340 LET N2=N2-1
1350 LET X(N1)=X(N2)
1360 NEXT I
1370REM    CALCULATE MULTIPLIERS FOR STORAGE LOCATIONS
1380 LET S(1)=1
1390 FOR I=2 TO K
1400 LET S(I)=S(I-1)*(V(I-1)+1)
1410 NEXT I
1420 MAT T=CON
1430REM    PLACE DATA IN PROPER LOCATIONS
1440 LET N1=N1-1
1450 FOR I=1 TO N
1460 LET L=T(1)
1470 FOR J=2 TO K
1480 LET L=L+S(J)*(T(J)-1)
1490 NEXT J
1500 LET N1=N1+1
1510 LET X(L)=X(N1)
1520 FOR J=1 TO K
1530 IF T(J)=V(J) THEN 1560
1540 LET T(J)=T(J)+1
1550 GO TO 1580
1560 LET T(J)=1
1570 NEXT J
1580 NEXT I
1590REM
1600REM    SUBROUTINE AVCAL
1610REM
1620REM   CALCULATE LAST DATA POSITION OF EACH FACTOR
1630 LET U(1)=L+1
1640 FOR I=2 TO K
1650 LET U(I)=U(I-1)+S(I)
1660 NEXT I
1670REM    PERFORM CALCULUS OF OPERATION
1680 FOR I=1 TO K
1690 LET L=L2=1
1700 LET S0=0
1710 LET O=V(I)
1720 LET F=O
1730 LET I2=S(I)
1740 LET L7=U(I)
1750REM    SIGMA OPERATION
1760 FOR J=1 TO O
1770 LET S0=S0+X(L)
1780 LET L=L+I2
1790 NEXT J
1800 LET X(L)=S0
1810REM    DELTA OPERATION
1820 FOR J=1 TO O
1830 LET X(L2)=F*X(L2)-S0
1840 LET L2=L2+I2
1850 NEXT J
1860 LET S0=0
1870 IF L>=L7 THEN 1950
1880 IF L-L7+I2>0 THEN 1920
1890 LET L=L+I2
1900 LET L2=L2+I2
1910 GO TO 1760
1920 LET L=L+I2+1-L7
1930 LET L2=L2+I2+1-L7
1940 GO TO 1760
1950 NEXT I
1960REM
1970REM    SUBROUTINE MEANQ
1980REM
1990REM    CALCULATE TOTAL NUMBER OF DATA
2000 LET N=V(1)
2010 FOR I=2 TO K
2020 LET N=N*V(I)
2030 NEXT I
2040REM    SET UP CONTROL FOR MEAN SQUARE OPERATOR
2050 LET U(1)=V(1)
2060 FOR I=2 TO K
2070 LET U(I)=V(I)+1
2080 NEXT I
2090 LET O=1
2100REM    CLEAR AREA TO STORE SUMS OF SQUARES
2110 LET L2=(2^K)-1
2120 LET P(1)=1
2130 FOR I=2 TO K
2140 LET P(I)=2*P(I-1)
2150 NEXT I
2160 MAT Q=ZER
2170REM    PERFORM MEAN SQUARE OPERATOR
2180 MAT T=ZER
2190 LET L=0
2200 FOR I=1 TO K
2210 IF T(I)=U(I) THEN 2290
2220 IF L>0 THEN 2270
2230 LET T(I)=T(I)+1
2240 IF T(I)>V(I) THEN 2290
2250 LET L=L+P(I)
2260 GO TO 2300
2270 IF T(I)=V(I) THEN 2300
2280 GO TO 2250
2290 LET T(I)=0
2300 NEXT I
2310 IF L<=0 THEN 2350
2320 LET Q(L)=Q(L)+X(O)*X(O)
2330 LET O=O+1
2340 GO TO 2190
```
```2350REM    CALCULATE GRAND MEAN
2360 LET G=X(O)/N
2370REM    CALC.  FIRST DIVISOR REQD TO FORM SUM OF SQUARES
2380REM           SECOND DIVISOR (=DF) REQD TO FORM MEAN SQUARES
2390 MAT P=ZER
2400 LET O=0
2410 LET P(1)=1
2420 LET N4=N5=1
2430 FOR I=1 TO K
2440 IF P(I)=0 THEN 2470
2450 LET N4=N4*V(I)
2460 LET N5=N5*(V(I)-1)
2470 NEXT I
2480 LET F1=N*N4
2490 LET F2=N5
2500 LET O=O+1
2510 LET Q(O)=Q(O)/F1
2520 LET D(O)=N5
2530 LET M(O)=Q(O)/F2
2540 IF O>=L2 THEN 2620
2550 FOR I=1 TO K
2560 IF P(I)=0 THEN 2590
2570 LET P(I)=0
2580 GO TO 2610
2590 LET P(I)=1
2600 GO TO 2420
2610 NEXT I
2620 RETURN
2630REM    DATA BEGINS
2640DATA TEST DATA FOR SAMPLE RUN OF PROGRAM
2650DATA  4,A,B,C,R,4,3,3,2,72
2660DATA 3,10,9,8,24,8,9,3,2,8,9,8
2670DATA 4,12,3,9,22,7,16,2,2,2,7,2
2680DATA 5,10,5,8,23,9,17,3,2,8,6,3
2690DATA 2,14,9,13,29,16,11,3,2,7,5,3
2700DATA 7,11,5,8,28,18,10,6,6,6,5,9
2710DATA 9,10,27,8,28,16,11,7,8,9,8,15
2720END
```
```
```