Statistical Analysis

Date: 1983
Type: Program
Platform(s): TS 2068

Scientific statistical analysis.

Appears on

Library tape from the Sinclair Computer Users Society (SINCUS).

Gallery

Source Code

   10 REM STATISTICS PROGRAM
   21 BEEP .9,28: PAPER 0: BORDER 0: INK 6: CLS : PRINT INVERSE 1;AT 10,5;" STATISTICAL ANALYSIS "
   25 POKE 23658,8: LET CPY=0
   30 BEEP .8,30: PRINT INK 7'''"  WOULD YOU LIKE INSTRUCTIONS?"''TAB 12;"(Y/N)"
   40 PAUSE 0: IF INKEY$="Y" THEN CLS : GO TO 8000
   50 IF INKEY$="N" THEN GO TO 70
   60 GO TO 40
   70 REM DATA INPUT,  STORAGE,  PRINTING,  READ GRAPHICS.
   75 POKE 26564,35: PAPER 6: INK 1: BORDER 6: CLS 
   80 RESTORE : FOR f=0 TO 2: FOR g=0 TO 7: READ a: POKE USR CHR$ (144+f)+g,a: NEXT g: NEXT f
   90 BEEP .7,25: PRINT INK 1;"  STATISTICAL ANALYSIS OF DATA       BY GREG TURNBULL 1983."; OVER 1;AT 0,0;"________________________________"; OVER 1;AT 1,0;"________________________________"''
   95 PRINT AT 5,0;"DO YOU WISH TO LOAD IN OLD DATA THAT WAS SAVED?        (Y/N)": PAUSE 0: IF INKEY$="Y" THEN GO TO 175
  100 PRINT AT 5,0;"TYPE IN YOUR TOTAL NUMBER OF    DATA PAIRS  (N)               ": INPUT r: PRINT "N=";r'': LET A=r
  120 PRINT INK 1;"TYPE IN YOUR X AND Y VALUES     (ENTER EACH ONE):"''
  130 PRINT INK 3;"NOTE:IF YOU MAKE A MISTAKE      WRITE IT DOWN AND YOU WILL      BE ABLE TO ALTER IT LATER."
  150 DIM X(A,2): PRINT : FOR N=1 TO A: INPUT "x: ";x;"     y: ";y: LET X(N,1)=x: LET X(n,2)=y: GO SUB 160: NEXT N: GO TO 180
  160 PRINT INK 1;"N:";n;TAB 6;"x:";X(n,1),"y:";X(n,2): RETURN 
  175 CLS : PRINT AT 10,0;"PRESS ENTER AND PLAY DATA TAPE": PAUSE 0: LOAD "S.A. DATA" DATA X()
  180 ON ERR GO TO 190: FOR N=1 TO 999: LET A=X(N,1): NEXT N
  190 ON ERR RESET : PAUSE 90: CLS : PRINT "DATA"'': LET A=N-1: DIM B(A): DIM C(A): FOR N=1 TO A: LET B(N)=X(N,1): LET C(N)=X(N,2): GO SUB 160: NEXT N
  200 REM CHOICE OF ALTERING DATA
  210 BEEP .3,30: PRINT INK 2;"WOULD YOU LIKE TO ALTER         ANY DATA? (Y/N):": INPUT Q$: CLS 
  220 IF Q$="Y" THEN GO TO 250
  230 IF Q$="N" THEN GO TO 700
  240 GO TO 210
  250 PRINT "WOULD YOU LIKE TO CHANGE        x OR y VALUES?  (x/y):": INPUT V$: CLS 
  260 IF V$="Y" THEN GO TO 410
  270 IF V$="X" THEN GO TO 290
  280 GO TO 250
  290 BEEP .3,30: PRINT INK 1;"CHANGE AN x VALUE:"; OVER 1;AT 0,0;"                 "''
  300 PRINT "INPUT THE DATA ROW NUMBER       FOR THE CHANGE (N):": INPUT N: CLS 
  305 IF N>A THEN GO TO 300
  310 PRINT "INPUT THE x VALUE YOU WANT      FOR THIS ROW (x):": INPUT W: CLS 
  320 LET X(N,1)=W: LET B(N)=W
  330 PRINT "DO YOU WANT TO ALTER ANY MORE   x VALUES? (Y/N):": INPUT Q$: CLS 
  340 IF Q$="Y" THEN GO TO 290
  350 IF Q$="N" THEN GO TO 370
  360 GO TO 330
  370 PRINT "DO YOU WANT TO ALTER ANY        y VALUES?(Y/N):": INPUT Q$: CLS 
  380 IF Q$="Y" THEN GO TO 410
  390 IF Q$="N" THEN GO TO 530
  400 GO TO 370
  410 BEEP .3,30: PRINT INK 1;"CHANGE A y VALUE:"; OVER 1;AT 0,0;"________________"''
  420 PRINT "INPUT THE DATA ROW NUMBER       FOR THE CHANGE (N):": INPUT N: CLS 
  425 IF N>A THEN GO TO 420
  430 PRINT "INPUT THE y VALUE YOU WANT      FOR THIS ROW (y):": INPUT V: CLS 
  440 LET X(N,2)=V: LET C(N)=V
  450 PRINT "DO YOU WANT TO ALTER ANY MORE   y VALUES? (Y/N):": INPUT Q$: CLS 
  460 IF Q$="Y" THEN GO TO 410
  470 IF Q$="N" THEN GO TO 490
  480 GO TO 450
  490 PRINT "DO YOU WANT TO ALTER ANY        x VALUES? (Y/N):": INPUT Q$: CLS 
  500 IF Q$="Y" THEN GO TO 290
  510 IF Q$="N" THEN GO TO 530
  520 GO TO 490
  530 PRINT INK 3;"NEW DATA VALUES:"; OVER 1;AT 0,0;"_______________"''
  540 FOR N=1 TO A
  550 PRINT "N:";n;"  ";"x:";X(n,1),"y:";X(n,2)
  560 NEXT n
  570 PRINT : PRINT INK 2;"WOULD YOU LIKE TO ALTER         ANY FURTHER DATA? (Y/N):": INPUT Q$: CLS 
  580 IF Q$="Y" THEN GO TO 250
  590 IF Q$="N" THEN GO TO 700
  595 GO TO 570
  600 REM DATA FOR GRAPHICS.
  610 DATA 0,126,66,32,24,32,66,126
  620 DATA 255,0,195,102,60,60,102,195
  630 DATA 255,0,195,102,60,24,48,224
  650 REM COPY DATA TO PRINTER.
  655 IF CPY=1 THEN COPY : CLS : RETURN 
  660 INPUT "ENTER TO CONTINUE, Z TO COPY";W$
  670 IF W$="z" THEN COPY : CLS : RETURN 
  680 IF W$="" THEN CLS : RETURN 
  690 GO TO 650
  700 PRINT PAPER 1; INK 6; FLASH 1;"PLEASE WAIT."'': PRINT PAPER 6; INK 1; FLASH 0;"THE COMPUTER IS CALCULATING     THE STATISTICAL VALUES."''
  710 GO SUB 7000: CLS 
  720 REM MENU OF CHOICES.
  730 CLS : BEEP .3,30: PRINT INK 1;"WHICH TYPE OF ANALYSIS          WOULD YOU LIKE?"''  
  740 PRINT INK 2;"A) DESCRIPTIVE STATISTICS:"'': PRINT INK 1;"TYPE IN '1' FOR MEAN,SD,CV(%),              SEM & F-TEST:": PRINT "TYPE IN '2' TO PRINT THE DATA": PRINT "TYPE IN '3' FOR MIN,MAX & MEDIAN"''
  750 PRINT INK 2;"B) STATISTICAL ANALYSIS:"'': PRINT INK 1;"TYPE IN '4' FOR REGRESSION AND              CORRELATION": PRINT "TYPE IN '5' FOR 2-SAMPLE t-TEST"''
  760 PRINT INK 2;"C) GRAPHS:"'': INK 1: PRINT "TYPE IN '6' FOR A LINE GRAPH"'"TYPE IN '7' FOR A BAR CHART"'': PRINT INK 3;"TYPE IN '0' TO SAVE DATA/RESTART"
  770 INPUT W$: IF W$="" THEN GO TO 720
  780 LET W=VAL W$: CLS 
  790 IF W=0 THEN GO TO 6000
  800 IF W>0 AND W<4 THEN GO TO 800+W*100
  810 IF W>4 AND W<7 THEN GO TO 1000+W*100
  820 IF W=4 THEN GO TO 1300
  830 IF W=7 THEN GO TO 2000
  840 IF W>7 THEN GO TO 720
  900 REM START OF DESCRIPTIVE STATISTICS
  910 REM MEANS  SD. CV(%)  SEM   F-TEST.
  915 BEEP .3,30: PRINT INK 3;"DESCRIPTIVE STATISTICS:"; OVER 1;AT 0,0;"______________________"''
  920 LET s3=INT (s3*10^5+.5)/(10^5): LET s4=INT (s4*10^5+.5)/(10^5)
  930 LET v1=INT (v1*10^3+.5)/(10^3): LET v2=INT (v2*10^3+.5)/(10^3)
  940 LET s5=INT (s5*10^5+.5)/(10^5): LET s6=INT (s6*10^5+.5)/(10^5)
  950 LET h1=s3^2: LET h2=s4^2
  955 IF h1>h2 OR h1=h2 THEN LET h3=h1/h2
  960 IF h2>h1 THEN LET h3=h2/h1
  965 LET h3=INT (h3*10^4+.5)/(10^4): LET h4=A-1
  970 PRINT "N=";A;"    \b=";P;"    \c=";q: PRINT '"S.D. of x=";s3: PRINT "CV(%) of x=";v1: PRINT "S.E.M for x=";s5
  975 PRINT '"S.D. of y=";s4: PRINT "CV(%) of y=";v2: PRINT "S.E.M for y=";s6''
  980 PRINT INK 3;AT 12,0;"F-TEST:"; OVER 1;AT 12,0;"______"'': PRINT INK 1;"A TEST TO COMPARE THE           PRECISION OF x WITH THAT OF y.": PRINT "THE F VALUE=";h3: PRINT "FOR DF1 & DF2 OF:";h4: PRINT "THIS VALUE CAN BE LOOKED UP IN  F-TABLES TO FIND A PROBABILITY  (P) VALUE FOR SIGNIFICANCE      TESTING." 
  990 GO SUB 650: GO TO 720
 1000 REM PRINT DATA
 1010 BEEP .3,30: PRINT INK 2;"DATA:"; OVER 1;AT 0,0;"    "''
 1020 IF A<21 THEN GO TO 1060
 1030 LPRINT "DATA."; OVER 1;AT 0,0;"    "'': FOR n=1 TO A
 1040 LPRINT "N:";n;TAB 6;"x:";X(n,1),"y:";X(n,2)
 1050 NEXT n: GO TO 1090
 1060 FOR n=1 TO A
 1070 PRINT "N:";n;TAB 6;"x:";X(n,1),"y:";X(n,2)
 1080 NEXT n
 1090 GO SUB 650: GO TO 720
 1100 REM DATA SORTING INTO DESCENDING ORDER . PRINT RANKED DATA.
 1110 PRINT PAPER 1; INK 7; FLASH 1;"PLEASE WAIT."'': PRINT PAPER 6; INK 1; FLASH 0;"THE COMPUTER IS RANKING THE DATA"
 1112 LET mm=A
 1113 LET mm=INT (mm/2)
 1114 IF mm=0 THEN GO TO 1130
 1115 LET kk=A-mm
 1116 LET jj=1
 1117 LET ii=jj
 1118 LET ll=ii+mm
 1119 IF B(ii)>=B(ll) THEN GO TO 1124
 1120 LET tt=B(ll): LET B(ll)=B(ii): LET B(ii)=tt
 1121 LET ii=ii-mm
 1122 IF ii<1 THEN GO TO 1124
 1123 IF NOT ii<1 THEN GO TO 1118
 1124 LET jj=jj+1
 1125 IF jj>kk THEN GO TO 1113
 1126 GO TO 1117
 1130 REM SORT Y VALUES
 1131 LET mm=A
 1132 LET mm=INT (mm/2)
 1133 IF mm=0 THEN GO TO 1160
 1134 LET kk=A-mm
 1135 LET jj=1
 1136 LET ii=jj
 1137 LET ll=ii+mm
 1138 IF C(ii)>=C(ll) THEN GO TO 1143
 1139 LET tt=C(ll): LET C(ll)=C(ii): LET C(ii)=tt
 1140 LET ii=ii-mm
 1141 IF ii<1 THEN GO TO 1143
 1142 IF NOT ii<1 THEN GO TO 1137
 1143 LET jj=jj+1
 1144 IF jj>kk THEN GO TO 1132
 1145 GO TO 1136
 1150 REM PRINT SORTED DATA
 1160 CLS : BEEP .3,30: PRINT INK 3;"RANKED DATA:"; OVER 1;AT 0,0;"___________"''
 1165 FOR l=1 TO A
 1170 PRINT "n:";l;TAB 6;"x:";B(l),"y:";C(l)
 1180 NEXT l
 1190 GO SUB 650
 1200 REM MIN,MAX AND MEDIANS.
 1205 PRINT INK 3;"MIN, MAX, MEDIANS:"; OVER 1;AT 0,0;"_________________"''
 1210 LET s=A/2: IF s=INT s THEN GO TO 1230
 1220 LET M1=B(s): LET M2=C(s): GO TO 1240
 1230 LET w=A/2: LET v=A/2+1: LET M1=(B(w)+B(v))/2: LET M2=(C(w)+C(v))/2
 1240 PRINT "MEDIAN OF x=";M1: PRINT "MINIMUM VALUE OF x IS ";B(A): PRINT "MAXIMUM VALUE OF x IS ";B(1)''
 1250 PRINT "MEDIAN OF y=";M2'"MINIMUM VALUE OF y=";C(A)'"MAXIMUM VALUE OF y IS ";C(1)''
 1260 LET M1=INT (M1*10+.5)/10: IF M1=INT (p*10+.5)/10 OR M1-.1=INT (p*10+.5)/10 OR M1-.1=INT (p*10+.5)/10 THEN PRINT "median of x approx' equal to    mean of x indicating normally   distributed x data."''
 1270 LET M2=INT (M2*10+.5)/10: IF M2=INT (q*10+.5)/10 OR M2+.1=INT (q*10+.5)/10 OR M2-.1=INT (q*10+.5)/10 THEN PRINT "median of y approx' equal to    mean of y indicating normally   distributed y data."''
 1280 GO SUB 650: GO TO 720
 1300 REM START OF STATISTICAL   ANALYSIS.
 1310 REM REGRESSION AND         CORRELATION.
 1320 BEEP .3,30: PRINT INK 3;"REGRESSION AND CORRELATION:"''
 1330 LET E=INT (E*10^5+.5)/(10^5): LET D=INT (D*10^5)/(10^5): LET U=INT (U*10^5)/(10^5)
 1340 PRINT "\ax=";t1,"\ax*x=";t3,"\ay=";t2,"\ay*y=";t4,"\ax*y=";t5
 1350 PRINT "n=";A;"    \b=";p;"    \c=";q'': PRINT INK 0;"FOR  y=b*x+c"'': PRINT "b=";D,"","c=";E: PRINT '' INK 3;"COR. COEFF'"; INK 1''"r=";U''
 1360 IF D>.75 AND U>.75 THEN PRINT "b and r are >.75 indicating a   strong positive linear          correlation between x and y."''
 1370 IF D<-.75 AND U<-.75 THEN PRINT "b and r are <-.75 indicating a  strong negative linear          correlation between x and y."''
 1375 IF D<.75 AND U>.75 THEN PRINT "correlation coefficient (r)<.75 indicating a strong positive    relationship between x and y."
 1380 IF U=0 THEN PRINT "r=0 this indicates that x and y are totally uncorrelated."
 1390 GO SUB 650: GO TO 720
 1500 REM t-TEST AND DF.
 1510 BEEP .3,30: PRINT INK 3;"2-SAMPLE t-TEST:"''
 1515 LET T=INT (T*10^5+.5)/(10^5)
 1520 PRINT INK 0;"for DF=";U2''
 1530 PRINT INK 0;"THE VALUE OF t=";T''
 1540 PRINT INK 1;"LOOK UP YOUR t VALUE IN t-TABLESFOR THE ABOVE DF, AND FIND THE  PROBABILITY VALUE (P)           FOR SIGNIFICANCE TESTING."''
 1550 GO SUB 650: GO TO 720
 1600 REM START OF GRAPHICAL     SECTION.
 1605 REM DRAW LINE GRAPH.
 1610 BEEP .3,32: PRINT INK 3;"A LINE GRAPH OF x,y:"; OVER 1;AT 0,0;"                   "''
 1620 PRINT INK 1;"HAVE YOU BEEN VIA THE MEDIANS   ROUTINE?   (Y/N)"''"THIS IS BECAUSE THE MAXIMUM AND MINIMUM VALUES ARE NEEDED FOR   THE BARCHART."'': PAUSE 0
 1625 IF INKEY$="N" THEN GO TO 720
 1630 IF NOT INKEY$="Y" THEN CLS : GO TO 1600
 1635 FOR N=1 TO 20: NEXT N
 1640 PRINT ''"TYPE IN THE NAME OF THE x-AXIS": INPUT A$
 1650 PRINT '"TYPE IN THE NAME OF THE y-AXIS": INPUT B$: CLS 
 1660 LET F=B(1): LET G=C(1)
 1670 IF F>26 THEN LET F=26
 1680 IF G>18 THEN LET G=18
 1690 FOR O=17 TO (8*F+40): PLOT O,9: NEXT O
 1700 FOR M=9 TO (8*G+22): PLOT 17,M: NEXT M
 1710 PRINT AT 21,3;A$: PRINT AT 18-G,2;B$: PRINT AT 19-G,0;G: PRINT AT 21,2.5+F;F: PRINT AT 21,1;"0"
 1720 FOR n=1 TO A
 1730 IF X(n,1)>=26 OR X(n,2)>=18 THEN PRINT AT 19,3;"DATA IS TOO LARGE": GO SUB 650: GO TO 720
 1735 BEEP .02,12: INK 2: OVER 0: CIRCLE 8*X(n,1)+17,8*X(n,2)+9,2
 1740 NEXT n
 1750 IF p>10 OR q>10 THEN PRINT AT 19,3;"MEAN VALUES ARE TOO LARGE": GO SUB 650: GO TO 720
 1760 FOR Z=1 TO 20: BEEP .05,50-z: NEXT z: INK 1: PLOT 17,8*E: DRAW p+16*p,q+16*p: PAUSE 200
 1770 GO SUB 650: GO TO 720
 2000 REM BAR CHART.
 2010 BEEP .3,30: PRINT INK 3;"BAR CHART."; OVER 1;AT 0,0;"_________"''
 2020 PRINT INK 1;"HAVE YOU BEEN VIA THE MEDIANS   ROUTINE?   (Y/N)"''"THIS IS BECAUSE THE MAXIMUM AND MINIMUM VALUES ARE NEEDED FOR   THE BARCHART."'': PAUSE 0
 2040 IF INKEY$<>"Y" THEN GO TO 720
 2060 PRINT INK 1;"WOULD YOU LIKE A BAR CHART OF   THE x OR y DATA?                TYPE IN x OR y                  OR PRESS ENTER TO RETURN:"'': INPUT z$: CLS 
 2070 IF z$="X" THEN GO TO 2095
 2080 IF z$="Y" THEN GO TO 2500
 2085 IF z$="" THEN GO TO 720
 2090 GO TO 2060
 2095 PRINT FLASH 1;"PLEASE WAIT ."'' FLASH 0;"THIS MAY TAKE SOME TIME!"
 2096 REM CALCULATE X VALUES.
 2100 LET minx=B(A): LET maxx=B(1): DIM R(15): DIM L(16): LET divx=(maxx-minx)/15
 2110 FOR B=1 TO 15: FOR n=1 TO A
 2120 LET P9=0: LET R9=minx+divx
 2125 IF B=15 THEN LET R9=R9+.000001
 2130 IF X(n,1)>=minx AND X(n,1)<R9 THEN LET P9=P9+1: LET R(B)=R(B)+P9: LET L(B)=L(B)+P9
 2140 NEXT n
 2150 LET minx=minx+divx
 2160 NEXT B
 2165 PRINT "NEARLY FINISHED."
 2170 FOR J=1 TO 15: FOR K=1 TO 15
 2180 LET l=0: IF L(K+1)>L(K) THEN LET l=L(K): LET L(K)=L(K+1): LET L(K+1)=l
 2190 NEXT K: NEXT J
 2200 LET highx=L(1): LET scalex=1
 2210 IF highx>18 THEN LET scalex=scalex+1: LET highx=highx-18: GO TO 2210
 2250 GO TO 3000
 2500 PRINT FLASH 1;"PLEASE WAIT."'' FLASH 0;"THIS MAY TAKE SOME TIME!"
 2505 REM CALCULAT y VALUES.
 2510 LET miny=C(A): LET maxy=C(1): DIM S(15): DIM M(16): LET divy=(maxy-miny)/15
 2520 FOR B=1 TO 15: FOR n=1 TO A
 2530 LET P9=0: LET R9=miny+divy
 2535 IF B=15 THEN LET R9=R9+.000001
 2540 IF X(n,2)>=miny AND X(n,2)<R9 THEN LET P9=P9+1: LET S(B)=S(B)+P9: LET M(B)=M(B)+P9
 2550 NEXT n
 2560 LET miny=miny+divy
 2570 NEXT B
 2575 PRINT "NEARLY FINISHED."
 2580 FOR J=1 TO 15: FOR K=1 TO 15
 2590 LET l=0: IF M(K+1)>M(K) THEN LET l=M(K): LET M(K)=M(K+1): LET M(K+1)=l
 2600 NEXT K: NEXT J
 2610 LET highy=M(1): LET scaley=1
 2620 IF highy>18 THEN LET scaley=scaley+1: LET highy=highy-18: GO TO 2620
 2630 GO TO 3500
 3000 REM DRAW BAR CHART OF x .
 3010 IF scalex=1 THEN GO TO 3030
 3020 FOR B=1 TO 15: LET R(B)=INT (R(B)/scalex+.5): NEXT B
 3030 BEEP .5,20: CLS : DIM J$(18): PRINT "INPUT THE NAME OF THE HORIZONTAL(x) AXIS:": INPUT I$
 3040 PRINT "INPUT THE NAME OF THE VERTICAL  (y) AXIS:": INPUT J$: CLS 
 3050 BEEP .3,30: PLOT 16,16: DRAW 0,143: PLOT 16,16: DRAW 239,0: PRINT AT 0,4;"BAR CHART OF x.": PRINT AT 19,1;"0": PRINT AT 20,2;B(A): PRINT AT 20,28;B(1): PRINT AT 21,6;I$: FOR z=0 TO 17: PRINT AT z+4,0;J$(z+1): NEXT z: PRINT AT 2,0;18*scalex
 3055 LET sp=2
 3060 FOR B=1 TO 15
 3065 IF R(B)=0 THEN LET sp=sp+2: GO TO 3110
 3070 FOR J=1 TO R(B)
 3080 PRINT INK 2;AT 20-J,sp;" ": PRINT INK 2;AT 20-J,sp+1;" "
 3090 NEXT J
 3100 LET sp=sp+2
 3110 NEXT B
 3150 GO SUB 650: CLS : GO TO 2060
 3500 REM DRAW BAR CHART OF y.
 3510 IF scaley=1 THEN GO TO 3530
 3520 FOR B=1 TO 15: LET S(B)=INT (S(B)/scaley+.5): NEXT B
 3530 BEEP .25,20: CLS : DIM K$(18): PRINT "INPUT THE NAME OF THE HORIZONTAL(x) AXIS:": INPUT I$
 3540 PRINT "INPUT THE NAME OF THE VERTICAL  (y) AXIS:": INPUT K$: CLS 
 3550 BEEP .2,30: PLOT 16,16: DRAW 0,143: PLOT 16,16: DRAW 239,0: PRINT AT 0,4;"A BAR CHART OF y.": PRINT AT 19,1;"0": PRINT AT 20,2;C(A): PRINT AT 20,28;C(1): PRINT AT 21,6;I$: FOR z=0 TO 17: PRINT AT z+4,0;K$(z+1): NEXT z: PRINT AT 2,0;18*scaley
 3560 LET sp=2
 3570 FOR B=1 TO 15
 3580 IF S(B)=0 THEN LET sp=sp+2: GO TO 3630
 3590 FOR J=1 TO S(B)
 3600 PRINT INK 2;AT 20-J,sp;" ": PRINT INK 2;AT 20-J,sp+1;" "
 3610 NEXT J
 3620 LET sp=sp+2
 3630 NEXT B
 3650 GO SUB 650: CLS : GO TO 2060
 6000 REM EXIT.
 6010 PRINT "DO YOU WISH TO:"''" SAVE THE DATA         (Y/N)": INPUT Y$: CLS 
 6020 IF Y$="N" THEN GO TO 6050
 6030 IF Y$<>"Y" THEN GO TO 6000
 6040 SAVE "S.A. DATA" DATA X()
 6050 PRINT ''"WOULD YOU LIKE TO:"'''"CONTINUE?                  C"''"CLEAR DATA AND RUN AGAIN?  R"''"OR STOP?                   S": INPUT Y$: CLS 
 6060 IF Y$="R" THEN GO TO 20
 6070 IF Y$="C" THEN GO TO 720
 6075 IF Y$="S" THEN STOP 
 6080 GO TO 6050
 7000 REM CALCULATION OF SUM OF  TOTALS  MEANS  SD  CV  SEM  REG CORR DF * t.
 7010 LET t1=0: LET t2=0: LET t3=0: LET t4=0: LET t5=0: LET S1=0: LET S2=0
 7020 FOR h=1 TO A
 7030 LET t1=t1+X(h,1): LET t2=t2+X(h,2): LET t3=t3+X(h,1)^2: LET t4=t4+X(h,2)^2: LET t5=t5+X(h,1)*X(h,2)
 7040 NEXT h
 7050 LET q=t2/A: LET q=INT (q*10^3+.5)/(10^3): REM MEAN(y)
 7060 LET p=t1/A: LET p=INT (p*10^3+.5)/(10^3): REM MEAN(x)
 7070 LET d=(t5-(t1*t2/(h-1)))/(t3-(t1^2/(h-1))): REM REG(b)
 7080 LET U=(t5-(t1*t2/(h-1)))/SQR ((t3-(t1^2/(h-1)))*(t4-(t2^2/(h-1)))): REM COR(r)
 7090 LET E=q-D*p: REM REG(c)
 7100 FOR i=1 TO A
 7110 LET s1=s1+(X(i,1)-p)*(X(i,1)-p): LET s2=s2+(X(i,2)-q)*(X(i,2)-q)
 7120 NEXT i
 7130 LET s3=SQR (s1/(i-2)): LET s4=SQR (s2/(i-2)): REM SD(x&y)
 7140 LET v1=s3/p*100: LET v2=s4/q*100: REM CV(x&y)
 7150 LET s5=s3/SQR (i-1): LET s6=s4/SQR (i-1): REM SEM(x&y)
 7160 LET u2=2*A-2: REM DF
 7170 IF q>p THEN LET T=(q-p)/SQR ((2/(u2*A))*(t3+t4-(t1^2/A)-(t2^2/A))): GO TO 7190
 7180 LET T=(p-q)/SQR ((2/(u2*A))*(t3+t4-(t1^2/A)-(t2^2/A))): REM t-TEST
 7190 RETURN 
 8000 REM INSTRUCTIONS.
 8010 BEEP .8,30: PRINT INK 5;"INSTRUCTIONS ON STATISTICS:"; OVER 1;AT 0,0;"__________________________"''
 8020 PRINT INK 6;"THIS PROGRAM ALLOWS YOU TO INPUTTWO SETS OF DATA OF ANY LENGTH  FOR A 72K 2068 TIMEX.           NOTE: BOTH SETS OF DATA MUST BE OF EQUAL LENGTH.                THE TOTAL NUMBER OF DATA PAIRS  BEING ENTERED AS n"''
 8030 GO SUB 650
 8060 PRINT INK 5;"THE RAW DATA:"; OVER 1;AT 0,0;"____________": PRINT ' INK 6;"THIS WILL BE STORED IN TWO      SEPARATE ARRAYS, ONE FOR        PRINTING AND ANALYSIS, THE OTHERFOR RANKING (USED IN MEDIANS).  YOU WILL THEN BE ABLE TO ALTER  ANY OF THE DATA THAT MAY HAVE   BEEN ENTERED INCORRECTLY. THE   STATISTICAL TESTS ARE THEN      PERFORMED AND A MENU OF CHOICES PRINTED."''
 8070 GO SUB 650
 8100 PRINT INK 5;"DESCRIPTIVE STATISTICS:"'': PRINT INK 6;"THIS GIVES YOU THE MEANS        (AVERAGES) OF THE TWO SETS OF   DATA. IT ALSO GIVES YOU SOME    MEASURES OF THE DISTRIBUTION OF VALUES ABOUT THE MEANS.": PRINT INK 5'"THESE ARE:"''"A) STANDARD DEVIATION:"; OVER 1;AT 10,3;"__________________": PRINT ' INK 6;"THIS VALUE IS BOTH POSITIVE (+) AND NEGATIVE (-). AT THE 95%    CONFIDENCE LIMIT LEVEL 95.4% OF ALL VALUES SHOULD LIE WITHIN +2 OR -2 SD FROM THE MEAN. SO ANY  VALUE OUTSIDE THESE LIMITS MUST BE CONSIDERED STATISTICALLY     DIFFERENT FROM THE MEAN OF      NORMALLY DISTRIBUTED DATA."
 8120 PRINT : GO SUB 650
 8150 PRINT INK 5;"B) COEFFICIENT OF VARIATION (CV)"; OVER 1;AT 0,0;"   _____________________________"'': PRINT INK 6;"THIS IS A PERCENTAGE (%) VALUE  OFTERN USED TO EXPRESS THE      PRECISION OF THE DATA.          IT RELATES BOTH THE SD AND MEAN BY: CV=SD/MEAN*100%.   A LOW CV INDICATES GOOD  PRECISION, AND AHIGH VALUE INDICATES POOR       PRECISION."''
 8160 GO SUB 650
 8190 PRINT INK 5;"C) STANDARD ERROR OF THE MEAN      (SEM):"; OVER 1;AT 0,0;"   __________________________"'''': PRINT INK 6;"THIS IS AN ESTIMATE OF HOW CLOSETHE MEAN OF YOR SAMPLE IS TO    THE MEAN OF THE POPULATION FROM WHICH IT WAS TAKEN. HENCE THIS  VALUE MAY NOT BE RELEVANT FOR   ALL SETS OF DATA.               THE CALCULATION IS SEM=SD/SQR(n)SO AS SAMPLE SIZE INCREASES,    THE SEM SHOULD DECREASE AS IT   APPROACHES THE 'TRUE' MEAN OF   THE POPULATION. (WHERE SEM=0)"''
 8200 GO SUB 650
 8230 PRINT INK 5;"F-TEST:"; OVER 1;AT 0,0;"______": PRINT ' INK 6;"THIS IS A TEST SOMETIMES USED TOCOMPARE THE PRECISIONS OF TWO   SETS OF DATA. THE F VALUE IS    CALCULATED FROM THE VARIANCE    RATIO (VARIANCE=SD SQUARED) BY: F=(LARGER VARIANCE)/(SMALLER    VARIANCE). THIS VALUE IS THEN   LOOKED UP IN F-TABLES FOR TWO DF(DEGREES OF FREEDOM) VALUES     (IN THIS CASE BOTH VALUES ARE   EQUAL AND ONLY ONE IS PRINTED). FROM THE TABLES A PROBABILITY   VALUE (P) IS FOUND AND THIS CAN BE USED IN ASSESSING THE        SIGNIFICANCE (IF ANY) BETWEEN   THE TWO PRECISIONS. SEE ALSO THENOTES ON THE t-TEST."
 8250 PRINT : GO SUB 650
 8280 PRINT INK 5;"PRINT DATA:"; OVER 1;AT 0,0;"__________": PRINT ' INK 6;"THE SECOND CHOICE ON THE MENU   ALLOWS YOU TO LIST THE DATA.    THIS CAN BE COPIED BY PRESSING  'c' INSTEAD OF ENTER,SO ANY     TIME A HARD COPY OF THE         INSTRUCTIONS OR THE ANALYSIS IS REQUIRED JUST PRESS 'c'."''
 8300 GO SUB 650
 8320 PRINT INK 5;"MEDIANS & DATA SORTING:"; OVER 1;AT 0,0;"_______   ____________": PRINT ' INK 6;"THE THIRD CHOICE (AND FINAL PARTOF DESCRIPTIVE STATISTICS) WILL USE A SORTING ROUTINE TO RANK   THE SPARE ARRAY DATA INTO       DESCENDING ORDER (THIS MAY TAKE SOME TIME AS IT IS IN BASIC AND NOT MACHINE CODE!). ONCE THE    DATA HAS BEEN RANKED IT WILL BE LISTED AND THE MAXIMUM, MINIMUM AND MEDIAN VALUES FOR x & y WILLBE DISPLAYED. THE MEDIAN IS A   VALUE WHICH DIVIDES THE NUMBER  OF OBSERVATIONS INTO TWO EQUAL  PARTS. IN NORMALLY DISTRIBUTED  DATA IT WOULD BE EQUAL, OR VERY CLOSE TO THE MEAN VALUE. THUS   DIFFERENCES BETWEEN THE MEAN ANDMEDIAN SHOWS LEFT OR RIGHT SKEW IN THE DATA."
 8340 PRINT : GO SUB 650
 8370 PRINT INK 5;"THE MODE:"; OVER 1;AT 0,0;"________"'': PRINT ' INK 6;"THIS IS THE MOST COMONNLY       OCCURING VALUE IN ANY SET OF    DATA. IN THIS PROGRAM IT CAN    EASILY BE SEEN IN THE LIST OF   RANKED DATA.IN NORMALLY         DISTRIBUTED DATA THE MODE,MEAN  AND MEDIAN WOULD ALL BE         (APPROXIMATELY) EQUAL. ANY LEFT OR RIGHT SKEW IN THE DATA WOULD MAKE THEM SIGNIFICANTLY         DIFFERENT FROM EACH OTHER."''
 8380 GO SUB 650
 8410 PRINT INK 5;"STATISTICAL ANALYSIS:"; OVER 1;AT 0,0;"____________________": PRINT ' INK 6;"THESE CHOICES GIVE VARIOUS      CALCULATIONS ON THE DATA WHICH  WOULD BE VERY TIME CONSUMING TO DO MANUALLY. THEY ARE REGRESION,CORRELATION AND t-TEST."''
 8420 GO SUB 650
 8450 PRINT INK 5;"REGRESSION ANALYSIS:"; OVER 1;AT 0,0;"___________________"'': PRINT INK 6;"THIS IS AN ESTIMATE OF THE      ASSOCIATION OF THE x DATA WITH  THE y DATA. LINEAR REGRESSION ISUSED, WHERE IF THE ASSOCIATION  IS A  STRAIGHT LINE THEN IT WILLHAVE THE FORMULAE y=b*x+c WHERE c=INTERCEPT ON THE y-AXIS AND   b=REGRESSION COEFFICIENT        (GRADIENT).IF THE ASSOCIATION   IS TOTALLY LINEAR THEN b WILL BE+1 OR -1 DEPENDING ON THE SLOPE OF THE LINE. STATISTICALLY      REGRESSION IS USED TO DRAW A    BEST-FIT LINE THROUGH SPREAD OUTDATA."''
 8460 GO SUB 650
 8490 PRINT INK 6;"HERE b IS CLCULATED AND USED TO FIND THE VALUE OF c (BY c=C-b*B)THE LINE IS THEN DRAWN FROM c   THROUGH (B,C) TO THE UPPER      LIMITS OF THE DATA. THIS LINE   DRAWING METHOD IS THE ONE USED  ON THE PLOT A GRAPH CHOICE.     NOTE:THE LINE ONLY WORKS FOR    POSITIVELY CORRELATED DATA,     IF THE DATA IS NEGATIVELY       CORRELATED THE LINE WILL RUN OFFTHE SCREEN. THIS CAN BE AVOIDED IF PROGRAM LINES 1750 & 1760 AREDELETED. SEE ALSO GRAPH         INSTRUCTIONS."''
 8500 GO SUB 650
 8530 PRINT INK 5;"CORRELATION COEFFICIENT:"; OVER 1;AT 0,0;"                       "'': PRINT INK 6;"THIS IS ANOTHER EXPRESSION OF   THE ASSOCIATION BETWEEN THE TWO SETS OF DATA. COMPLETE          CORRELATION WILL GIVE AN r VALUEOF +1 OR -1 DEPENDING ON THE    SLOPE OF THE LINE. IF THE DATA  IS TOTALLY UNCORRELATED THEN r  WILL BE 0. CORRELATION AND      REGRESSION ANALYSIS ARE USUALLY USED IN CONJUNCTION AND ARE     OFTERN DISPLAYED ON THE GRAPHS  OF DATA."''
 8540 GO SUB 650
 8570 PRINT INK 5;"2-SAMPLE t-TEST:"'': PRINT INK 6;"THERE ARE MANY TYPES OF t-TEST  ANALYSIS. THE ONE USED HERE IS  FOR TWO SAMPLES OF EQUAL LENGTH.THE TEST IS USED TO DETERMINE   WHETHER THERE IS ANY SIGNIFICANTDIFFERENCE BETWEEN THE TWO SETS OF DATA. THE t VALUE IS         CALCULATED ALONG WITH THE       DEGREES OF FREEDOM (DF) FOR THE DATA. FROM THESE, STUDENT'S     t-TABLES CAN BE USED TO FIND THEPROBABILITY VALUE (P) FOR       SIGNIFICANCE TESTING."''
 8580 GO SUB 650
 8610 PRINT INK 5;"SIGNIFICANCE TESTING:"'': PRINT INK 6;"THIS USES THE P VALUE (WHICH MAYBE EXPRESSED AS A %) TO SEE IF  THERE IS ANY STATISTICAL        DIFFERENCE BETWEEN THE TWO SETS OF DATA FOR EXAMPLE P<=0.001    (OR 0.1%) MEANS THAT THE DATA   ARE STATISTICALLY THE SAME.     NOTE: IF THE t VALUE EXCEEDS THETABULATED VALUES THEN THE       DIFFERENCE IS SIGNIFICANT       (ie: NOT LIKELY TO BE DUE TO    CHANCE ALONE.)"''
 8620 GO SUB 650
 8650 PRINT INK 5;"THE LINE GRAPH:"'' INK 6;"THIS IS LIMITED BY THE SCREEN   SIZE FOR THE 2068. IT WILL      ONLY ALLOW (x,y)<(26,20) TO BE  PRINTED, OR MEANS<11. IT ALSO   ASSUMES POSITIVE LINEAR         CORRELATION BETWEEN x & y WHEN  IT DRAWS A LINE THROUGH THE     POINTS. HOWEVER AS MENTIONED    THIS COULD BE AVOIDED IF        NECESSARY BY THE DELETION OF THERELEVANT LINES. IF A GRAPH OF   HIGH DATA IS NEEDED, YOU WOULD  HAVE TO RE-ENTER THE VALUES     AFTER DIVISION BY A SUITABLE    FACTOR TO DECREASE THEIR SIZE."''
 8660 GO SUB 650
 8690 PRINT INK 6;"THE GRAPH ROUTINE WILL ALLOW YOUTO NAME THE TWO AXES, AND       SPECIFY THEIR MAXIMUM LENGTHS.  THUS  THE ROUTINE IS VERY USEFULFOR  VISUALISING THE ACTUAL     RELATIONSHIPS BETWEEN TWO SETS  OF DATA.  IT CAN BE COPIED TO   THE PRINTER BY PRESSING 'c'."''
 8700 GO SUB 650
 8710 PRINT INK 5;"BAR CHART."'' INK 6;"THIS ROUTINE ALLOWS YOU  TO     CHOOSE A BAR CHART OF x OR y    VALUES. AGAIN IT IS LIMITED BY  THE SCREEN SIZE OF THE 2068     THE VALUES ARE SORTED INTO 15   DOUBLE-WIDTH COLUMNS BY A       DIVISION FACTOR CALCULATED FROM THE MAXIMUM AND MINIMUM DATA    VALUES. THUS YOU MUST GO THROUGHCHOICE NUMBER 3 (MEDIANS) BEFOREUSING THE BAR CHART. THE DATA ISSORTED INTO AN ARRAY ACCORDING  TO ITS PARTICULAR VALUE. IF THE COLUMN BECOMES TOO LARGE (>17)  THEN THE COMPUTER WILL SCALE    DOWN ALL THE VALUES AS REQUIRED.THE USE OF THIS IS THAT IT WILL SHOW YOU IF THE DATA IS NORMALLYDISTRIBUTED THIS IS REQUIRED BY MANY STATS TESTS."
 8720 GO SUB 650
 8750 LET CPY=0
 8800 PRINT "PRESS"''"R TO READ THE INSTRUCTIONS AGAIN"''"C TO COPY INSTRUCTIONS"''"P TO RETURN TO THE MAIN PROGRAM:"
 8810 PAUSE 0: IF INKEY$="R" THEN CLS : GO TO 8000
 8820 IF INKEY$="P" THEN CLS : GO TO 70
 8830 IF INKEY$="C" THEN LET CPY=1: GO TO 8000
 8840 GO TO 8810
 9000 REM THIS LISTING OCCUPIES  26.2K
 9998 SAVE "Stat.Anal." LINE 10
 9999 VERIFY ""

People

No people associated with this content.

Scroll to Top