In Depth Notes on Chi-Square Tests
Module 5: Chi-Square Tests
Comparing Counts
- Covers 2 types of tests:
- (a) Goodness-of-fit tests for experiments with more than 2 categories.
- (b) Homogeneity and independence tests for contingency tables.
Goodness-of-Fit Test (Univariate Chi-Squared Test)
- Purpose: Checks if the frequency distribution of a categorical variable from a sample matches the model's expected distribution.
- Key Focus: Measures how well our data fits a predetermined model.
Hypothesis & Assumption (Goodness-of-Fit Test)
- Distribution: $p1, p2, …, p_k$.
- Hypotheses:
- $H0: p1 = p{01}, p2 = p{02}, …, pk = p_{0k}$
- $Ha: H0$ is not true.
- Assumptions and Conditions:
- (a) Counted Data Condition: Data must be counts for the categories of a categorical variable.
- (b) Independence Assumption: Counts in cells must be independent.
- (i) Randomization Condition: The sample must be a random selection from the population.
- (c) Sample Size Assumption:
- (i) Expected Cell Frequency Condition: Expect at least 5 counts in each cell.
Test Statistic (Goodness-of-Fit Test)
- Chi-square statistic ($ ext{χ}^2$):
extχ2<em>0=extexpectedcountsextsumofthesquaresofobserved−expectedcounts=extΣ</em>extallcategoriesE(O−E)2 - Note on Interpretation:
- If $O ext{ ≈ } E$, then $ ext{χ}^20$ is small, do not reject $H0$.
- If $O ext{ is large or significantly deviates from } E$, reject $H_0$.
Idea Behind the Test Statistic
- The chi-square statistic is intended for hypothesis testing, not for confidence intervals.
- Large statistics indicate the observed counts diverge significantly from the expected.
- p-value:
- pext−value=P(extχ2>extχ02) is the upper tail area for a distribution with degrees of freedom $c-1$.
- Decision Rule:
- If $p ext{-value} ext{ ≤ } ext{α}$, reject $H0$; if $p ext{-value} ext{ > } ext{α}$, do not reject $H0$.
Distribution of $ ext{χ}^2$
- The chi-square value follows a distribution characterized by degrees of freedom (df).
- For goodness-of-fit test, degrees of freedom are $c - 1$, where $c$ is the number of categories.
Example of Goodness-of-Fit Test
- Scenario: Proportion of beans in groups A, B, C, D should be $9:3:3:1$ based on a sample of 1600 beans: 882, 313, 287, and 118.
- Calculations:
- Null Hypothesis: Theory fits experiment well.
- Expected Counts:
- A: $rac{9}{16} imes 1600 = 900$; B: $rac{3}{16} imes 1600 = 300$; C: $rac{3}{16} imes 1600 = 300$; D: $rac{1}{16} imes 1600 = 100$.
- Calculate $ ext{χ}^2_0$:
=900(882−900)2+300(313−300)2+300(287−300)2+100(118−100)2=4.73
- Conclusion: $p ext{-value} > 0.05$, do not reject $H_0$.
Test of Homogeneity
- Compares distributions across two or more groups on the same categorical variable.
- Essentially generalizes the two-proportion z-test.
- Conditions:
- Similar assumptions as goodness-of-fit test: counted data condition, randomization condition, expected cell frequency condition.
Test Statistic and p-value for Homogeneity
- Calculate the $ ext{χ}^2_0$ as in goodness-of-fit test.
- Degrees of freedom: $(r-1)(c-1)$, where $r$ is the number of rows, $c$ is the number of columns.
Example of Homogeneity Test
- Scenario: Study on children's TV program preferences among 200 first graders (80 boys, 120 girls).
- Hypotheses:
- Null Hypothesis: Distribution of preferences is the same across boys and girls.
- Alternative Hypothesis: At least one preference distribution differs.
- Expected Counts Calculation: Based on row and column totals.
- Results: $p ext{-value} > 0.05$, do not reject $H_0$.
Chi-Square Test for Independence
- Evaluates the association between two categorical variables.
- Uses same calculations as homogeneity test—interpretation differs.
- Implies independence if the counts of one variable do not depend on the other.
Assumptions for Independence Test
- Need counts in each cell, expect counts to be at least 5.
- Sample must be a representative random sample.
Example: Independence Test
- Scenario: Study on hand vs foot lengths; right-handed vs left-handed participants.
- Set up null and alternative hypotheses regarding independence.
- Calculate $ ext{χ}^2_0$ and derive $p ext{-value}$.
Conclusion for Independence Test
- If $p ext{-value} < 0.05$, reject $H_0$, suggesting a relationship exists between the variables.