Sub topic 8
Reading p-values and understanding error risk
A hypothesis test returns a p-value. The p-value is easy to compute and easy to misread. This chapter explains what it measures, what it does not measure, and which errors you can still make when it looks convincing. The goal is to decide, with a known level of risk, whether the data support your suspected root cause.
This chapter assumes you can run a two-sample t-test or a chi-square test, as in the previous chapter. It also assumes you know the null and alternative hypotheses and can read a basic Python script.
What a p-value measures
Every test starts from a null hypothesis (H0). In root cause work, H0 usually says the suspected cause has no effect. For example, "the defect rate is the same on shift A and shift B."
The p-value is the probability of seeing a difference at least as large as the one in your data, if H0 were true and the process behaved as the test assumes.
Read it as a measure of surprise. A small p-value means your data would be unusual in a world where the cause does nothing. That gives you a reason to doubt H0.
The p-value is not any of these:
- The probability that H0 is true. A p of 0.03 does not mean a 3% chance that the cause is irrelevant.
- The probability that your result happened "by chance" in a general sense.
- The size or importance of the effect. A tiny p-value can accompany a trivial difference.
- The probability that the result will repeat.
The calculation takes H0 as given and asks how well the data fit it. It does not assign a probability to H0 itself.
The significance level
Before looking at the data, you choose a significance level, written alpha. Most Six Sigma projects use 0.05. You then apply a fixed rule:
- If p < alpha, reject H0. The data are inconsistent enough with "no effect" that you treat the effect as real.
- If p ≥ alpha, fail to reject H0. The data do not give you enough evidence to claim an effect.
"Fail to reject" is not the same as "prove there is no effect." A small sample can hide a real difference. Absence of evidence is not evidence of absence.
Choose alpha before you collect or look at the data. If you pick it after seeing the p-value, you can make almost any result look significant.
Applying it to a real table
Here is the shift example from the topic. Shift B had 41 defective units out of 200. Shift A had 18 out of 200.
import numpy as np
from scipy import stats
# Rows: shift A, shift B. Columns: defective units, good units
table = np.array([
[18, 182],
[41, 159],
])
chi2, p, dof, expected = stats.chi2_contingency(table)
print(f"chi2 = {chi2:.2f}, dof = {dof}, p = {p:.4f}")
print("Expected counts if shift had no effect:")
print(expected)
alpha = 0.05
print("Reject H0" if p < alpha else "Fail to reject H0")The defect rates are 9% for shift A and 20.5% for shift B. SciPy applies a continuity correction to 2x2 tables by default. The statistic comes out near 9.6 with one degree of freedom, and p is about 0.002.
If shift had no effect, you would expect about 29.5 defective units in each shift. The result is not a 0.2% chance that shift is unrelated to defects. The correct reading is that a gap this large would occur in about 2 of 1,000 samples if the true defect rates were equal.
The two kinds of error
A test can be wrong in two ways. You do not know which situation you are in, so you manage the risk of each.
| Row | H0 is actually true (no real effect) | H0 is actually false (real effect) |
|---|---|---|
| Reject H0 | Type I error (false positive) | Correct decision |
| Fail to reject H0 | Correct decision | Type II error (false negative) |
- A Type I error means you blame a cause that is not real. Its probability is alpha, as long as the test's assumptions hold. You then spend the Improve phase fixing the wrong thing, and the real cause keeps producing defects.
- A Type II error means you drop a cause that is real. Its probability is called beta. Statistical power is 1 − beta, the chance of detecting an effect that exists.
The two risks trade off. Lowering alpha makes false positives rarer but, for a fixed sample, makes false negatives more likely. The next chapter shows how sample size lets you reduce beta without raising alpha.
You can see the Type I rate directly by simulating a world where H0 is true.
import numpy as np
from scipy import stats
rng = np.random.default_rng(42)
alpha = 0.05
trials = 10_000
false_positives = 0
for _ in range(trials):
# Both groups come from the same process: no real difference exists
a = rng.normal(loc=12.0, scale=0.5, size=8)
b = rng.normal(loc=12.0, scale=0.5, size=8)
if stats.ttest_ind(a, b, equal_var=False).pvalue < alpha:
false_positives += 1
print(f"Rejected H0 in {false_positives / trials:.3f} of {trials} trials")The printed rate lands close to 0.05. When nothing is going on, about 1 test in 20 still reports a "significant" difference. That is what alpha = 0.05 means.
A workflow for reading a result
The diagram shows the decision path. It adds a size check after the p-value.
Statistical significance is not practical significance
A p-value says whether a difference is detectable. It does not say whether it matters. With enough data, a very small difference becomes "significant."
Report the effect size and a confidence interval next to the p-value. Using the cycle time data from the previous chapter:
import numpy as np
from scipy import stats
setup_old = np.array([12.1, 11.8, 12.4, 12.0, 12.6, 11.9, 12.3, 12.2])
setup_suspect = np.array([13.0, 12.8, 13.4, 12.9, 13.1, 13.5, 12.7, 13.2])
result = stats.ttest_ind(setup_suspect, setup_old, equal_var=False)
diff = setup_suspect.mean() - setup_old.mean()
ci = result.confidence_interval(confidence_level=0.95) # SciPy 1.10 or newer
print(f"p = {result.pvalue:.4f}")
print(f"Mean difference = {diff:.2f} min")
print(f"95% CI for the difference: {ci.low:.2f} to {ci.high:.2f} min")The mean difference is about 0.91 minutes. The interval tells you how large the true gap plausibly is. Compare that range with what the process can tolerate. If a 0.9-minute increase pushes cycle time past the customer requirement, the cause matters. If the process has 10 minutes of slack, a significant p-value alone should not drive action.
Common mistakes
Testing many causes and reporting the winners
Suppose you test 10 suspected causes at alpha = 0.05, and none has any real effect. The chance that at least one appears significant is 1 − 0.95^10, about 40%. Fishbone diagrams often list many candidate causes, so this is a real risk.
Defend against it in three ways:
- Test only causes with a reason to suspect them, and state the hypothesis before looking at the data.
- Use a stricter alpha when you run many tests. A simple method divides alpha by the number of tests (the Bonferroni correction).
- Treat a surprising result from a large search as a lead to confirm with new data, not as a finding.
Stopping when the p-value turns significant
If you test after every new batch of data and stop once p < 0.05, you inflate the Type I rate well above 5%. Fix the sample size in your data collection plan and test once at the end.
Treating a high p-value as "no difference"
A p of 0.20 from 6 units per group says almost nothing. The test may have had very little power. Before you dismiss a cause, check how large an effect your sample could have detected.
Ignoring assumptions
The stated error rates hold only if the test fits the data. Independent observations, adequate measurement quality, and appropriate distributions all matter. Measurements that are correlated over time, such as consecutive units from one machine, break the independence assumption. They make p-values look smaller than they should be. Data with a bad gauge give a precise answer to the wrong question.
Reading one-sided and two-sided tests loosely
A two-sided test looks for a difference in either direction. A one-sided test looks in one direction only, and you must justify it before seeing the data. Switching to one-sided after the fact halves your p-value without any new evidence.
Choosing alpha in practice
Alpha is a risk decision, not a ritual. Consider the cost of each error:
- If a false positive is expensive, such as an expensive equipment change based on a wrong cause, use a smaller alpha like 0.01.
- If a false negative is expensive, such as missing a safety-related cause, accept a larger alpha like 0.10, and make sure the sample is large enough.
Write down the alpha and the reason in the project record. That makes the decision reviewable later.
What to record
For each test you run, log these items so a reviewer can follow your reasoning:
- The hypothesis in plain words, and the H0 and alternative.
- The chosen alpha and why.
- The test used and the assumptions checked.
- The sample sizes, the p-value, the effect size, and the confidence interval.
- The decision (reject or fail to reject) and what it means for the cause.
Exercise
A team tests five suspected causes of late deliveries, each at alpha = 0.05. Only the test on "carrier region" gives p = 0.03, and the other four give p above 0.30. A teammate says, "There is a 97% chance that carrier region is a real cause." Explain what is wrong with this statement and what the team should do next.
Show answer
The p-value is not the probability that the cause is real. A p of 0.03 means that, if carrier region had no effect, a difference this large would appear about 3% of the time. Because five causes were tested, the chance of at least one false positive is about 1 − 0.95^5, or 23%, so the 0.03 result is weaker than it looks. The team should treat carrier region as a lead. They should check the effect size and confidence interval for practical importance, consider a stricter alpha such as 0.05 / 5 = 0.01 (under which this result would not be significant), and confirm the cause with new data or a controlled trial before moving to Improve.
Exercise
A test of a suspected setup change uses 5 units per group and gives p = 0.18. The project lead concludes that the setup has no effect on cycle time. Which error could this conclusion involve, and what should be checked first?
Show answer
It could be a Type II error, a missed real effect. With only 5 units per group, the test may have had low power. The team should check the power of the test, or the smallest difference it could detect, and look at the confidence interval for the difference. If the interval is wide and includes differences that matter, the result is inconclusive. The next step is to collect more data according to a sample size plan.