Docsity

Lecture 33: Chi-square Test for Independence and Two-sample Z-test, Study notes of Statistics

Partial preview of the text

Download Lecture 33: Chi-square Test for Independence and Two-sample Z-test and more Study notes Statistics in PDF only on Docsity!

STAT 2

Lecture 33:

Yet more testing

This week ● Today: the chi-square test for independence; interpreting statistical tests (ch. 28-29) ● Tuesday: review of testing ● Wednesday: mock final ● Thursday: reviewing the mock final ● Friday: the real final

Review: the two-sample z -test ● To test a new hair-restoral treatment, I carry out a randomised doubled-blinded controlled experiment on 200 bald men. ● The treatment group of 100 men grew an average of 1.0 ounces of hair, with an SD of 0.8 ounces ● The control group of 100 men grew an average of 0.8 ounces of hair, with an SD of 0.4 ounces ● Can the higher average for the treatment group be explained by chance?

Review: the two-sample z -test ● The samples are like draws from a box with 200 tickets; each ticket has a “treatment” number and a “control” number ● We observe the treatment number for the treatment group and the control number for the control group ● Null hypothesis: the average of all the treatment numbers equals the average of all the control numbers

Review: the two-sample z -test ● SE of treatment average = 0.8/sqrt(100) = 0.08 ounces ● SE of control average = 0.4/sqrt(100) = 0.04 ounces ● SE of difference = sqrt(0. 2

2 ) = 0.0894 ounces ● z -statistic = (0.2 – 0)/0.0894 = 2.

Review: the two-sample z -test ● P( Z > 3.16) = 1.25% ● One-tailed P -value is 1.25% ● If the null hypothesis is true, the probability of a P -value this high or higher ● Reject the null hypothesis; the treatment works

Recall: the chi-square test ● If we have data in categories, and we wish to know if this data fits a null model, we calculate the chi-squared statistic: ● The degrees of freedom is the number of categories minus one ● We find the P -value from a chi-square distribution using a table or computer  2

observed frequency−expected frequency 2 expected frequency

Recall: independence ● Events A and B are independent if P(A and B) = P(A) * P(B) ● Equivalently: the probability of A is the same regardless of the outcome of B (and vice versa)

Example: handedness If gender and handedness are independent, how many of the 1067 men in the sample would you expect to be right-handed? ● Answer: 90% of them, or more precisely, 2004/22371067 = 934 ● Expect 205/22371067 = 113 left-handed ● Expect 28/2237*1067 = 13 ambidextrous Can do similar calculations for the sampled women

Example: handedness OBSERVED EXPECTED Men Women (^) Total Men Women (^) Total Right-handed (^934 1070) 2004 (^956 1048) 2004 Left-handed (^113 92) 205 (^98 107) 205 Ambidextrous (^20 8) 28 (^13 15) 28 TOTAL 1067 1170 2237 1067 1170 2237 How do we test whether or not any differences might be due to chance?

Example: handedness We calculate the chi-square statistic as previously: ● For each of the six entries in the table, compute then add the six results. ● What distribution will this test statistic have? observed frequency−expected frequency 2 expected frequency

Example: handedness ● In a chi-square test for independence for data in a table, degrees of freedom = (# rows – 1)(# columns – 1) ● Here, the chi-square statistic has a chi-square distribution with (3-1)(2-1) = 2 degrees of freedom

Method: the chi-square test for independence of two variables ● Null hypothesis is independence; alternative is dependence ● Draw up a table of the observed counts for each combination of categories of the two variables ● Find the subtotals for each category

Method: the chi-square test for independence of two variables ● Draw up a table of the expected counts for each combination of categories Expected counts can be found using the “expected percentage of right-handed men = percentage of right-handed people” heuristic, or as follows: OBSERVED EXPECTED A B C A B C a - - - a total a (A total)(a total)/(Grand total) etc. b - - - b total b (A total)(b total)/(Grand total) c - - - c total c (A total)*(c total)/(Grand total) A total B total C total Grand total