Chi-Square Test: Contingency Tables
Chi-Square Test: Contingency Tables
- Used to determine whether there is an association between two categorical variables.
- Example: Personality (Introvert, Extrovert) and Colour Preference (Red, Yellow, Green, Blue).
Application
- The Chi-Square test may be used to investigate the association between personality and colour preference.
- Note: The Chi-Square test may be used for ordinal data, but the test will treat the ordinal data as categorical. In R, it is possible to modify the Chi-Square test using the linear-by-linear option to ensure the order is taken into account.
Hypotheses
- Null Hypothesis (): There is no association between the variables.
- Alternative Hypothesis (): There is an association between the variables.
- The method is based on comparing observed frequencies with the frequencies you would expect to get by chance.
Test Statistic
For a table with rows and columns, the Chi-Square statistic is calculated as:
where:- represents the observed frequency.
- represents the expected frequency.
approximately follows a distribution with degrees of freedom.
Expected Frequencies
- The expected frequency is calculated as:
where:
- gives the row totals.
- gives the column totals.
- is the total number of observations.
Evaluation
- We evaluate using tables of distribution with degrees of freedom.
Yates' Continuity Correction
- For 2x2 frequency tables (where degrees of freedom, ), the Chi-Square test produces overly significant results (rejecting when it is true).
- In such cases, we apply Yates' Continuity Correction to the test statistic:
- Yates' continuity correction is also applied to the goodness-of-fit test when .
Effect Size: Strength of Association
Chi-Square tests do not tell us how strong an association is; therefore, consider effect size measures.
Phi Coefficient ():
- Used for 2x2 tables only.
- Guidelines:
- Small: 0.1
- Medium: 0.3
- Large: 0.5
Cramer's V:
- Can be used with 2 categorical variables when each variable has 2 or more categories.
where
. When , there is no association between the variables. only when the variables are equal to each other.
- Guidelines:
| dfv | Small | Medium | Large | ||
|---|---|---|---|---|---|
| 1 (2x2) | 0.1 | 0.3 | 0.5 | ||
| 2 | 0.07 | 0.21 | 0.35 | ||
| 3 | 0.06 | 0.17 | 0.29 | ||
| 4 | 0.05 | 0.15 | 0.25 | ||
| 5 | 0.05 | 0.13 | 0.22 | ||
Odds Ratio: | |||||
Consider the following table: | |||||
| Outcome A | |||||
| Outcome B | |||||
| Totals | |||||
| Group 1 | |||||
| Group 2 | |||||
| Totals | |||||
The odds ratio (OR) is given by:
Evaluation of Odds Ratio
- OR = 1: Belonging to Group 1 has not affected the odds of Outcome A.
- OR > 1: Belonging to Group 1 has increased the odds of Outcome A.
- OR < 1: Belonging to Group 1 has decreased the odds of Outcome A.
Post Hoc Tests
- If is significant ⇒ association between the variables, but it does not provide any specific information about the association.
- In R, we can use post hoc tests to investigate further. We will use the standardised residuals approach.
The Likelihood Ratio
- An alternative to the test uses a Model based on Maximum-likelihood theory.
L{x^2} = 2 \left{ \sum{i=1}^{r} \sum{j=1}^{c} y{ij} \ln \left( \frac{y{ij}}{E{ij}} \right) \right}
Evaluation of Likelihood Ratio
- Evaluate in the same way as .
- Example: Following Example 3.6, find .
- Again, . Do not reject \H_0 ⇒ there does not appear to be an association between Education Levels and Department.