# 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.

## Presentation on theme: "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."— Presentation transcript:

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 – the probability that event ij occurs (that is A i and B j occur simultaneously) = P(A i )P(B j ) –If there are n total observations, the total expected occurrences of event ij is e ij = n*(P(A i )P(Bj))

Best Estimates for P(A i ) and P(B j ) From the sample suppose n i = number of times event A i occurs and n j = number of times B j occurs Then, –P(A i ) n i /n and P(B j ) n j /n Thus e ij = n(n i /n)(n j /n) = n i n j /n or,

Tables Suppose there were 524 total observations. 82 were observed to be A 2 and 80 were observed to be B 3. Contingency Table entry e 23 if H 0 were true 82*80/524 Rowi Total Column j Total Observations (frequency, f ij ) 12.51908

The Chi-Square Test H 0 : Categories A and B are independent H 1 : Categories A and B are dependent =.05 Reject H 0 (Accept H 1 ) if 2 > 2.05,(r-1)*(c-1) Check that all e ijs 5 Then again, EXCEL: p-value for this test: =CHITEST(cells containing the f i s, cells containing the e i s)

Step 1: Determine row and column totals =SUM(C4:G4) Drag down =SUM(C4:C7) Drag across

2. Type Expected Values 3. Highlight the Frequency Table and Select Copy

4. Put cursor in cell below Expected Values and click Paste

5. Highlight entries in new table and click Delete

6. In first cell put the formula for e 11 =H4*C8/H8

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.

10. Calculate the p-value for the chi-square test =CHITEST(Highlight C4:G7, Highlight C13:G16).009731

Download ppt "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."

Similar presentations