MECHOWL QUALITY ANALYSIS AI

Chi-Square Test of Independence Calculator: Paste a Contingency Table from Excel

Paste a contingency table such as line × defect type or machine × pass/fail to run the chi-square test of independence. You get the chi-square statistic, the degrees of freedom, the p-value, the expected counts and the adjusted residual of each cell, plus Fisher's exact test for a 2 × 2 table.

Last updated

Your data is not sent. Everything is computed in your browser

Data

Paste the table as it is in Excel (column names in the first row, row names in the first column, counts in the rest). With one record per row (e.g. two columns, line and defect type), choose the row variable and the column variable, and the page counts them into a table.

Read 3 rows and 5 columns.

What each column means

Guessed from the column names. Choose again if a guess is wrong.

When the contingency table is pasted as it is, the columns of counts (defect types, pass/fail …).

The names of the rows (lines, machines …).

With one record per row, the column of the classification for the rows (e.g. line).

The column of the classification for the columns (e.g. defect type, pass/fail).

A column saying how many items each row stands for. Without it, each row counts as one.

Line, part, machine, period … Select it to look at one value at a time.

Settings
More settings (Chart title, Period, Stratum)

Empty: "Chi-square test (contingency table)".

e.g. 1–31 Oct 2026. Written on the chart and the report.

Empty: all rows. A value: only the rows with that value.

Judgement rules

Decide the significance level and the alternative hypothesis before looking at the data. If you change them, write it in the report.

Usually 0.05 (5 %). The confidence interval is given at 1 − α (95 % for 0.05). Decide it before looking at the data.

The default is a common guideline (see —).

Result

p-value 0.0179: Significant association (α = 0.05)

Result of the sample data

Chi-square test (contingency table)n = 310 3 × 4 table χ² = 15.318 df = 6 p = 0.0179 Period: October 2026Chi-square test (contingency table)n = 310 3 × 4 table χ² = 15.318 df = 6 p = 0.0179 Period: October 2026ScratchDentDimensionOtherShare within each rowLine 142 %18 %25 %15 %Line 230 %35 %22 %13 %Line 335 %18 %36 %11 %0 %25 %50 %75 %100 %Adjusted residuals (▲ more than expected, ▼ fewer than expected: beyond ±1.96)ScratchDentDimensionOtherLine 11.65−1.59−0.830.76Line 2−1.39▲ 3.28−1.640.04Line 3−0.26−1.65▲ 2.41−0.78

Significant association (α = 0.05)

The classifications are called related (not independent) when p = 0.0179 is at most the significance level 0.05. A test result does not show the strength of the association or its cause.

p-value
0.0179
Chi-square statistic χ²
15.3181
Degrees of freedom
6

About the data

  • Data read as: the contingency table as it is.
  • The result has been checked to be the same as Excel's CHISQ.TEST without correction (CHISQ.TEST(actual_range, expected_range); make the range of expected counts as row total × column total ÷ grand total).

How to read it

What the chart shows

  • In the 3 × 4 table, the row and column classifications are related (not independent) at the significance level 0.05 (p = 0.0179).
  • Cells that depart from the expected counts (adjusted residual beyond ±1.96): Line 2 × Dent (more, 3.28); Line 3 × Dimension (more, 2.41).
  • The strength of the association (Cramér's V, 0 to 1) is 0.157.

Common misreadings

  • A small p-value does not mean a strong association. With many counts, even a weak association is significant. Judge the strength by Cramér's V and decide whether it matters in practice.
  • An association (dependence) does not show a cause. See which cells depart (adjusted residuals) and investigate the 4M of those combinations.

Next steps

  • For the combinations in the cells with more than expected (▲), such as a line and a defect type, look for differences in the work, the equipment and the material.

Numbers

p-value0.0179
Chi-square statistic χ²15.3181
Degrees of freedom6
Total count n310
Cells with an expected count under 50 / 12 (smallest 12.90)
Strength of association (Cramér's V) V0.157

Calculation steps
  1. Expected countsEᵢⱼ = row total × column total ÷ grand totale.g. Line 1 × Scratch: 100 × 110 ÷ 310 = 35.4839
  2. Chi-square statisticχ² = Σ (O − E)² / E= 15.3181
  3. Degrees of freedom and p-valueν = (rows − 1) × (columns − 1), p = P(χ²_ν ≥ χ²)ν = 6, p = 0.0179
  4. Adjusted residuals(O − E) / √( E × (1 − row total/n) × (1 − column total/n) ) (beyond ±1.96: a departure larger than chance)largest 3.28, smallest −1.65
Observed counts
ScratchDentDimensionOtherTotal
Line 142182515100
Line 230352213100
Line 338204012110
Total110738740310
Expected counts (※ under 5)
ScratchDentDimensionOther
Line 135.4823.5528.0612.90
Line 235.4823.5528.0612.90
Line 339.0325.9030.8714.19
Contribution of each cell to chi-square
ScratchDentDimensionOther
Line 11.1971.3070.3350.341
Line 20.8485.5691.3100.001
Line 30.0271.3452.7000.339
Adjusted residuals (▲ ▼ beyond ±1.96)
ScratchDentDimensionOther
Line 11.65−1.59−0.830.76
Line 2−1.39▲ 3.28−1.640.04
Line 3−0.26−1.65▲ 2.41−0.78

The results are reference values based on the data you entered and the formulas and criteria shown. They are not a quality guarantee or a pass/fail decision. The final decision rests with you.

Next tool: Compare two defect rates with the test of two proportions

References

  • NIST/SEMATECH e-Handbook of Statistical Methods, 7.4.5 How can we compare the results of classifying according to several categories? · NIST · Open
  • NIST/SEMATECH e-Handbook of Statistical Methods, 7.4.6 Do all the processes have the same proportion of defectives? · NIST · Open
  • JIS Z 8101-2:2015 Statistics — Vocabulary and symbols — Part 2: Applied statistics (in Japanese) · Japanese Standards Association (JSA)

Standards are shown by number and title only.

Chi-square test explained

The chi-square test of independence is a hypothesis test for a contingency table of counts by two classifications (line and defect type, machine and pass/fail …). It checks, with the chi-square distribution, whether the observed counts depart from the expected counts under independence (no relation between the classifications) by more than chance explains. The adjusted residuals show which cells depart.

Chi-square test by hand: the calculation step by step

  1. Tabulate the counts by the two classifications (rows and columns), and decide the significance level α (usually 0.05).
  2. Compute the expected count of each cell, E = row total × column total ÷ grand total. When many cells have expected counts under 5, combine categories, or for a 2 × 2 table use Fisher's exact test.
  3. Compute χ² = Σ (observed − expected)² ÷ expected and the degrees of freedom (rows − 1) × (columns − 1), and get the p-value from the chi-square distribution.
  4. If the p-value is at most α, the classifications are related (not independent); then look at the cells whose adjusted residuals are beyond ±1.96 (more or fewer than expected).

Worked examples

  1. Example 1: Two machines × three defect types

    Machine	Scratch	Dent	Dimension
    Machine 1	10	20	30
    Machine 2	20	20	20

    Row totals 60 and 60, column totals 30, 40 and 50, grand total 120. The expected counts are 15, 20 and 25 for both machines. χ² = (10−15)²/15 + 0 + (30−25)²/25 + (20−15)²/15 + 0 + (20−25)²/25 = 1.6667 + 0 + 1 + 1.6667 + 0 + 1 = 5.3333, degrees of freedom (2−1)(3−1) = 2, p = e^(−5.3333/2) = 0.069483 (the upper tail of the chi-square distribution with 2 degrees of freedom is e^(−x/2)).

  2. Example 2: 2 × 2 pass/fail table (no correction, Fisher)

    Machine	Defective	Good
    Machine 1	3	7
    Machine 2	8	2

    Expected counts 5.5, 4.5, 5.5 and 4.5 (the two cells of 4.5 are under 5). χ² = 2.5²/5.5 × 2 + 2.5²/4.5 × 2 = 2.2727 + 2.7778 = 5.0505, 1 degree of freedom, p = 0.024619. Fisher's exact test (margins fixed) gives a two-sided p = 0.069779, odds ratio = (3 × 2)/(7 × 8) = 0.107. With small expected counts, Fisher's value is the one to look at.

  3. Example 3: The same 2 × 2 table with Yates' correction

    Machine	Defective	Good
    Machine 1	3	7
    Machine 2	8	2

    Settings: Yates' continuity correction (2 × 2 only) = On

    In every cell |O − E| = 2.5 becomes 2.0. χ² = 2²/5.5 × 2 + 2²/4.5 × 2 = 1.4545 + 1.7778 = 3.2323, p = 0.0722 (larger than without the correction).

  4. Example 4: A cell with a count of 0

    Process	A	B
    Before	0	10
    After	5	5

    Expected counts 2.5, 7.5, 2.5 and 7.5 (the two cells of 2.5 are under 5). χ² = 2.5²/2.5 + 2.5²/7.5 + 2.5²/2.5 + 2.5²/7.5 = 2.5 + 0.8333 + 2.5 + 0.8333 = 6.6667, p = 0.009823. Fisher's two-sided p = 0.032508, odds ratio = (0 × 5)/(10 × 5) = 0 (with small expected counts, look at Fisher's value).

  5. Example 5: A row with a total of 0 (not computed)

    Line	A	B
    1	5	3
    2	0	0
    3	4	6

    Row 2 has a total of 0, so its expected counts are 0 and cannot be divided by. The page asks to remove that row.

  6. Example 6: Significance level out of range (input error)

    Line	A	B
    1	5	3
    2	4	6

    Settings: Significance level α = 1

    A significance level of 1 is not possible. The page asks for a value greater than 0 and less than 0.5.

Common mistakes

  • Trusting the chi-square p-value of a table with many small expected counts (under 5): the approximation no longer holds.
  • Testing a table of percentages (compute with counts; percentages lose the information of the totals).
  • Counting one item more than once (e.g. a part with two defects; each item goes into one cell only).

FAQ

Should I use Yates' continuity correction?
This page applies no correction by default. The correction makes chi-square smaller and the p-value larger (more conservative), and it is known to be too conservative at times. For a 2 × 2 table with small counts, Fisher's exact test (given on this page as well) is the safer one to look at.
Why do Fisher's exact test and the chi-square test give different p-values?
The chi-square test is an approximation for large counts; Fisher's exact test is the exact probability with the margins fixed. The smaller the counts, the larger the difference. When a cell has an expected count under 5, look at Fisher's value.
Does it give the same result as Excel's CHISQ.TEST?
Without correction, yes: the result has been checked against Excel's CHISQ.TEST (values computed in Microsoft Excel 16 agree to 15 digits). CHISQ.TEST(actual_range, expected_range) needs a range of expected counts, which you make separately as row total × column total ÷ grand total. Excel has no function for Yates' correction or Fisher's exact test (this page gives them).
Is my data sent anywhere?
No. The calculations and the chart are made in your browser only.

Scope

The chi-square test of independence of a contingency table (at least two rows and two columns), the adjusted residuals, and for 2 × 2 tables Fisher's exact test and Yates' correction.

Not covered by this tool:

  • Goodness-of-fit tests (against given proportions) and paired classifications (McNemar's test).
  • Exact tests of tables larger than 2 × 2.

Excel template: Chi-square test

A template with the column names and sample values only (no formulas). Enter your values, then copy the range and paste it into the box above.

Download the template (chi-square-template.xlsx)

Related tools

Request a tool (contact page of the official site)

Report

The company name and the other fields are kept on this device only.

Contact

We take enquiries on the contact page of the MechOwl official site. Requests for tools you would like are welcome there too.

To the contact page(opens in a new tab)