home *** CD-ROM | disk | FTP | other *** search
- 10 rem
- 11 print"[147]"chr$(142):poke53281,0:poke53280,6
- 12 printspc(8)"loadstar 2x2 statistics":print""spc(9)"written by al vekovius
- 13 [153]" converted to the c-64 by alan gardner"
- 14 [153]""[166]12)"copyright 1985"
- 15 [153]" loadstar is not public domain."
- 16 [153]" please respect the author's rights."
- 17 [153]" press a key to continue.":[151]198,0:[146]198,1:[161]r$
- 20 [137]500:nd[178]0
- 100 [143] plot routine
- 110 [151]783,0:[151]781,vt:[151]782,ht
- 120 [158]65520
- 130 [142]
- 500 [143] main menu
- 510 [153]"load":[151]53281,0:[151]53280,5
- 520 [153]"2x2 loadstar statistics"
- 530 [153]"1> input data"
- 540 [153]"2> view your data"
- 550 [153]"3> view expected values"
- 560 [153]"4> chi-square test"
- 570 [153]"5> fisher's exact test"
- 580 [153]"6> mcnemar's test"
- 581 [153]"7> see examples"
- 582 [153]"8> exit"
- 590 :
- 600 [153]"make a selection ";:[151]198,0:[146]198,1:[161]r$
- 605 [139]r$[179]"1"[176]r$[177]"8"[167][153]:[153]"onononon";:[151]53280,[187](1)[172]15:[137]600
- 606 [139]r$[178]"7"[167][141]8541:[137]700:[143] save those values
- 607 [139]r$[178]"8"[167]20000
- 610 [145][197](r$)[141]7000,4500,8200,6000,4000,9500
- 620 [137]500
- 700 [143] example menu
- 701 [153]"load":[153]"examples menu"
- 702 [153]"1. example of chi-square test"
- 704 [153]"2. example of fisher's test"
- 706 [153]"3. example of mcnemar's test"
- 708 [153]"4. return to main menu"
- 710 :
- 720 [153]"make a selection":[151]198,0:[146]198,1:[161]r$
- 721 [139]r$[179]"1"[176]r$[177]"4"[167][153]"onononon";:[151]53280,[187](1)[172]15:[137]720
- 730 [139]r$[178]"1"[167]flag[178]1:[141]1920:[137]12000
- 734 [139]r$[178]"2"[167]flag[178]2:[141]1910:[137]12000
- 736 [139]r$[178]"3"[167]flag[178]3:[141]1930:[137]12000
- 760 [141]8651:[141]7400:[141]8000:[141]8500
- 761 [143] get values, margins, display values, save values
- 770 [137]500
- 900 :
- 1000 [143] compute factorial
- 1005 [139]n[178]1[176]n[178]0[167]s[178]1:[137]1050
- 1010 s[178]1
- 1020 [129]k[178]2[164]n
- 1030 s[178]k[172]s
- 1040 [130]
- 1050 [142]
- 1090 :
- 1900 [143] example
- 1910 b$[178]"fisher's exact example":x$(1)[178]"alive":x$(2)[178]"died"
- 1911 y$(1)[178]"gam glob":y$(2)[178]"pasteur":n(1,1)[178]11:n(1,2)[178]1:n(2,1)[178]2:n(2,2)[178]3
- 1912 [142]
- 1913 :
- 1920 b$[178]"chi-square example":x$(1)[178]"male":x$(2)[178]"female"
- 1921 y$(1)[178]"democrat":y$(2)[178]"republican":n(1,1)[178]15:n(1,2)[178]10:n(2,1)[178]7:n(2,2)[178]10
- 1922 [142]
- 1923 :
- 1930 b$[178]"mcnemar's test":x$(1)[178]"test2 +":x$(2)[178]"test2 -"
- 1931 y$(1)[178]"test1 +":y$(2)[178]"test1 -":n(1,1)[178]32:n(1,2)[178]10:n(2,1)[178]7:n(2,2)[178]26
- 1932 [142]
- 1933 :
- 1940 :
- 1999 [142]
- 2000 [143] draw 2 x 2 table
- 2005 [153]"load"b$
- 2006 d$[178]""
- 2010 [129]i[178]6[164]19:[153][202](d$,1,i)[166]10)"peek";[166]10)"peek"[166]10)"peek"
- 2020 [130]
- 2030 [129]x[178]1[164]3:[153]"":[129]p[178]1[164]4[172]x[170]2:[153]"";: [130]
- 2032 [153][166]9)"---------------------------"
- 2034 [130]
- 2040 [153]""y$(1)
- 2050 [153]""y$(2)
- 2060 [153]""x$(1)
- 2070 [153]""x$(2)
- 2080 [153]
- 2100 [142]
- 3000 vt[178]9:ht[178]14:[141]100
- 3002 [153]d(1,1);:ht[178]24:[141]100:[153]d(1,2);:ht[178]33:[141]100:[153]r(1)
- 3010 vt[178]13:ht[178]14:[141]100
- 3012 [153]d(2,1);:ht[178]24:[141]100:[153]d(2,2);:ht[178]33:[141]100:[153]r(2)
- 3020 vt[178]17:ht[178]14:[141]100
- 3022 [153]c(1);:ht[178]24:[141]100:[153]c(2);:ht[178]33:[141]100:[153]t
- 3090 [142]
- 3500 vt[178]9:ht[178]14:[141]100:[153]d(1,1):ht[178]24:[141]100:[153]""d(1,2)"wait";:ht[178]33:[141]100
- 3501 [153]r(1)
- 3510 vt[178]13:ht[178]14:[141]100:[153]""d(2,1)"wait":ht[178]24:[141]100:[153]d(2,2);:ht[178]33:[141]100
- 3511 [153]r(2)
- 3520 vt[178]17:ht[178]14:[141]100:[153]c(1);:ht[178]24:[141]100:[153]c(2):ht[178]33:[141]100:[153]t
- 3600 :
- 3999 [142]
- 4000 [143] fisher's exact test
- 4001 [139]t[178]0[167][141]15000:[137]4110
- 4002 prob[178]0:tag[178]0
- 4005 [139]t[177]33[167][153]"load cannot compute this function with the"
- 4006 [139]t[177]33[167][153]""[166]12)"current data.":[129]dl[178]1[164]3000:[130]:[137]4100
- 4010 [141]5100
- 4020 [141]5000
- 4030 prob[178]prob[170]x[173]p
- 4035 b$[178]"fisher's exact test"
- 4039 tag[178]0
- 4040 [139]n(li,lj)[178]0[167][141]2000:[141]3000:x[178]prob:tag[178]1
- 4042 [139]tag[178]1[167]vt[178]20:ht[178]0:[141]100:[153]" p=";:[141]11000:
- 4043 [139]tag[178]1[167][153]" press any key to continue":[151]198,0:[146]198,1
- 4044 [139]tag[178]1[167][161]r$:[153]:[137]4100
- 4050 [141]5200
- 4060 [137]4020
- 4100 [141]8600
- 4110 [142]
- 4200 :
- 4500 [143] view data
- 4501 [139]t[178]0[167][141]15000:[137]4540
- 4510 b$[178]"":[141]2000
- 4520 [141]3000
- 4530 [153]" press a key to continue":[151]198,0:[146]198,1:[161]r$
- 4540 [142]
- 4600 :
- 5000 [143] print fisher
- 5005 p[178]1
- 5010 [129]i[178]1[164]2:[129]j[178]1[164]2:n[178]n(i,j):[141]1000:p[178]p[172]s:[130]j,i
- 5020 [129]i[178]1[164]2
- 5030 n[178]c(i):[141]1000:cf(i)[178]s
- 5040 n[178]r(i):[141]1000:rf(i)[178]s
- 5050 [130]i
- 5060 n[178]t:[141]1000:tf[178]s
- 5070 x[178](cf(1)[172]cf(2)[173]tf)[172]rf(1)[172]rf(2)
- 5080 exact[178]x[173]p
- 5090 [142]
- 5095 :
- 5100 [143] set up fisher
- 5105 m[178]9999
- 5110 [139]m[177]r(1)[167] m[178]r(1):x[178]1
- 5120 [139]m[177]r(2)[167] m[178]r(2):x[178]2
- 5130 [139]m[177]c(1)[167] m[178]c(1):x[178]3
- 5140 [139]m[177]c(2)[167] m[178]c(2):x[178]4
- 5150 [139]x[179]3[167]a1[178]n(x,1)[173]c(1):a2[178]n(x,2)[173]c(2)
- 5160 [139]x[177]2[167]a1[178]n(1,x[171]2)[173]r(1):a2[178]n(2,x[171]2)[173]r(2)
- 5170 [139]x[179]3[167]li[178]x:lj[178]1:[139]a2[179]a1[167]lj[178]2
- 5180 [139]x[177]2[167]lj[178]x[171]2:li[178]1:[139]a2[179]a1[167]li[178]2
- 5190 [142]
- 5195 :
- 5200 [143] set up next pass fisher
- 5210 [129]i[178]1[164]2:[129]j[178]1[164]2
- 5230 [139]i[178]li[175]j[178]lj[167]n(i,j)[178]n(i,j)[171]1:[137]5290
- 5240 [139]i[179][177]li[175]j[179][177]lj[167]n(i,j)[178]n(i,j)[171]1:[137]5290
- 5250 n(i,j)[178]n(i,j)[170]1
- 5290 [130]j:[130]i
- 5300 [142]
- 5400 :
- 6000 [143] chi square and yates
- 6005 [139]t[178]0[167][141]15000:[137]6900
- 6006 b$[178]"chi-square test"
- 6010 cn[178]n(1,1)[172]n(2,2)[171]n(2,1)[172]n(1,2)
- 6020 yt[178][182](cn)[171]t[173]2
- 6030 prod[178]c(1)[172]c(2)[172]r(1)[172]r(2)
- 6040 csq[178]cn[174]2[172]t[173]prod
- 6050 yts[178]yt[174]2[172]t[173]prod
- 6060 [141]8000:[141]2000:[141]3000
- 6100 [153]"chi-square :"csq
- 6110 a[178]csq:[141]10000
- 6120 [153]a$
- 6125 [153]
- 6130 [153]"yates ="yts
- 6140 a[178]yts:[141]10000
- 6150 [153]a$
- 6160 [151]198,0:[146]198,1:[161]r$
- 6900 [153]:[142]
- 6999 :
- 7000 [143] input data
- 7010 x$(1)[178]" col 1":x$(2)[178]" col 2": y$(1)[178]" row 1":y$(2)[178]" row 2"
- 7020 [153]"load"
- 7025 [141]2000
- 7030 ht[178]10:vt[178]20:[141]100:[153]"do you want new labels"
- 7031 vt[178]21:ht[178]10:[141]100:[153]"for this table (y/n)";:
- 7032 [151]198,0:[146]198,1:[161]r$:[153]
- 7040 [139]r$[178]"y"[167][141]7300:[137]7020
- 7045 [139]r$[178]"n"[167]7200
- 7050 [153]"onononon";:[137]7032
- 7100 :
- 7200 [143] get data values
- 7201 nd[178]1:vt[178]1:ht[178]1:[141]100:[153]"put your data in the appropriate cell"
- 7220 vt[178]9:ht[178]14:[141]100:[133]n$:n(1,1)[178][197](n$)
- 7230 vt[178]9:ht[178]24:[141]100:[133]n$:n(1,2)[178][197](n$)
- 7240 vt[178]13:ht[178]14:[141]100:[133]n$:n(2,1)[178][197](n$)
- 7250 vt[178]13:ht[178]24:[141]100:[133]n$:n(2,2)[178][197](n$)
- 7260 vt[178]18:ht[178]10:[141]100:[153]"satisfied (y/n)";:[151]198,0:[146]198,1:[161]r$
- 7270 [139]n(1,1)[177]16[176]n(1,2)[177]16[176]n(2,1)[177]16[176]n(2,2)[177]16[167][141]16000:[137]7000
- 7272 [139]n(1,1)[179]0[176]n(1,2)[179]0[176]n(2,1)[179]0[176]n(2,2)[179]0[167][141]17000:[137]7000
- 7275 [141]7400:[141]8000:[141]8100
- 7288 [141]8500
- 7290 [142]
- 7295 :
- 7300 [143] input labels
- 7310 [153]"load"
- 7320 [133] "label for row 1 ";y$(1):[139][195](y$(1))[177]8[167]y$(1)[178][200](y$(1),8)
- 7330 [133] "label for row 2 ";y$(2):[139][195](y$(2))[177]8[167]y$(2)[178][200](y$(2),8)
- 7340 [133] "label for col 1 ";x$(1):[139][195](x$(1))[177]8[167]x$(1)[178][200](x$(1),8)
- 7350 [133] "label for col 2 ";x$(2):[139][195](x$(2))[177]8[167]x$(2)[178][200](x$(2),8)
- 7360 [142]
- 7390 :
- 7400 [143] calculate margins
- 7405 r(1)[178]n(1,1)[170]n(1,2):r(2)[178]n(2,1)[170]n(2,2)
- 7410 c(1)[178]n(1,1)[170]n(2,1):c(2)[178]n(1,2)[170]n(2,2)
- 7420 t[178]c(1)[170]c(2)
- 7499 [142]
- 7500 :
- 8000 [143] get display values
- 8010 [129]i[178]1[164]2:[129]j[178]1[164]2:d(i,j)[178]n(i,j):[130]j,i
- 8020 [142]
- 8030 :
- 8100 [143] expected values
- 8105 ex[178]0
- 8110 b$[178]"expected values"
- 8120 [129]i[178]1[164]2:[129]j[178]1[164]2
- 8130 e(i,j)[178]r(i)[172]c(j)[173]t:e(i,j)[178][181](e(i,j)[172]100[170].5)[173]100
- 8135 [139]e(i,j)[179]5[167]ex[178]1
- 8140 [130]j,i
- 8150 [142]
- 8160 :
- 8200 [143] print expected values
- 8205 [139]t[178]0[167][141]15000:[137]8280
- 8230 [129]i[178]1[164]2:[129]j[178]1[164]2:d(i,j)[178]e(i,j):[130]j,i
- 8240 [141]2000
- 8245 [141]3000
- 8250 [139]ex[178]1[167]vt[178]20:ht[178]0:[141]100
- 8251 [139]ex[178]1[167][153]"you have an expected values less than 5"
- 8260 [153]" press a key to continue":[151]198,0:[146]198,1:[161]r$:[153]
- 8270 [141]8000
- 8280 [142]
- 8300 :
- 8500 [143] hold values
- 8510 [129]i[178]1[164]2:[129]j[178]1[164]2
- 8520 t(i,j)[178]n(i,j)
- 8530 [130]j,i
- 8540 [142]
- 8541 [143] hold values for examples
- 8542 [129]i[178]1[164]2:[129]j[178]1[164]2
- 8543 l(i,j)[178]n(i,j)
- 8544 [130]j,i
- 8545 l1$[178]y$(1):l2$[178]y$(2):l3$[178]x$(1):l4$[178]x$(2)
- 8546 [142]
- 8550 :
- 8600 [143] retrieve values
- 8610 [129]i[178]1[164]2:[129]j[178]1[164]2
- 8620 n(i,j)[178]t(i,j)
- 8630 [130]j,i
- 8640 [142]
- 8650 :
- 8651 [143] retrieve values for examples
- 8652 [129]i[178]1[164]2:[129]j[178]1[164]2
- 8653 n(i,j)[178]l(i,j)
- 8654 [130]j,i
- 8655 y$(1)[178]l1$:y$(2)[178]l2$:x$(1)[178]l3$:x$(2)[178]l4$
- 8656 [142]
- 8700 :
- 9000 [143] corr binomial prob
- 9010 m1[178]n(1,2):m2[178]n(2,1):m3[178]m1[170]m2
- 9020 lt[178]m1
- 9030 [139]m2[179]m1[167]lt[178]m2
- 9040 bi[178]1
- 9045 [139]lt[178]0[167]9110
- 9050 n[178]m3:[141]1000:m4[178]s
- 9060 [129]j[178]1[164]lt
- 9070 n[178]j:[141]1000:jf[178]s
- 9080 n[178]m3[171]j:[141]1000:js[178]s
- 9090 bi[178]bi[170]m4[173](jf[172]js)
- 9100 [130]j
- 9110 bi[178]bi[173]2[174]m3
- 9120 [142]
- 9130 :
- 9500 [143] mcnemar's test
- 9505 [139]t[178]0[167][141]15000:[137]9550
- 9510 mc[178](n(1,2)[171]n(2,1))[174]2[173](n(1,2)[170]n(2,1))
- 9520 mc[178][181](mc[172]10000[170].5)[173]10000:a[178]mc:[141]10000
- 9525 b$[178]"mcnemar's test"
- 9530 [141]2000:[141]3000:vt[178]20:ht[178]0:[141]100:[153]"chi square ="mc:[153]a$
- 9535 [141]9000:[153]"one tail binomial prob. =";:x[178]bi:[141]11000
- 9540 [151]198,0:[146]198,1:[161]r$:[153]
- 9550 [142]
- 9600 :
- 10000 [143] chi square table df=1
- 10010 a$[178]"not significant at .05 level"
- 10020 [139]a[177]3.84[167]a$[178]"significant at the .05 level"
- 10030 [139]a[177]5.02[167]a$[178]"significant at the .025 level"
- 10040 [139]a[177]6.63[167]a$[178]"significant at the .010 level"
- 10050 [139]a[177]7.88[167]a$[178]"significant at the .005 level"
- 10060 [139]a[177]10.8[167]a$[178]"significant at the .0001 level"
- 10070 [142]
- 10080 :
- 11000 [143] print routine
- 11005 [153]".";
- 11010 [129]i[178]1[164]6
- 11020 x[178]10[172]x:xx[178][181](x):s$[178][196](xx):s$[178][202](s$,2):x[178]x[171]xx
- 11030 [153]s$;
- 11040 [130]
- 11050 [153]
- 11060 [142]
- 11070 :
- 12000 [143] example of fisher
- 12003 [141]8500: [143] save values
- 12005 [153]"load":[139]flag[179][177]2[167]12020
- 12010 [153][163]4)"an example of fisher's exact test"
- 12012 [153]" seventeen persons had been bitten in the head or neck by the same";
- 12013 [153]" rabid wolf in iran (bull. world health organ.1955).
- 12014 print" the standard pasteur vaccine treatmentwas given. in addition, 12";
- 12015 print" persons alsoreceived one or more doses of antirabies";
- 12016 print"gamma globulin. the results are summar-ized as follows:"
- 12018 vt=23:ht=5:gosub100:print"press any key to continue";:poke198,0:wait198,1
- 12019 getr$:goto12050
- 12020 ifflag<>1then12031
- 12021 printtab(5)"an example of chi-square test":print" suppose that 42 people are";
- 12022 print" called at random to determine whether there is anyrelationship";
- 12023 print" between a person's sex and whether he will vote democratic or "
- 12024 print"republican in the next electon.":print"results are as follows: of the 25"
- 12025 print"men contacted, 15 will vote democratic and 10 will vote republican."
- 12026 print"of the 17 women contacted, 7 will vote democratic[160]and 10 will vote";
- 12027 print" republican.":print" the question is whether there is a difference";
- 12028 print" between males and females based on the findings represented."
- 12029 vt=24:ht=5:gosub100:print"press any key to continue";:poke198,0:wait198,1
- 12030 getr$:goto12050
- 12031 printtab(6)"an example of mcnemar's test":print" suppose that two diagnostic";
- 12032 print" tests are both applied to 75 men.":print"when the tests do not agree,";
- 12033 print" do they do so in the same way? that is, do the"
- 12034 print"cases when test 1 is positive and test 2"
- 12035 print"[145]is negative occur in equal numbers to the cases when test 1 is";
- 12036 print" negative and test 2 is positive?"
- 12038 vt=23:ht=5:gosub100:print"press any key to continue":poke198,0:wait198,1
- 12039 getr$
- 12050 gosub8000:gosub7400:gosub2000
- 12052 ifflag=3thengosub3500:goto12070
- 12055 gosub3000
- 12070 vt=23:ht=1:gosub100:print"press a key to examine expected values"
- 12072 poke198,0:wait198,1:getr$:gosub8105
- 12080 fori=1to2:forj=1to2:d(i,j)=e(i,j):nextj,i
- 12090 gosub2000:gosub3000
- 12100 ifflag=2thenprint:print"since at least one expected value is less than 5, ";
- 12101 ifflag=2thenprint" chi-square is not valid. fisher's exact test is the";
- 12102 ifflag=2thenprint" test to use."
- 12110 vt=23:ht=5:gosub100:print"press any key to continue":poke198,0:wait198,1
- 12111 getr$:
- 12120 ifflag=2thengosub8000:gosub4000:goto12200
- 12130 ifflag=1thengosub6000:goto12200
- 12140 gosub9500
- 12200 goto700
- 15000 rem no data entered yet!
- 15005 print"[147] sorry! there is no data entered yet.."
- 15010 print"please press a key"
- 15020 poke198,0:wait198,1:getr$
- 15030 return
- 16000 rem values to big
- 16010 print"[147] your values are too big..."
- 16012 print" please keep them less than 16."
- 16020 print" press a key to re-enter the values."
- 16030 poke198,0:wait198,1:getr$
- 16040 return
- 17000 rem values to small
- 17020 print"[147] no negative values please..."
- 17030 print" press a key to re-enter the values."
- 17040 poke198,0:wait198,1:getr$
- 17050 return
- 20000 rem return to ls
- 20010 print"[147]load"chr$(34)"hello"chr$(34)",8":print"run"
- 20020 poke631,13:poke632,13:poke198,2:
- 20030 end
-