home *** CD-ROM | disk | FTP | other *** search
/ Play and Learn 2 / 19941.ZIP / 19941 / EDUCMATH / STATS / RANDOMIZ.BAS (.txt) < prev    next >
Encoding:
GW-BASIC  |  1994-02-04  |  3.4 KB  |  59 lines

  1. 1  '                   SELECTING A RANDOM SAMPLE
  2. 2  '               Copyright Tracy L. Gustafson, M.D.
  3. 3  '              Round Rock, Texas. Version 3.2, 1985
  4. 4  ON ERROR GOTO 5000:CHAIN MERGE "EPIMRG",5
  5. 15  DIM CX(10),CC(10),EX(10)
  6. 22  DATA "SELECTING A RANDOM SAMPLE",26,27
  7. 30  LOCATE 7,5:PRINT "Do you want to:":PRINT
  8. 35  PRINT TAB(14);"1.)  Select a SURVEY SAMPLE from a population.":PRINT
  9. 40  PRINT TAB(14);"2.)  Assign UNPAIRED subjects to 2 groups prospectively."
  10. 45  PRINT:PRINT TAB(14);"3.)  Assign PAIRED subjects to 2 groups prospectively."
  11. 50  LOCATE 16,30:PRINT "Enter choice:":AR=16:AC=44:GOSUB 4800:ASUB=VAL(IP$):IF ABS(ASUB-2)>1 THEN BEEP:GOTO 50
  12. 55  LOCATE 20,10:INPUT "Do you want numbers printed on screen or printer? (S or P)  ",A$
  13. 60  IF A$="p" OR A$="P" THEN PO$="LPT1:":PMAX=PRNT-10 ELSE IF A$="S" OR A$="s" THEN PO$="SCRN:":PMAX=70 ELSE BEEP:GOTO 55
  14. 65  ON ERROR GOTO 5070:OPEN PO$ FOR OUTPUT AS #1:IF PO$="LPT1:" THEN WIDTH #1,255:PRINT #1,TYP$;
  15. 70  CLS:ON ASUB GOTO 75,135,220
  16. 75  PRINT TAB(30);"SELECT A SURVEY SAMPLE":PRINT TAB(30);STRING$(22,205)
  17. 80  LOCATE 4,20:PRINT "What is the smallest number you want?":AR=4:AC=60:GOSUB 4800:E1=VAL(IP$)
  18. 85  PRINT TAB(21);"What is the largest number you want?":AR=5:GOSUB 4800:E2=VAL(IP$)
  19. 90  LOCATE 7,10:PRINT "How many random numbers between";E1;"and";E2;"do you want?":AR=7:AC=68:GOSUB 4800:NM=VAL(IP$)
  20. 95  ERASE EX:DIM EX(NM+1)
  21. 100  PRINT:PRINT:PRINT #1,TAB(PMAX/2-14);NM;"RANDOM NUMBERS BETWEEN";E1;"AND";E2
  22. 105  PRINT #1,:GOSUB 210:NT=0:EZ=E1-1
  23. 110  IF (E2-EZ)*RND<NM-NT THEN NT=NT+1:EZ=EZ+1:EX(NT)=EZ:IF NT<NM THEN 110 ELSE 120
  24. 115  EZ=EZ+1:GOTO 110
  25. 120  TB=6:IF E2>10000 THEN TB=10
  26. 125  GOSUB 215:T=1:FOR Z=1 TO NM:PRINT #1,TAB(T);EX(Z);:T=T+TB:IF T>PMAX THEN T=1
  27. 130  NEXT:PRINT #1,:GOTO 265
  28. 135  PRINT TAB(26);"ASSIGN SUBJECTS TO TWO GROUPS":PRINT TAB(26);STRING$(29,205)
  29. 140  LOCATE 4,2:INPUT "Will subjects enter the study over a period of time longer than 1 month?  ",A$:PRINT:AF=0
  30. 145  IF A$="y" OR A$="Y" THEN AF=1:PRINT "Then it is preferable to randomize SUBSETS independently to avoid seasonal bias":PRINT TAB(15);"and to asssure equal numbers of cases and controls":PRINT TAB(23);"should the study terminate early.":PRINT
  31. 150  D1="How many subjects ":IF AF=1 THEN PRINT TAB(8);D1;"are expected to enter the study each month?":AR=10:AC=70:GOSUB 4800:NN=VAL(IP$) ELSE PRINT TAB(13);D1;"(total) will be in the study?":AR=6:AC=62:GOSUB 4800:NN=VAL(IP$)
  32. 155  NM=NN/2:ERASE CX,CC:DIM CX(NM+1),CC(NM+1):PRINT:PRINT
  33. 160  PRINT #1,TAB(PMAX/2-13);"RANDOM ASSIGNMENT OF";NN;"SUBJECTS":PRINT #1,
  34. 165  GOSUB 210:NT=0:NC=0:EZ=0
  35. 170  EZ=EZ+1:IF (NN-EZ)*RND<NM-NT THEN NT=NT+1:CX(NT)=EZ ELSE NC=NC+1:CC(NC)=EZ
  36. 175  IF NT+NC<NN THEN 170
  37. 180  GOSUB 215:PRINT #1,"CASES = ";:T=11
  38. 185  FOR Z=1 TO NT:PRINT #1,TAB(T);CX(Z);:T=T+7:IF T>PMAX THEN T=11
  39. 190  NEXT
  40. 195  PRINT #1,:PRINT #1,:PRINT #1,"CONTROLS =";:T=11
  41. 200  FOR Z=1 TO NC:PRINT #1,TAB(T);CC(Z);:T=T+7:IF T>PMAX THEN T=11
  42. 205  NEXT:PRINT #1,:GOTO 265
  43. 210  RANDOMIZE (VAL(RIGHT$(TIME$,2))):COLOR 23:AR=CSRLIN:PRINT TAB(35);"RANDOMIZING";:COLOR CLR1:RETURN
  44. 215  LOCATE AR,1:PRINT TAB(79):LOCATE AR,1:PLAY "MS O3 L64 G O2 GE L9 E":RETURN
  45. 220  PRINT TAB(23);"ASSIGN PAIRED SUBJECTS TO TWO GROUPS":PRINT TAB(23);STRING$(36,205)
  46. 225  LOCATE 4,17:PRINT "How many PAIRS of subjects are in the study?":AR=4:AC=62:GOSUB 4800:NM=VAL(IP$)
  47. 230  PRINT TAB(12);"Each member of a pair is assigned #1 or #2 on the basis of"
  48. 235  PRINT TAB(14);"alphabetical order or some other objective criterion."
  49. 240  PRINT #1,:PRINT #1,TAB(PMAX/2-17);"RANDOM ASSIGNMENT OF";NM;"PAIRS TO TWO GROUPS":PRINT #1,
  50. 245  PRINT #1,TAB(PMAX/3);"#1 IN PAIR";TAB(PMAX*2/3);"#2 IN PAIR"
  51. 250  RANDOMIZE VAL(RIGHT$(TIME$,2)):PRINT #1,:D1="CASE":D2="CONTROL"
  52. 255  FOR Z=1 TO NM:PRINT #1,TAB(15);Z;:RN=RND:PRINT #1,TAB(PMAX/3+2);:IF RN<0.5 THEN PRINT #1,D1;TAB(PMAX*2/3+2);D2 ELSE PRINT #1,D2;TAB(PMAX*2/3+2);D1
  53. 260  NEXT
  54. 265  CLOSE #1:LOCATE 25,16:INPUT;"Do you want to perform another randomization?  ",A$:IF A$="y" OR A$="Y" THEN 20
  55. 270  GOTO 3000
  56. 5000  BEEP:IF ERR<>53 AND ERR<>71 THEN 5010 ELSE LOCATE 2,10:PRINT "Please place EPISTAT in drive A: (or other default).":PRINT TAB(25);"Press any key to continue:"
  57. 5005  A$=INKEY$:IF A$="" THEN 5005 ELSE RESUME
  58. 5010  ON ERROR GOTO 0:END
  59.