150 likes | 254 Views
Contingency Tables. Basic Concepts. 2 categories: (A (rows): possible outcomes A 1 , A 2 , … A r ; B (columns): possible outcomes B 1 , B 2 …, B c ) Assume the categories are independent unless it can be shown otherwise If categories are independent
E N D
Basic Concepts • 2 categories: (A (rows): possible outcomes A1, A2, … Ar; B (columns): possible outcomes B1, B2 …, Bc) • Assume the categories are independent unless it can be shown otherwise • If categories are independent • the probability that event ij occurs (that is Ai and Bj occur simultaneously) = P(Ai)P(Bj) • If there are n total observations, the total expected occurrences of event ij is eij = n*(P(Ai)P(Bj))
Best Estimates for P(Ai) and P(Bj) • From the sample suppose ni = number of times event Ai occurs and nj = number of times Bj occurs • Then, • P(Ai) ni/n and P(Bj) nj/n • Thus eij = n(ni/n)(nj/n) = ninj/n or,
Rowi Total Column j Total 82*80/524 Tables Suppose there were 524 total observations. 82 were observed to be A2 and 80 were observed to be B3. Observations (frequency, fij) Contingency Table entry e23 if H0 were true 12.51908
The Chi-Square Test • H0: Categories A and B are independent H1: Categories A and B are dependent • = .05 • Reject H0 (Accept H1) if 2 > 2.05,(r-1)*(c-1) • Check that all eij’s 5 • Then again, EXCEL: p-value for this test: =CHITEST(cells containing the fi’s, cells containing the ei’s)
=SUM(C4:G4) Drag down =SUM(C4:C7) Drag across Step 1: Determine row and column totals
2. Type Expected Values 3. Highlight the Frequency Table and Select Copy
=H4*C8/H8 6. In first cell put the formula for e11
7. In the formula bar for this cell: • Highlight the denominator (H8) and click the F4 function key to add $’s. • Since there is now a $ in front of the H and the 8, • Put another $ in front of the other H (H4===> $H4) • And put another in front of the other 8 (C8 ====> C$8)
8. Drag cell C13 down to cell C16 and highlight cells C13:C16.
9. Now drag cells C13:C16 across to cells G13:16. This is now the contingency table of expected values.
=CHITEST(Highlight C4:G7, Highlight C13:G16) 10. Calculate the p-value for the chi-square test .009731