Test of Independence

1 min read Updated Fri Apr 24 2026 03:19:45 GMT+0000 (Coordinated Universal Time)

Used when two categorical variables are measured on the same sample. Tests if there is a relationship between the variables.

Suppose a table of rr rows and cc columns, containing observed data, is provided. Observed values are dentoed by OijO_{ij}.

Hypotheses

H0:There is no association between the two variables.H_0 : \text{There is no association between the two variables.}

H1:There is a significant association between the two variables.H_1 : \text{There is a significant association between the two variables.}

Degrees of freedom

ν=(r1)(c1)\nu = (r - 1)(c - 1)

Expected Frequency

Eij=(Row total)×(Column total)Grand totalE_{ij} = \frac{(\text{Row total}) \times (\text{Column total})}{\text{Grand total}}

Test Statistic

χcalc2=(OijEij)2Eijχν2\chi_{\text{calc}}^2 = \sum \frac{(O_{ij} - E_{ij})^2}{E_{ij}} \quad \sim \chi^2_\nu

H0H_0 is rejected if χcalc2>χν,α\chi_{\text{calc}}^2 \gt \chi_{\nu,\alpha}.