Which hypothesis test should I use? A guide for engineers

Updated

The right hypothesis test follows from four questions: what kind of data you have (measurements, pass/fail results or counts), what you want to compare (an average, the variation, a proportion), how many groups are involved (one against a target, two, or more), and whether the samples are paired (the same parts measured twice) or independent. For example, measurements from two independent groups compared on their means call for a two-sample t-test; the same parts measured two ways call for a paired t-test. Getting the last question wrong is the most common and most costly mistake, as the worked example below shows.

The four questions

1. What kind of data?

  • Measurements on a continuous scale: diameter, weight, torque, temperature.
  • Pass/fail or categories: good or defective, defect type, supplier.
  • Counts of events over an amount of time, area or product: scratches per panel, alarms per shift.

2. What do you want to compare? Usually the mean (is the process centered?), but often the variation (is it more consistent?), a proportion (is the defect rate lower?) or the whole distribution (is it normal?).

3. How many groups? One group against a target or a claimed value, two groups against each other, or three or more.

4. Paired or independent? Data are paired when each value in one group has a natural partner in the other: the same part measured by two gages, the same operator before and after training, left and right sides of the same panel. They are independent when the groups are separate sets of units, such as parts from line 1 and parts from line 2.

The decision table

Measurements (continuous data)

QuestionUsual testIf the data are skewed or have outliers
Is the mean on target?1-sample t (1-sample Z if σ is known)Sign test or 1-sample Wilcoxon
Do two independent groups differ in mean?2-sample tMann-Whitney
Do paired measurements differ?Paired t1-sample Wilcoxon or sign test on the differences
Do three or more groups differ in mean?One-way ANOVAKruskal-Wallis or Mood's median
Several treatments tested on the same blocks?Two-way layout (general linear model)Friedman
Is the variation different?1 variance, 2 variances, equal variancesMethods such as Levene's or Bonett's, which do not assume normality
Are two processes equivalent within a margin?Equivalence tests

Pass/fail results and categories

QuestionTest
Is the defect rate different from a target or claim?1 proportion
Do two groups have different defect rates?2 proportions
Is the defect rate or the defect type related to line, shift or supplier?Cross tabulation and chi-square
Do counts by category match expected shares?Chi-square goodness of fit

Counts of events

QuestionTest
Is the event rate different from a target?1-sample Poisson rate
Do two processes have different event rates?2-sample Poisson rate
Do the counts follow a Poisson distribution?Poisson goodness of fit

Other questions

QuestionTool
Are the data normal?Normality test and probability plot
Is one value an outlier?Outlier test
Are two measurements related?Correlation, regression
Is the sequence random, or are there runs and trends?Runs test

Worked example: paired or independent?

A lab wants to know whether a new bore gage (B) reads the same as the reference gage (A). A technician measures the same eight parts with both gages:

Part12345678
Gage A (mm)10.1210.319.8710.0510.449.9610.2310.18
Gage B (mm)10.1510.339.9110.0610.489.9710.2710.20
B − A (mm)0.030.020.040.010.040.010.040.02

The wrong test: two-sample t. Treating the columns as two independent groups compares the means, 10.145 and 10.171 mm, against the spread between parts, a standard deviation of about 0.19 mm in each column:

The same eight parts measured with two gages10.010.210.4Bore diameter (mm)Gage AGage B
The same eight parts measured with two gages

The boxes overlap almost completely. The Welch two-sample t-test gives:

SE = √(0.18601²/8 + 0.19000²/8) = 0.09401 mm t = (10.17125 − 10.145) / 0.09401 = 0.279, df ≈ 14.0, p = 0.784

No evidence of a difference: the 95% confidence interval for B − A runs from −0.175 to +0.228 mm.

The right test: paired t. The parts are the same in both columns, so the part-to-part variation is not noise in this comparison; it cancels out in the differences. Gage B reads higher on all eight parts. The paired t-test works on the differences alone:

d̄ = 0.02625 mm, s_d = 0.013025 mm, SE = 0.013025 / √8 = 0.004605 mm t = 0.02625 / 0.004605 = 5.70, df = 7, p = 0.00074

The 95% confidence interval for the mean difference, with t(0.975, 7) = 2.3646, is 0.0154 to 0.0371 mm. Gage B reads about 0.026 mm high, which matters if the tolerance is a few hundredths of a millimeter.

Same data, opposite conclusions. The two-sample test buried a consistent 0.026 mm offset under 0.19 mm of variation between parts. The pairing is part of the design of the study, so the test must follow it. If you measure the same units twice, use a paired test; see paired t-test and, for gage comparisons in general, measurement system analysis.

Parametric or nonparametric?

t-tests and ANOVA compare means and assume roughly normal data within each group. They are fairly robust, especially with similar group sizes and more than 15 to 20 values per group. Nonparametric tests such as Mann-Whitney and Kruskal-Wallis work on ranks, so a few extreme values or a skewed shape affect them less, at the cost of some power when the data really are normal. Use them for small, clearly skewed samples, ordinal scores such as ratings from 1 to 5, or data with outliers you cannot explain away. A normality test and a look at a boxplot help decide.

Three or more groups: one test, not many

With four suppliers there are six pairs to compare. Running six separate t-tests at α = 0.05 raises the chance of at least one false alarm to roughly 1 − 0.95⁶ = 26% (the exact figure depends on how the comparisons overlap). A one-way ANOVA asks first whether any of the means differ, in one test. If it finds a difference, multiple-comparison methods then show which pairs differ while keeping the overall false-alarm rate at α.

Comparing variation

Engineers often care more about consistency than about the average: a new fixture that keeps the mean but halves the spread is a real improvement. Means tests do not see that. Use the 2 variances test for two groups or the test for equal variances for more. Variance tests that assume normality, such as the F-test, are very sensitive to non-normal data, so prefer methods that do not, such as Levene's or Bonett's.

Showing that two things are the same

A non-significant test does not show that a new supplier or a new machine is equivalent to the old one; it may just mean too few data. To claim sameness, define how big a difference would matter and use an equivalence test, which tests whether the difference is inside that margin.

Before choosing any test

  • Write down the question and the decision it supports, before collecting data.
  • Decide the smallest difference that matters and choose the sample size for it; see how many samples.
  • Plan the data collection so that it matches the test: pair when you can, randomize the order, record what could confound the comparison.
  • Look at the data before testing, with a boxplot or an individual value plot.
  • Report the effect size with a confidence interval, not only the p-value.

Frequently asked questions

When should I use a Z-test instead of a t-test?

Only when the process standard deviation is known from a long, stable history rather than estimated from the sample. In practice σ is almost always estimated, so the t-test is the usual choice. With large samples the two give nearly the same answer.

Should I use the pooled or the Welch two-sample t-test?

The Welch version, which does not assume equal variances, is the safer default. When the variances really are equal it loses very little; when they are not, the pooled version can give misleading p-values, especially with unequal group sizes.

What if my data are before-and-after measurements on different parts?

Then they are independent, not paired, even if the times match. Pairing requires the same unit, or a deliberate match, in both conditions. Use a two-sample test, or better, redesign the study to measure the same parts before and after if the change allows it.

Which test do I use for pass/fail data from three shifts?

A cross tabulation with a chi-square test, with shift in one direction and pass/fail in the other. With very small expected counts in some cells, use Fisher's exact test instead.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab