Test of Independence Calculators
0 calculators tagged with “Test of Independence”
All Calculators
No calculators found for this topic.
Chi-Square Test of Independence Formula
χ² = Σ [(O − E)² / E]
O = observed frequency; E = expected frequency = (row total × column total) / grand total.
Degrees of freedom: df = (rows − 1) × (columns − 1)
Step-by-Step Example
Does smoking status relate to lung cancer? Observed (2×2 table):
| Cancer | No Cancer | |
| Smoker | 40 | 60 |
| Non-smoker | 10 | 90 |
Row totals: 100, 100. Column totals: 50, 150. Grand total: 200.
Expected E(smoker, cancer) = (100×50)/200 = 25. E(smoker, no cancer) = 75. E(non-smoker, cancer) = 25. E(non-smoker, no cancer) = 75.
χ² = (40−25)²/25 + (60−75)²/75 + (10−25)²/25 + (90−75)²/75 = 9 + 3 + 9 + 3 = 24. df = 1. p < 0.001. Conclusion: significant association between smoking and cancer.
Assumptions
- All expected counts ≥ 5 (use Fisher's exact test for smaller expected counts)
- Observations are independent
- Data are categorical counts, not continuous
Glossary
Frequently Asked Questions
The chi-square test of independence tests whether two categorical variables are associated. It compares observed frequencies in a contingency table to expected frequencies calculated under the null hypothesis of independence (E = row total × column total / grand total). χ² = Σ[(O−E)²/E]; df = (rows−1)(columns−1). Large χ² → small p-value → reject independence. A significant result means the variables are associated; it does not tell you the direction or magnitude of the association (use odds ratio or Cramér's V for that).
Expected frequency for each cell = (row total × column total) / grand total. Example: in a 3×2 table, if row 1 total = 50, column 1 total = 40, grand total = 100: E(row1, col1) = (50 × 40)/100 = 20. All expected frequencies must be ≥ 5 for the chi-square approximation to be valid. If any E < 5, merge categories, use Fisher's exact test for 2×2 tables, or use a simulation-based test for larger tables.
Goodness of fit: tests whether one categorical variable matches a specified theoretical distribution (e.g., 3:1 Mendelian ratio). One variable; expected values from the theoretical model; df = categories − 1. Test of independence: tests whether two categorical variables in a contingency table are associated. Two variables; expected values from the marginal totals; df = (rows−1)(columns−1). Both use χ² = Σ[(O−E)²/E] but differ in how expected values are calculated and in the degrees of freedom formula.
A significant chi-square (p < 0.05) means there is evidence that the two variables are associated — their distribution is not independent. However, chi-square alone does not tell you: (1) the direction of the association; (2) the strength of the association; (3) which specific cells drive the significance. Follow up with: Cramér's V (effect size: V = √(χ²/n×min(r−1,c−1)) — ranges 0 to 1); standardized residuals for each cell (which cells deviate most from expected); and odds ratios for 2×2 tables (direction and magnitude of association).