Sub topic 3
Comparing three or more means with ANOVA
This chapter assumes you know two-sample t-tests, p-values, and the purpose of the Analyze phase in DMAIC.
Comparing three or more means with ANOVA
Running several t-tests on three groups raises the chance of a false alarm. One-way ANOVA (analysis of variance) tests all group means in one step. Its null hypothesis says every mean is equal. A small p-value means at least one mean differs.
import numpy as np
from scipy import stats
rng = np.random.default_rng(7)
line_a = rng.normal(100, 5, 25)
line_b = rng.normal(102, 5, 25)
line_c = rng.normal(105, 5, 25)
f_stat, p_anova = stats.f_oneway(line_a, line_b, line_c)
print("ANOVA p =", p_anova)When assumptions fail: non-parametric tests
Kruskal-Wallis is a rank-based test. It replaces ANOVA when the data are clearly skewed or the samples are very small.
Discrete data: proportion tests and chi-square
When Y is a count, such as defective or good parts, use a proportion test for one or two groups. Use a chi-square test of association to compare proportions across more groups. Check that each expected count is at least 5. Otherwise the p-value is unreliable.
Continuous X and continuous Y: correlation and regression
Pearson correlation (r) measures the strength of a straight-line relationship, from -1 to +1. Simple linear regression estimates how much Y changes per unit of X. Test the slope's p-value before you trust it.
How much data is enough: sample size and power
Power is the probability of detecting a real difference, usually set to 0.8. A medium effect (Cohen's d = 0.5) at alpha 0.05 needs about 64 samples per group.
Statistically significant is not always worth acting on
A large sample can make a tiny difference statistically significant. Before the study, agree with the project team on the smallest difference worth acting on. Report the size of the difference along with the p-value.
Multiple comparisons and common pitfalls
After a significant ANOVA, comparing every pair of groups with separate t-tests inflates the error rate. Use a correction such as Tukey's test. Also, a p-value is not the probability that the null hypothesis is true. Decide the sample size before collecting data, rather than stopping when the p-value looks good.
Exercise
Three suppliers deliver parts with the same mean diameter target. Why run one ANOVA instead of three t-tests?
Show answer
Three t-tests each carry a 5% false-alarm risk, so the chance of at least one false alarm across all three is about 14%. One ANOVA keeps the overall risk at the chosen alpha of 5%.