Loading…

A Test of Independence

Statistics • Chi Square Tests

View all topics

Enter a contingency table of observed counts. The calculator computes expected counts, the χ² statistic, df, and the p-value (right-tailed). If you choose the test option, it also compares to a chosen significance level α.

Number of row categories (exclude totals).

Number of column categories (exclude totals).

The test of independence uses a right-tail χ² rejection region.

You can paste a labeled CSV below to auto-fill the table.

Observed counts (editable table)

Enter nonnegative counts. Totals are computed automatically.

Key formulas used

\[ \begin{aligned} df &= (R-1)(C-1) \\ E_{ij} &= \frac{(\text{row total}_i)(\text{column total}_j)}{n} \\ \chi^2 &= \sum \frac{(O_{ij}-E_{ij})^2}{E_{ij}} \end{aligned} \]
The p-value is computed as the right-tail area: \(\;p = P(\chi^2_{df} \ge \chi^2_{\text{obs}})\).
How to use
1) Build the table, 2) enter observed counts, 3) click Calculate. Use batch mode if you prefer pasting CSV.
Ready
χ² model visualization (right tail)
Blue shading shows the p-value region (right tail). Red shading shows the rejection region at level α.

Outputs

The results below include: expected counts, χ², df, and (if testing) the p-value and critical value.
Tip
Use Copy tables to paste into documents/spreadsheets.
Enter observed counts and click Calculate.
Batch mode: paste CSV (or paste from a CSV file)

Paste a contingency table as CSV. Supported formats:
A) Matrix only (numbers): each row is a category, each column is a category.
B) With labels: first row contains column labels and first column contains row labels.
Example (with labels): ,In Favor,Against,No Opinion Men,93,70,12 Women,87,32,6

Rate this calculator

0.0 /5 (0 ratings)
Be the first to rate.
Your rating
You can update your rating any time.

Frequently Asked Questions

What does a chi-square test of independence determine?

It tests whether two categorical variables are independent by comparing the observed contingency table to the expected table under independence. A small p-value suggests an association between the variables.

How are expected counts computed in a contingency table?

For each cell, the expected count is Eij = (row total i x column total j) / n, where n is the grand total. This is the expected frequency if the variables are independent.

What degrees of freedom are used for the chi-square independence test?

The test uses df = (R - 1)(C - 1), where R is the number of row categories and C is the number of column categories (excluding totals).

Why is the chi-square test of independence right-tailed?

The chi-square statistic is a sum of squared standardized differences, so it is always nonnegative. Larger values indicate larger departures from independence, so evidence against H0 is in the right tail.

What should I do if some expected counts are less than 5?

A common guideline is that expected counts should be at least 5 in every cell for the chi-square approximation to be reliable. If some expected counts are small, consider combining categories or increasing the sample size.