home *** CD-ROM | disk | FTP | other *** search
/ PC Home 11 / PC_HOME_11.ISO / general / maths / gcemath / amc / am1408b.cha < prev    next >
Encoding:
Text File  |  1994-07-12  |  12.0 KB  |  535 lines

  1. .SET #8(*1, *)
  2. .LET (*#34=#34+#8*) TEXT
  3. .LET (*#21=#21+#6*)
  4. @LAB:SCREEN10
  5. .SCR 0
  6. .SNA(*(.INF 39)0*)
  7. .COL 7,0
  8. .LOC 2,46(*10*)
  9. .COL 0,3
  10. .LOC 5,11(* Contingency Tables *)
  11. .PAU(**)#4
  12. .COL 14,0
  13. .LOC 8,10(*Another important use of the X² distribution is to investigate*)
  14. .LOC 10,16(*a population which has been split into pre-defined*)
  15. .LOC 12,14(*categories.  It is*)
  16. .COL 12,0
  17. .LOC 12,33(*ESSENTIAL*)
  18. .COL 14,0
  19. .LOC 12,43(*that these categories are*)
  20. .COL 11,0
  21. .LOC 15,32(*MUTUALLY  EXCLUSIVE*)
  22. .PAU(**)#4
  23. .COL 10,0
  24. .LOC 18,15(*Our Null Hypothesis, in this case, is always that the*)
  25. .COL 12,0
  26. .LOC 20,21(*categories are statistically independent.*)
  27. .SPE PLAY (*AM140810.SPE*) WAIT
  28. .PAU(**)#4
  29. .COL 0,3
  30. .LOC 24,64(*SPACE >>*)
  31. .PAU(**)
  32. @LAB:SCREEN11
  33. .SCR 0
  34. .SNA(*(.INF 39)0*)
  35. .COL 7,0
  36. .LOC 2,46(*11*)
  37. .COL 14,0
  38. .LOC 5,13(*We shall use the X² test in precisely the same way as in*)
  39. .LOC 7,36(*Module 14.7*)
  40. .PAU(**)#4
  41. .COL 12,0
  42. .LOC 9,13(*An example:*)
  43. .COL 10,0
  44. .LOC 11,15(*A population of 1000 schoolchildren was split up according*)
  45. .LOC 13,15(*to the colour of their hair and the colour of their eyes.*)
  46. .LOC 15,15(*The results were...*)
  47. .COL 14,0
  48. .LOC 15,43(*[ fictitious data ]*)
  49. .PAU(**)#4
  50. .COL 0,3
  51. .LOC 24,64(*SPACE >>*)
  52. .PAU(**)
  53. .LOC 24,64(*          *)
  54. .COL 7,0
  55. .WIP (4,2)-(23,79) #6
  56. .LOC 2,46(*11a*)
  57. .COL 14,0
  58. .LOC 11,38(*Hair Colour*)
  59. .LOC 12,29(*Black   Brown   Blond   Red*)
  60. .LOC 15,12(*Eye*)
  61. .LOC 17,12(*Colour*)
  62. .LOC 14,21(*Blue*)
  63. .LOC 16,21(*Brown*)
  64. .LOC 18,21(*Other*)
  65. .COL 13,0
  66. .LOC 11,27(*║*)
  67. .LOC 11,58(*║*)
  68. .LOC 12,27(*║*)
  69. .LOC 12,58(*║*)
  70. .LOC 13,21(*──────╫──────────────────────────────╫───────*)
  71. .LOC 14,27(*║                              ║*)
  72. .LOC 15,27(*║                              ║*)
  73. .LOC 16,27(*║                              ║*)
  74. .LOC 17,27(*║                              ║*)
  75. .LOC 18,27(*║                              ║*)
  76. .LOC 19,21(*──────╫──────────────────────────────╫───────*)
  77. .LOC 20,27(*║                              ║*)
  78. .COL 14,0
  79. .LOC 20,21(*Totals*)
  80. .LOC 12,60(*Totals*)
  81. .COL 10,0
  82. .LOC 14,30(*110      70     130     40*)
  83. .LOC 14,62(*350*)
  84. .LOC 16,31(*20     270      20     40*)
  85. .LOC 16,62(*350*)
  86. .LOC 18,31(*50     170      50     30*)
  87. .LOC 18,62(*300*)
  88. .LOC 20,30(*180     510     200    110*)
  89. .LOC 20,61(*1000*)
  90. .SPE PLAY (*AM140811.SPE*) WAIT
  91. .PAU(**)#4
  92. .COL 12,0
  93. .LOC 22,15(*NULL HYPOTHESIS:*)
  94. .PAU(**)#4
  95. .COL 10,0
  96. .LOC 22,32(*hair colour is independent of eye colour*)
  97. .PAU(**)#4
  98. .COL 0,3
  99. .LOC 24,64(*SPACE >>*)
  100. .PAU(**)
  101. .LOC 24,64(*          *)
  102. .COL 7,0
  103. .WIP (4,2)-(23,79) #6
  104. .LOC 2,46(*11b*)
  105. .PAU(**)#2
  106. .COL 10,0
  107. .LOC 18,15(*Each individual entry in the table is called a*)
  108. .COL 11,0
  109. .LOC 18,62(*CELL*)
  110. .PAU(**)#4
  111. .COL 0,3
  112. .LOC 8,30(*110*)
  113. .PAU(**)#2
  114. .COL 10,0
  115. .LOC 8,30(*110*)
  116. .COL 0,3
  117. .LOC 10,47(*20*)
  118. .PAU(**)#2
  119. .COL 10,0
  120. .LOC 10,47(*20*)
  121. .COL 0,3
  122. .LOC 12,47(*50*)
  123. .PAU(**)#2
  124. .COL 10,0
  125. .LOC 12,47(*50*)
  126. .COL 0,3
  127. .LOC 12,38(*170*)
  128. .PAU(**)#2
  129. .COL 10,0
  130. .LOC 12,38(*170*)
  131. .PAU(**)#4
  132. .LOC 20,15(*This Contingency Table has*)
  133. .COL 11,0
  134. .LOC 20,43(*3 rows*)
  135. .COL 0,3
  136. .LOC 8,70(*«*)
  137. .LOC 10,70(*«*)
  138. .LOC 12,70(*«*)
  139. .PAU(**)#2
  140. .COL 10,0
  141. .LOC 8,70(* *)
  142. .LOC 10,70(* *)
  143. .LOC 12,70(* *)
  144. .PAU(**)#2
  145. .COL 10,0
  146. .LOC 20,51(*and*)
  147. .COL 11,0
  148. .LOC 20,56(*4 columns*)
  149. .COL 0,3
  150. .LOC 15,31(*^*)
  151. .LOC 15,39(*^*)
  152. .LOC 15,47(*^*)
  153. .LOC 15,54(*^*)
  154. .PAU(**)#2
  155. .COL 10,0
  156. .LOC 15,30(*                           *)
  157. .SPE PLAY (*AM140812.SPE*) WAIT
  158. .PAU(**)#4
  159. .COL 0,3
  160. .LOC 24,64(*SPACE >>*)
  161. .PAU(**)
  162. .LOC 24,64(*          *)
  163. .COL 7,0
  164. .WIP (15,2)-(23,79)
  165. .LOC 2,46(*12 *)
  166. .PAU(**)#2
  167. .COL 14,0
  168. .LOC 16,11(*From the table, assuming that the cells are independent*)
  169. .PAU(**)#4
  170. .COL 10,0
  171. .LOC 18,18(*the probability of blue eyes is 350 out of 1000*)
  172. .COL 0,3
  173. .LOC 8,61(* 350 *)
  174. .LOC 14,60(* 1000 *)
  175. .PAU(**)#4
  176. .COL 14,0
  177. .LOC 20,26(*»*)
  178. .COL 10,0
  179. .LOC 20,33(*p( blue eyes )  =  0.35*)
  180. .COL 10,0
  181. .LOC 8,61(* 350 *)
  182. .LOC 14,60(* 1000 *)
  183. .PAU(**)#4
  184. .LOC 22,20(*p( brown eyes )  =  35 out of 1000  =  0.35*)
  185. .COL 0,3
  186. .LOC 10,61(* 350 *)
  187. .LOC 14,60(* 1000 *)
  188. .PAU(**)#4
  189. .COL 10,0
  190. .LOC 10,61(* 350 *)
  191. .LOC 14,60(* 1000 *)
  192. .COL 0,3
  193. .LOC 24,64(*SPACE >>*)
  194. .PAU(**)
  195. .LOC 24,64(*          *)
  196. .COL 7,0
  197. .WIP (15,2)-(23,79) #4
  198. .LOC 2,46(*12a*)
  199. .PAU(**)#2
  200. .COL 10,0
  201. .LOC 20,19(*p( black hair )  =  180 out of 1000  =  0.18*)
  202. .COL 0,3
  203. .LOC 14,29(* 180 *)
  204. .LOC 14,60(* 1000 *)
  205. .PAU(**)#4
  206. .COL 10,0
  207. .LOC 14,29(* 180 *)
  208. .LOC 14,60(* 1000 *)
  209. .LOC 22,21(*p( red hair )  =  110 out of 1000  =  0.11*)
  210. .COL 0,3
  211. .LOC 14,52(* 110 *)
  212. .LOC 14,60(* 1000 *)
  213. .PAU(**)#4
  214. .COL 10,0
  215. .LOC 14,52(* 110 *)
  216. .LOC 14,60(* 1000 *)
  217. .PAU(**)#4
  218. .COL 0,3
  219. .LOC 24,64(*SPACE >>*)
  220. .PAU(**)
  221. .LOC 24,64(*          *)
  222. .COL 7,0
  223. .WIP (4,2)-(23,79) #11
  224. .LOC 2,46(*13 *)
  225. .PAU(**)#2
  226. .COL 14,0
  227. .LOC 13,11(*Using Probability Law 4 for statistically independent events:*)
  228. .PAU(**)#4
  229. .COL 10,0
  230. .LOC 15,11(*p( brown eyes*)
  231. .COL 12,0
  232. .LOC 15,25(*AND*)
  233. .COL 10,0
  234. .LOC 15,29(*red hair )  =  p( brown eyes )*)
  235. .COL 12,0
  236. .LOC 15,60(*x*)
  237. .COL 10,0
  238. .LOC 15,62(*p( red hair )*)
  239. .SPE PLAY (*AM140813.SPE*) WAIT
  240. .PAU(**)#4
  241. .LOC 17,41(*=   0.35  x  0.11*)
  242. .PAU(**)#4
  243. .LOC 17,61(*=  0.0385    (1)*)
  244. .PAU(**)#4
  245. .LOC 19,11(*Expected frequency for the cell [ brown eyes and red hair ]*)
  246. .LOC 21,41(*=  1000  x  0.0385*)
  247. .PAU(**)#4
  248. .LOC 21,61(*=  38.5      (2)*)
  249. .COL 0,3
  250. .LOC 24,64(*C / R >>*)
  251. @SIN(*"C"=L:SCREEN14,"R"=L:-SCREEN10,"c"=L:SCREEN14,"r"=L:-SCREEN10*)
  252. @LAB:SCREEN14
  253. .SNA(*(.INF 39)0*)
  254. .COL 7,0
  255. .LOC 2,46(*14*)
  256. .COL 10,0
  257. .LOC 7,11(*Note how line (1) could be written as...*)
  258. .PAU(**)#4
  259. .COL 14,0
  260. .LOC 9,34(*350    110*)
  261. .LOC 10,33(*──── x ────*)
  262. .LOC 11,33(*1000   1000*)
  263. .PAU(**)#4
  264. .COL 10,0
  265. .LOC 13,11(*and line (2) as...*)
  266. .PAU(**)#4
  267. .COL 14,0
  268. .LOC 15,36(*350    110   350 x 110*)
  269. .LOC 16,28(*1000 x ──── x ──── = ─────────*)
  270. .LOC 17,35(*1000   1000      1000*)
  271. .PAU(**)#4
  272. .COL 10,0
  273. .LOC 19,38(*Row Total x Column Total*)
  274. .LOC 20,17(*Expected frequency = ────────────────────────*)
  275. .LOC 21,41(*Grand Total*)
  276. .SPE PLAY (*AM140814.SPE*) WAIT
  277. .PAU(**)#4
  278. .WIP (4,2)-(23,79)#14
  279. .PAU(**)#2
  280. .LOC 9,11(*You may like to verify for yourself algebraically that this*)
  281. .LOC 11,27(*expression is a general rule.*)
  282. .SPE PLAY (*AM140814.SPE*) WAIT
  283. .PAU(**)#4
  284. .COL 14,0
  285. .LOC 15,13(*We can re-draw the table in our example and add expected*)
  286. .LOC 17,22(*frequencies based on these assumptions.*)
  287. .PAU(**)#4
  288. .COL 15,0
  289. .LOC 20,15(*You may find it convenient to use two colours of pen.*)
  290. .PAU(**)#4
  291. .COL 0,3
  292. .LOC 24,64(*SPACE >>*)
  293. .PAU(**)
  294. @LAB:SCREEN15
  295. .SNA(*(.INF 39)0*)
  296. .COL 7,0
  297. .LOC 2,46(*15*)
  298. .COL 14,0
  299. .LOC 5,22(*Black       Brown       Blond        Red        Totals*)
  300. .COL 11,0
  301. .LOC 6,21(*O     E     O     E     O     E     O     E     O     E*)
  302. .COL 14,0
  303. .LOC 8,11(*Blue*)
  304. .LOC 10,11(*Brown*)
  305. .LOC 12,11(*Other*)
  306. .LOC 14,11(*Totals*)
  307. .COL 13,0
  308. .LOC 5,18(*║*)
  309. .LOC 5,30(*║*)
  310. .LOC 5,42(*║*)
  311. .LOC 5,54(*║*)
  312. .LOC 5,66(*║*)
  313. .LOC 6,18(*║*)
  314. .LOC 6,30(*║*)
  315. .LOC 6,42(*║*)
  316. .LOC 6,54(*║*)
  317. .LOC 6,66(*║*)
  318. .LOC 6,24(*│*)
  319. .LOC 6,36(*│*)
  320. .LOC 6,48(*│*)
  321. .LOC 6,60(*│*)
  322. .LOC 6,72(*│*)
  323. .LOC 7,11(*───────╫─────┼─────╫─────┼─────╫─────┼─────╫─────┼─────╫─────┼─────*)
  324. .LOC 8,18(*║     │     ║     │     ║     │     ║     │     ║     │*)
  325. .LOC 9,18(*║     │     ║     │     ║     │     ║     │     ║     │*)
  326. .LOC 10,18(*║     │     ║     │     ║     │     ║     │     ║     │*)
  327. .LOC 11,18(*║     │     ║     │     ║     │     ║     │     ║     │*)
  328. .LOC 12,18(*║     │     ║     │     ║     │     ║     │     ║     │*)
  329. .LOC 13,11(*───────╫─────┼─────╫─────┼─────╫─────┼─────╫─────┼─────╫─────┼─────*)
  330. .LOC 14,18(*║     │     ║     │     ║     │     ║     │     ║     │*)
  331. .COL 10,0
  332. .LOC 8,20(*110*)
  333. .LOC 8,33(*70*)
  334. .LOC 8,44(*130*)
  335. .LOC 8,57(*40*)
  336. .LOC 8,68(*350*)
  337. .LOC 10,21(*20*)
  338. .LOC 10,32(*270*)
  339. .LOC 10,45(*20*)
  340. .LOC 10,57(*40*)
  341. .LOC 10,68(*350*)
  342. .LOC 12,21(*50*)
  343. .LOC 12,32(*170*)
  344. .LOC 12,45(*50*)
  345. .LOC 12,57(*30*)
  346. .LOC 12,68(*300*)
  347. .LOC 14,20(*180*)
  348. .LOC 14,32(*510*)
  349. .LOC 14,44(*200*)
  350. .LOC 14,56(*110*)
  351. .LOC 14,67(*1000*)
  352. .PAU(**)#4
  353. .COL 12,0
  354. .LOC 8,27(*63*)
  355. .PAU(**)#2
  356. .LOC 10,27(*63*)
  357. .PAU(**)#2
  358. .LOC 12,27(*54*)
  359. .PAU(**)#2
  360. .LOC 14,26(*180*)
  361. .PAU(**)#4
  362. .LOC 8,37(*178.5*)
  363. .PAU(**)#2
  364. .LOC 10,37(*178.5*)
  365. .PAU(**)#2
  366. .LOC 12,38(*153*)
  367. .PAU(**)#2
  368. .LOC 14,38(*510*)
  369. .PAU(**)#4
  370. .LOC 8,50(*70*)
  371. .PAU(**)#2
  372. .LOC 10,50(*70*)
  373. .PAU(**)#2
  374. .LOC 12,50(*60*)
  375. .PAU(**)#2
  376. .LOC 14,49(*200*)
  377. .PAU(**)#4
  378. .LOC 8,62(*38.5*)
  379. .PAU(**)#2
  380. .LOC 10,62(*38.5*)
  381. .PAU(**)#2
  382. .LOC 12,62(*33*)
  383. .PAU(**)#2
  384. .LOC 14,62(*110*)
  385. .PAU(**)#
  386. .LOC 8,74(*350*)
  387. .PAU(**)#2
  388. .LOC 10,74(*350*)
  389. .PAU(**)#2
  390. .LOC 12,74(*300*)
  391. .PAU(**)#2
  392. .LOC 14,73(*1000*)
  393. .PAU(**)#4
  394. .COL 14,0
  395. .LOC 17,9(*In this particular example, the sums of the expected frequencies*)
  396. .LOC 19,11(*agree with those of the observed ones.  Rounding errors can *)
  397. .LOC 21,14(*prevent this but any differences should be very small.*)
  398. .PAU(**)#4
  399. .COL 0,3
  400. .LOC 24,64(*SPACE >>*)
  401. .PAU(**)
  402. .LOC 24,64(*          *)
  403. .COL 7,0
  404. .WIP (16,2)-(23,79)
  405. .LOC 2,46(*15a*)
  406. .PAU(**)#2
  407. .COL 14,0
  408. .LOC 17,11(*Now we can calculate X² by adding up the*)
  409. .COL 12,0
  410. .LOC 16,52(*( O - E )²*)
  411. .LOC 17,53(*───────*)
  412. .LOC 18,56(*E*)
  413. .COL 14,0
  414. .LOC 17,63(*for each cell.*)
  415. .SPE PLAY (*AM140815.SPE*) WAIT
  416. .PAU(**)#4
  417. .COL 10,0
  418. .LOC 21,14(*X²  =*)
  419. .LOC 20,21(*(110 - 63)²*)
  420. .LOC 21,22(*────────*)
  421. .LOC 22,25(*63*)
  422. .PAU(**)#4
  423. .LOC 21,33(*+*)
  424. .LOC 20,35(*(70 - 178.5)²*)
  425. .LOC 21,36(*──────────*)
  426. .LOC 22,39(*178.5*)
  427. .PAU(**)#4
  428. .LOC 21,49(*+*)
  429. .LOC 20,51(*(130 - 70)²*)
  430. .LOC 21,52(*────────*)
  431. .LOC 22,56(*70*)
  432. .PAU(**)#4
  433. .LOC 21,63(*+*)
  434. .COL 12,0
  435. .LOC 20,66(*for all*)
  436. .LOC 22,66(*12 cells*)
  437. .PAU(**)#4
  438. .COL 0,3
  439. .LOC 24,64(*SPACE >>*)
  440. .PAU(**)
  441. .LOC 24,64(*          *)
  442. .COL 7,0
  443. .WIP (15,2)-(23,79) #4
  444. .LOC 2,46(*15b*)
  445. .PAU(**)#2
  446. .COL 10,0
  447. .LOC 20,18(*=  35.06 + 65.95 + 51.43 + 0.06 + 29.35 + 46.90 + 35.71*)
  448. .LOC 22,23(*+ 0.06 + 0.30 + 1.89 + 1.67 + 0.27*)
  449. .PAU(**)#4
  450. .LOC 22,59(*=  268.65*)
  451. .COL 0,3
  452. .LOC 24,64(*C / R >>*)
  453. @SIN(*"C"=L:SCREEN16,"R"=L:-SCREEN14,"c"=L:SCREEN16,"r"=L:-SCREEN14*)
  454. @LAB:SCREEN16
  455. .SNA(*(.INF 39)0*)
  456. .COL 7,0
  457. .LOC 2,46(*16*)
  458. .COL 14,0
  459. .LOC 5,15(*Now we need to look at the Degrees of Freedom to use.*)
  460. .PAU(**)#4
  461. .COL 12,0
  462. .LOC 8,11(*For the rows:*)
  463. .PAU(**)#4
  464. .COL 10,0
  465. .LOC 8,28(*we made the totals of the rows agree so*)
  466. .LOC 10,28(*we could choose all but one of them*)
  467. .PAU(**)#4
  468. .COL 11,0
  469. .LOC 12,28(*number of rows  -  1 constraint*)
  470. .PAU(**)#4
  471. .COL 14,0
  472. .LOC 12,62(*»*)
  473. .COL 11,0
  474. .LOC 12,66(*r - 1*)
  475. .PAU(**)#4
  476. .COL 12,0
  477. .LOC 14,11(*and columns:*)
  478. .PAU(**)#4
  479. .COL 10,0
  480. .LOC 14,28(*we made the totals of the columns agree so*)
  481. .LOC 16,28(*we could choose all but one of them*)
  482. .PAU(**)#4
  483. .COL 11,0
  484. .LOC 18,28(*number of columns - 1 constraint*)
  485. .PAU(**)#4
  486. .COL 14,0
  487. .LOC 18,62(*»*)
  488. .COL 11,0
  489. .LOC 18,66(*c - 1*)
  490. .PAU(**)#4
  491. .COL 10,0
  492. .LOC 20,18(*Degrees of Freedom  =  ( r - 1 ) x ( c - 1 )*)
  493. .LOC 22,38(*=  ( 3 - 1 ) x ( 4 - 1 )  =  6*)
  494. .PAU(**)#4
  495. .COL 0,3
  496. .LOC 24,64(*SPACE >>*)
  497. .PAU(**)
  498. @LAB:SCREEN17
  499. .SCR 2
  500. .SNA(*(.INF 39)2*)
  501. .LOC 2,46(*17*)
  502. .PUT 183,29 PART=6
  503. .LOC 5,27(*=  268.65*)
  504. .PUT 344,31 PART=7
  505. .LOC 5,47(*=  6*)
  506. .PAU(**)#4
  507. .LOC 7,15(*Enter your*)
  508. .PUT 200,45 PART=6
  509. .LOC 7,29(*table at*)
  510. .PUT 304,47 PART=7
  511. .LOC 7,41(*= 6,  level 5 %*)
  512. .PAU(**)#4
  513. .LOC 7,60(*»  12.59*)
  514. .PAU(**)#4
  515. .LOC 9,16(*268.65  IS  ≥  12.59  so the result is  SIGNIFICANT*)
  516. .PAU(**)#4
  517. .LOC 12,9(*In fact, it is still highly significant even at the 0.1 % level !*)
  518. .PAU(**)#4
  519. .LOC 15,11(*We reject the Null Hypothesis  and the  Alternate Hypothesis*)
  520. .LOC 17,12(*that the categories are  NOT INDEPENDENT  would be adopted.*)
  521. .PAU(**)#4
  522. .USE PROG=PAUSE.USE
  523. .WIP (4,2)-(23,79) #3
  524. .LOC 2,46(*17a*)
  525. .PAU(**)#2
  526. .LOC 17,11(*The result is as you should expect:*)
  527. .PAU(**)#4
  528. .LOC 19,17(*brown hair is usually associated with brown eyes*)
  529. .LOC 21,17(*blond hair is usually associated with blue eyes.*)
  530. .PUT 500,187 PART=2 PSET
  531. @SIN(*"C"=L:SCREEN17Z,"R"=L:-SCREEN11,"c"=L:SCREEN17Z,"r"=L:-SCREEN11*)
  532. @LAB:SCREEN17Z
  533. @GOB:SCREEN18 PROG=AM1408B1.CHA
  534.  
  535.