Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0020/2x2.sta
There are 2 other files named 2x2.sta in the archive. Click here to see a list.
100'  NAME--2-X-2
110'
120'  DESCRIPTION--CALCULATES VARIOUS PERCENTAGES AND STATISTICS FOR
130'  2-X-2 TABLES.
140'
150'  SOURCE--UNKNOWN
160'
170'  INSTRUCTIONS--ENTER DATA AS A,B,C,D WHERE THE TABLE IS IN
180'  THE FOLLOWING FORM:
190'
200'           NOT Y  Y
210'           *********
220'         X * A * B *  A+B
230'           *********
240'     NOT X * C * D *  C+D
250'           *********
260'            A+C B+D     N
270'
280'  NOTE: TO TERMINATE EXECUTION, SET A=B=C=D=0
290'
300'
310'  *  *  *  *  *  *   MAIN PROGRAM  *  *  *  *  *  *  *  *  *  *  *  *
320'
330 DEF FNP(A,B) = A + 1.96 * SQR((A*(1.0-A))/B)
340 DEF FNL(A,B) = A - 1.96 * SQR((A*(1.0-A))/B)
350 DEF FNR(A) = 100* (INT(1000*A+.5)/1000)
360 DEF FNF(A,B)=1.96*SQR((A*(1.0-ABS(B))^2)/4)
370 PRINT
380 PRINT "ENTER A,B,C,D";
390 INPUT A,B,C,D
400 LET R1= A + B
410 LET R2 = C + D
420 LET C1 = A + C
430 LET C2 = B + D
440 LET N = C1 + C2
450 IF N= 0 THEN 1490
460 LET K1 = (B*C)-(A*D)
470 LET K2 = (B*C)+(A*D)
480 FOR I= 1 TO 5
490 PRINT
500 NEXT I
510 PRINT TAB(25);"OBSERVED FREQUENCIES"
520 PRINT
530 PRINT TAB(20);"NOT Y";TAB(30);"Y"
540 PRINT TAB(20);"=====";TAB(28);"====="
550 PRINT
560 PRINT TAB(15);"X";TAB(20);A;TAB(28);B
570 PRINT
580 PRINT TAB(11);"NOT X";TAB(20);C;TAB(28);D
590 PRINT
600 PRINT TAB(36);N
610 PRINT
620 PRINT
630 PRINT "IS THIS TABLE CORRECT";
640 INPUT Z$
650 IF Z$ = "YES" THEN 710
660 IF Z$ = "NO" THEN 690
670 PRINT "TRY A YES OR NO ANSWER";
680 GO TO 640
690 PRINT " THEN TRY A,B,C,D AGAIN";
700 GO TO 390
710 PRINT "DO YOU WANT THE PERCENTAGE TABLES";
720 INPUT Z$
730 IF Z$ = "NO" THEN 1050
740 IF Z$ = "YES" THEN 770
750 PRINT "I'LL TAKE A SIMPLE YES OR NO ANSWER";
760 GO TO 720
770 PRINT TAB(25);"PERCENTAGES"
780 PRINT
790 REM SETTING CONFIDENCE INTERVALS
800 LET P1 = R1/N
810 LET P2 = C2/N
820 LET U(1) = FNP(P1,N)
830 LET L(1) = FNL(P1,N)
840 LET U(2) = FNP(P2,N)
850 LET L(2) = FNL(P2,N)
860 PRINT TAB(25);"PER CENT X";TAB(40);"PER CENT Y"
870 PRINT "UPPER LIMIT (.95)";TAB(29);FNR(U(1));TAB(44);FNR(U(2))
880 PRINT "SAMPLE VALUE";TAB(29);FNR(P1);TAB(44);FNR(P2)
890 PRINT "LOWER LIMIT (.95)";TAB(29);FNR(L(1));TAB(44);FNR(L(2))
900 PRINT
910 PRINT
920 PRINT
930 PRINT TAB (20);"PER CENT Y";TAB(33);"N"
940 PRINT "AMONG X";TAB (24);FNR(B/R1)
950 PRINT TAB(31);R1
960 PRINT"AMONG NOT X";TAB(24);FNR(D/R2)
970 PRINT TAB(31);R2
980 PRINT
990 PRINTTAB(20);"PER CENT X";TAB(33)"N"
1000 PRINT "AMONG Y";TAB(24);FNR(B/C2)
1010 PRINT TAB(31);C2
1020 PRINT "AMONG NOT Y";TAB(24);FNR(A/C1)
1030 PRINT TAB (31);C1
1040 PRINT
1050 PRINT
1060 PRINT "DO YOU WANT TO KNOW THE VALUE OF CHI-SQUARE";
1070 INPUT Z$
1080 IF Z$ = "NO" THEN 1300
1090 IF Z$ = "YES" THEN 1120
1100 PRINT "ALL RIGHT!!! YES OR NO--";
1110 GO TO 1070
1120 PRINT
1130 PRINT
1140 PRINT
1150 REM CHI SQUARE
1160 LET C9 = N * (ABS((B*C)-(A*D))-(N/2))^2
1170 LET C(1) = C9/(R1*R2*C1*C2)
1180 PRINT "CHI SQUARE IS ";TAB(20);FNR(C(1))/100
1190 IF C(1) < 10.8 THEN 1220
1200 PRINT "THIS IS SIGNIFICANT AT THE 0.001 LEVEL WITH 1 D.F."
1210 GO TO 1290
1220 IF C(1) < 6.6 THEN 1250
1230 PRINT "THIS IS SIGNIFICANT AT THE 0.01 LEVEL WITH 1 D.F."
1240 GO TO 1290
1250 IF C(1) < 3.8 THEN 1280
1260 PRINT "THIS IS SIGNIFICANT AT THE 0.05 LEVEL WITH 1 D.F."
1270 GO TO 1290
1280 PRINT " THIS IS NOT SIGNIFICANT AT THE 0.05 LEVEL WITH 1 D.F."
1290 PRINT
1300 PRINT
1310 PRINT "DO YOU WANT TO KNOW THE VALUE OF Q";
1320 INPUT Z$
1330 IF Z$="NO" THEN 1460
1340 IF Z$="YES" THEN 1370
1350 PRINT "SORRY, I CAN ONLY READ A YES OR A NO. TRY AGAIN";
1360 GO TO 1320
1370 REM CALCULATION OF Q AND CONFIDENCE INTERVALS
1380 LET Q = K1/K2
1390 LET Q7 = (1/A)+(1/B)+(1/C)+(1/D)
1400 LET Q1=Q+FNF(Q7,Q)
1410 LET Q2=Q-FNF(Q7,Q)
1420 PRINT TAB (25); "Q(X,Y) "
1430 PRINT "UPPER LIMIT (.95)";TAB(29);FNR(Q1)/100
1440 PRINT "SAMPLE VALUE";TAB(29);FNR(Q)/100
1450 PRINT "LOWER LIMIT (.95)";TAB(29);FNR(Q2)/100
1460 GO TO 370
1470 PRINT
1480PRINT
1490 PRINT "EXECUTION TERMINATED BY N = 0"
1500 END