R version 2.10.1 (2009-12-14) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [R.app GUI 1.31 (5538) powerpc-apple-darwin8.11.1] ># ># Chi-Squared Test for Independence (Treibergs) 1-27-10 ># ># From W. Navidi "Statistics for Engineers and Scientists" 2006 ># page 438 # 12 ># At a certain genetic locus on the chromosome, each individual has ># one of three different DNA sequences (alleles). The three alleles are ># denoted B1, B2, B3. At another genetic locus on the same chromosome, each ># organism has one of three alleles denoted A1,A2,A3. each individual ># therefore has one of nine possible allele pairs: A1B1, A1B2, ... , A3B3. ># These paire are called haplotypes. The loci are said to be in linkage ># equilibrium if the two alleles in the individuals haplotype are independent. ># Haplotypes were determined for 316 individuals. Test whether the data ># suggests strongly that the haplotypes are not in linkage equilibrium ># (independent.) table of observed counts: ># ># B1 B2 B3 ># A1 66 44 34 ># A2 36 38 20 ># A3 32 22 24 ># > x <- matrix(c(66,36,32,44,38,22,34,20,24),ncol=3);x [,1] [,2] [,3] [1,] 66 44 34 [2,] 36 38 20 [3,] 32 22 24 > t <- chisq.test(x);t Pearson's Chi-squared test data: x X-squared = 4.8679, df = 4, p-value = 0.3011 > t$expected [,1] [,2] [,3] [1,] 61.06329 47.39241 35.54430 [2,] 39.86076 30.93671 23.20253 [3,] 33.07595 25.67089 19.25316 ># ># ># H0: independent. Accept H0. ># ># ============================================================= R version 2.10.1 (2009-12-14) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [R.app GUI 1.31 (5538) powerpc-apple-darwin8.11.1] ># ># Chi-Squared Test for Homogeneity (Treibergs) 1-27-10 ># ># From Devore "Probability and Statistics for Engineering ># and the Sciences" 6th ed. ># ># A 2004 study of the health effects of carbon monoxide ># in Istanbul resulted in the following counts of conditions for ># employees on various shifts. test whether the data strongly ># indicates that the proportions are not the same for each shift. ># ># Flu Headache Weakness Shortness of breath ># Morning 16 24 11 7 ># Evening 13 33 16 9 ># Night 18 6 5 9 ># ># > x <- matrix(c(16,13,18,24,33,6,11,16,5,7,9,9),ncol=4);x [,1] [,2] [,3] [,4] [1,] 16 24 11 7 [2,] 13 33 16 9 [3,] 18 6 5 9 > t<-chisq.test(x); t Pearson's Chi-squared test data: x X-squared = 17.5716, df = 6, p-value = 0.007397 > t$expected [,1] [,2] [,3] [,4] [1,] 16.32335 21.88024 11.113772 8.682635 [2,] 19.98204 26.78443 13.604790 10.628743 [3,] 10.69461 14.33533 7.281437 5.688623 > ># ># H0: proportions of conditions are the same for each shift. ># Reject H0. =================================================================