AMS 572 Lecture Notes 7 Nov. 16th , 2009 Inference on several proportions—the Chi-square test (large sample) Def. Multinomial Experiment. We have a total of n trials (sample size=n) ① For each trial, it will result in 1 of k possible outcomes. ② The probability of getting outcome i is pi , and k p =1 i 1 i ③ These trials are independent. e.g. Previous experience indicates that the probability of obtaining 1 healthy calf from a mating is 0.83. Similarly, the probabilities of obtaining 0 and 2 healthy calves are 0.15 and 0.02 respectively. If the farmer breeds 3 dams from the herd, find the probability of getting exact 3 health calves. Def. Multinomial Distribution Let X i be the number of trials resulted in i-th category out of a total of n trials and pi be the probability of getting i-th category outcome, then P( X 1 x1 , X 2 x2 ,..., X k xk ) n! p1x1 ... pk xk x1 ! x2 !...xk ! Solution: P(exact 3 health calves)= P( X1 1, X 2 1, X 3 1) + P( X 1 0, X 2 3, X 3 0) =0.015+0.572=0.59 *Relations to the Binomial Distribution (k=2) Category 1 2 Probability p1 =p p2 =1-p # trials X1 =x X 2 =n-x P ( X 1 x, X 2 n x ) n! p1x1 p2 x2 ( nx ) p x (1 p)n x x !(n x)! Chi-square goodness of fit test e.g1. Gregor Mendel (1822-1884) was an Austrian monk whose genetic theory is one of the greatest scientific discovery of all time. In his famous experiment with garden peas, he proposed a genetic model that would explain inheritance. In particular, he studied how the shape (smooth or wrinkled) and color (yellow or green) of pea seeds are transmitted through generations. His model shows that the second generation of peas from a certain ancestry should have the following distribution. wrinkledgreen Theoretical probabilities p1 1 16 wrinkledgreen p2 n=556 General test: Test whether the theoretical probability is correct 0 0 0 H 0 : p1 p1 , p2 p2 ,..., pk pk H a : H 0 is not true 3 16 smoothgreen p3 3 16 smoothyellow p4 9 16 ( x e )2 W0 i i ei i 1 k T.S H0 k21 where xi is the observed number of observations in category i ei is the expected count of the i-th category , ei n pi 0 At the significance level α, reject H 0 iff W0 k21,upper , Nov. 16th , 2009 Solution: wrinkled-green Theoretical probabilities p1 Observed count out of 556 X1 =31 Expected counts 1 16 e1 556 p2 1 =34.75 16 1 3 3 9 H 0 : p1 , p2 , p3 , p4 16 16 16 16 H a : H 0 is not true ( x e )2 W0 i i ei i 1 k T.S wrinkledgreen H0 k21 2 =7.815 0.604 < 3,0.05,upper 3 16 smoothgreen p3 3 16 smoothyellow p4 9 16 X 2 =102 X 3 =108 X 4 =315 e2 =104.25 e3 =104.25 e4 =312.75 At significance level 0.05, we cannot reject H 0 e.g2. A classic tale involves four car-pooling students who missed a test and gave as an excuse of a flat tire. On the make-up test, the professor asked the students to identify the particular tire that went flat. If they really did not have a flat tire, would they be able to identify the same tire? To mimic this situation, 40 other students were asked to identify the tire they would select. The data are: Tire Left front Right front Left rear Right rear 11 15 8 6 Frequency At α=0.05, please test whether each tire has the same chance to be selected? Solution: 1 H 0 : p1 p2 p3 p4 4 H a : H 0 is not true n=40, ei =n pi =10 k W0 i 1 ( xi ei )2 2 4.6 3,0.05, upper 7.81 ei Fail to reject H 0 . The chi-square goodness of fit test is an extension of the Z-test for one population proportion. Data: sample size n, x: successes with probability p n-x: failures with probability 1-p TS. Z 0 pˆ p0 H0 p0 (1 p0 ) n ~ N (0,1) At α, reject H 0 iff | Z0 | Z /2 Success p1 p0 Expected Observed W0 Failure p2 1 p0 e1 np0 X2 n x X 1 =x ( x np0 ) 2 [n x n(1 p0 )]2 ( x np0 ) 2 ( p0 1 p0 )]2 = np0 n(1 p0 ) np0 (1 p0 ) x ( p0 )2 ( x np0 ) 2 n Z02 = np0 (1 p0 ) p0 (1 p0 ) / n iid Recall: If Z1, Z2, ....Zn k N (0,1) , then W Z i 2 1 When k=1, W Z 2 12 Let Z~N(0,1), then W Z 2 12 P(| Z | Z /2 ) P( Z 2 Z2 /2 ) = P(W 1,2 ,upper ) The two tests are identical. e2 n(1 p0 ) k 2 . Nov. 23th , 2009 1. Fisher’s exact test: Inference on 2 population proportions, 2 independent samples e.g1. The result of a randomized clinical trial for comparing Predsome and Predsome+VCR drugs, is summarized below. Test if the success and failure probabilities are the same for the two drugs. Drug Success Failure Row total Pred 14 7 n1 =21 PVCR 38 4 n2 =42 m=58 n-m=11 n=63 “S” “F” Total Sample1 x n1 -x n1 Sample2 y n2 -y n2 m=x+y n-m n General setting: H 0 : p1 p2 H a : p1 p2 (nk1 )(mn2k ) min( m,n1 ) (kn1 )(mn2k ) p value pU P( X x | X Y m) (nm ) (nm ) kx k x H 0 : p1 p2 H a : p1 p2 p value pL P ( X x | X Y m) x ( nk1 )(nm2 k ) (nk1 )(nm2 k ) ( nm ) ( nm ) kx k max(0,m n2 ) H 0 : p1 p2 H a : p1 p2 p value 2 min( PU , PL ) Solution: H 0 : p1 p2 H a : p1 p2 p value 42 42 14 (21 (21 k )(52 k ) k )(52 k ) (63 ) 0.016 <0.05 63 (52 ) k max(0,52 42) k 10 52 14 Reject H 0 SAS code: Data trial; input drug $ outcome$ count; datalines; pred S 14 pred F 7 PVCR S 38 PVCR F 4 ; run; proc freq data=trial; tables drug*outcome/chisq; weight count; run; 2. McNemar’s test Inference on 2 population proportions- paired samples e.g2. A preference poll of a panel of 75 voters was conducted before and after a TV debate during the campaign for the 1980 presidential election between Jimmy Carter and Ronald Reagan. Test whether there was a significant shift from Carter as a result of the TV debate. Preference Preference after before Carter Reagan Carter 28 13 Reagan 7 27 General setting: Condition1 Condition2 response response Yes No Yes A=a, PA B=b, PB No C=c, PC D=d, PD PA + PB + PC + PD =1, A+B+C+D=n, (A, B, C, D)~Multinomial P1 PA PB , P2 PA PC H 0 : p1 p2 H 0 : pB pC P(B=k| B+C=m)~Bin(m,p= pB ) pB pC 1 2 Under H 0 : p , P(B=k| B+C=m)~Bin(m,p=1/2) 1 H 0 : p 2 H 0 : p1 p2 ① H : p p 2 a 1 H : p 1 a 2 1 m p value pU P ( B b | B C m) ( )m (mk ) 2 k b 1 H 0 : p 2 H 0 : p1 p2 ② H a : p1 p2 H : p 1 a 2 1 b p value pL P( B b | B C m) ( )m (mk ) 2 k 0 1 H : p 0 H : p p 2 ③ 0 1 2 H a : p1 p2 H : p 1 a 2 p value 2 min( PL , PU ) Solution: 1 H 0 : p 2 H 0 : p1 p2 H : p p 2 a 1 H : p 1 a 2 1 20 p value ( ) 20 ( 20 k ) 0.132 2 k 13 SAS code: Data election; input before $ after $ count; datalines; Carter Carter 28 Carter Reagan 13 Reagan Reagan 27 Reagan Carter 7 ; run; proc freq data=election; tables before*after/agree; weight count; run;