Week 1, Day 3 Part 2-Contingency Tables and Probability Analysis
Overview and Definition of Contingency Tables
Definition: A contingency table is a statistical tool used to display the number of cases (frequencies) for combinations of two categorical variables.
Primary Function: These tables help in identifying relationships or associations between different categories.
Example Categories:
Biological Sex (Male vs. Female)
Animal Preference (Cats vs. Dogs)
Structure of a Contingency Table
A table is the most basic form of a contingency table, tracking two outcomes across two groups.
Cell Layout:
Group 1: Contains values (Outcome A) and (Outcome B).
Group 2: Contains values (Outcome A) and (Outcome B).
Margins:
Row Totals: The sum of the frequencies across a row. For Group 1, the total is . For Group 2, the total is .
Column Totals: The sum of the frequencies down a column. For Outcome A, the total is . For Outcome B, the total is .
Grand Total (): The sum of all cases in the table, calculated as .
Key Concept: The margins specifically show the totals for each individual row or column variable.
Case Study: Study Habits vs. Pass Rate
This example involves a class of students, categorized by study duration (greater than/equal to vs. less than ) and exam result (Pass vs. Not Pass).
Table Data:
Studies : Pass, Not Pass, Total = .
Studies < 6\,\text{hrs}: Pass, Not Pass, Total = .
Column Totals: Total Pass = , Total Not Pass = .
Grand Total: .
Marginal, Joint, and Conditional Probabilities
Marginal Probabilities: These summarize each variable separately by looking at the totals in the margins relative to the grand total.
Proportion of students who passed:
Proportion of students who study :
Joint Probabilities: These represent the intersection of two events, or the likelihood of two conditions being met simultaneously.
Probability of a student studying AND passing:
Probability of a student studying < 6\,\text{hrs} AND not passing:
Conditional Probabilities: This is defined as the probability of one subgroup (event) occurring, given the knowledge of a specific group (condition).
Pass Rate given :
Pass Rate given < 6\,\text{hrs}:
Simpson’s Paradox and Data Aggregation
Definition: Simpson's Paradox occurs when combining data from different groups results in a misleading or counterintuitive conclusion compared to analyzed individual groups.
Hiring Process Example:
Department A Statistics: Hired, Not Hired, Total Applicants.
Department B Statistics: Hired, Not Hired, Total Applicants.
Aggregated Data: Total Hired, Total Not Hired, Total Overall Applicants.
Hiring Rates per Department:
Overall Hiring Rate Analysis:
Observation: The combined hiring rate () is numerically between the individual department rates ( and ). However, aggregation can mask the extreme differences between the groups.
Analytical Takeaway: It is critically important to analyze data by considering underlying groups rather than relying solely on aggregated totals.
Key Takeaways
Contingency tables effectively summarize the relationships between two categorical variables.
Marginal, joint, and conditional probabilities offer distinct views of the same dataset and should be calculated to understand the data's nuances.
Analysts must be vigilant regarding confounding results (such as Simpson's Paradox) that can lead to incorrect data interpretations.