Test of Independence Calculators

0 calculators tagged with “Test of Independence

The chi-square test of independence assesses whether two categorical variables are statistically associated or independent. It is applied to a contingency table (cross-tabulation) of observed frequencies and compares them to expected frequencies that would occur if the variables were independent. The test statistic is χ² = Σ[(O−E)²/E], where O is observed and E is expected. A significant result (p < 0.05) means the variables are associated; non-significant means there is insufficient evidence to reject independence. It is one of the most widely used statistical tests in the social sciences, medical research, and biology.

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):

CancerNo Cancer
Smoker4060
Non-smoker1090

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

Chi-Square Test of Independence
χ² = Σ[(O−E)²/E]; tests whether two categorical variables in a contingency table are associated; df = (rows−1)(columns−1); significant result = variables are not independent.
Expected Frequency (E)
The cell frequency predicted if the two variables were independent: E = (row total × column total) / grand total; must be ≥ 5 in all cells for valid chi-square approximation.
Cramér's V
Effect size for chi-square test of independence: V = √(χ²/n×min(r−1,c−1)); ranges 0–1; small ~0.1, medium ~0.3, large ~0.5; measures strength of association independent of sample size.

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