Chi-Square Test Calculator

Enter observed counts, or a contingency table, to test whether they fit what you expect.

Contingency table
Rows
2
Columns
2

Observed counts, rows separated by semicolons, like 10, 20; 30, 40. At least 2 rows and 2 columns.

Significance levelα\alpha

How unlikely a result must be, if the null hypothesis were true, before it is rejected.

Try

Result

You enteredO=(10203040)O = \begin{pmatrix} 10 & 20 \\ 30 & 40 \end{pmatrix}

χ2=0.793651, df=1, p=0.372998, do not reject H0 at the 5% level\displaystyle \chi^2 = 0.793651,\ \text{df} = 1,\ p = 0.372998,\ \text{do not reject }H_0\text{ at the 5\% level}

p-value

0.372998\displaystyle 0.372998

Significance level

0.05\displaystyle 0.05

Decision

Do not reject H0\displaystyle \text{Do not reject } H_0
Show the work
  1. Null and alternative hypotheses

    The null hypothesis H0H_0 says the two variables are independent: knowing one tells you nothing about the other. The alternative hypothesis H1H_1 is what the test looks for, and it makes this a right-tailed test.

    H0:the variables are independentH1:they are associated\begin{gathered} H_0: \text{the variables are independent} \\ H_1: \text{they are associated} \end{gathered}
  2. Expected counts

    If the variables were independent, the count in row ii and column jj would be the row total RiR_i times the column total CjC_j, shared out over the grand total N=100N = 100. The row totals are 30, 7030,\ 70 and the column totals 40, 6040,\ 60.

    Using Eij=RiCjNE_{ij} = \frac{R_i C_j}{N}

    E=(12182842)E = \begin{pmatrix} 12 & 18 \\ 28 & 42 \end{pmatrix}
  3. Test statistic

    Add up (O−E)2E\frac{(O - E)^2}{E} over all 4 cells. The table has 2 rows and 2 columns, so ν=(r−1)(c−1)=1\nu = (r - 1)(c - 1) = 1 degrees of freedom.

    χ2=∑(O−E)2E=13+29+17+221=5063≈0.793651\begin{aligned} \chi^2 &= \sum \frac{\left(O - E\right)^2}{E} \\ &= \frac{1}{3} + \frac{2}{9} + \frac{1}{7} + \frac{2}{21} \\ &= \frac{50}{63} \approx 0.793651 \end{aligned}
  4. p-value

    The p-value is the probability, if H0H_0 were true, of a test statistic at least as extreme as the one observed. A chi-square test is always right-tailed: only a large statistic is evidence against the null hypothesis.

    p=P(χ12>0.793651)≈0.372998p = P\left(\chi^2_{1} > 0.793651\right) \approx 0.372998
  5. Decision

    Compare the p-value with the significance level α=0.05\alpha = 0.05: if p<αp < \alpha the result would be too unlikely under H0H_0, so reject it. Here it is not, so do not reject H0H_0: there is not enough evidence at the 5% level to say that the two variables are associated.

    p=0.372998, α=0.05, p≥α⇒do not reject H0p = 0.372998,\ \alpha = 0.05,\ p \ge \alpha \Rightarrow \text{do not reject } H_0
  6. Result

    So χ2≈0.793651\chi^2 \approx 0.793651, p=0.372998p = 0.372998, and the null hypothesis is not rejected at the 5% level.

Worked examples