Sub topic 11
Correlation is not causation: confounders and lurking variables
This chapter assumes you can read a scatter plot, know what a correlation coefficient and a simple regression line are, and have run a hypothesis test such as the t-test or chi-square test from earlier chapters. It also assumes you already hold a suspected root cause X for a defect or delay Y from a fishbone diagram or 5 Whys.
Why a strong association is not enough
A test result like "defect rate is higher on shift B, p = 0.001" tells you the groups differ. It does not tell you why. Statistical tests measure association: whether X and Y move together more than chance would explain. A root cause claim is stronger. It says that changing X changes Y.
If you move to Improve on an association alone, you may adjust something that has no effect on the defect. The real cause keeps running, and your team loses credibility.
Four reasons X and Y can move together without X causing Y
| Explanation | What is happening | Process example |
|---|---|---|
| Confounding | A third variable Z influences both X and Y | Humidity affects both the line speed operators choose and the defect rate |
| Reverse causation | Y influences X, not the other way round | Operators slow the line after defects appear, so slow speed correlates with defects |
| Chance | The pattern appears in this sample but not in the process | A small sample, or many comparisons run until one is significant |
| Selection or mixing of groups | The data covers groups that differ in other ways | Comparing a tool used mostly on hard parts with a tool used mostly on easy parts |
Confounding is the most common of these in process data, so the rest of the chapter concentrates on it.
Confounders and lurking variables
A confounder is a variable that influences both the suspected cause X and the outcome Y. A lurking variable is a confounder nobody has measured or even thought of. The two terms overlap: a confounder you did not record is lurking.
The diagram shows the structure. The dashed line is the apparent link between X and Y. It exists in the data only because Z drives both.
Process data is especially exposed to this problem. Most of it is observational: you recorded what happened, and nobody assigned X at random. Operators, planners, and the environment choose X values for reasons. Those reasons often also affect Y.
A worked example with simulated data
In this simulation, humidity affects both line speed (operators slow down in humid conditions) and defects. Line speed has no effect on defects. The code shows that the raw correlation is strong anyway, and that it disappears once humidity is accounted for.
import numpy as np
rng = np.random.default_rng(42)
n = 200
# Z: humidity, the confounder
humidity = rng.normal(50, 8, n)
# X: line speed depends on humidity, not on anything related to defects
line_speed = 100 + 0.8 * (humidity - 50) + rng.normal(0, 3, n)
# Y: defect rate depends on humidity only; line speed has no effect
defect_rate = 2 + 0.15 * (humidity - 50) + rng.normal(0, 0.8, n)
def residuals(y, x):
"""Part of y left over after removing its linear relationship with x."""
slope, intercept = np.polyfit(x, y, 1)
return y - (slope * x + intercept)
r_raw = np.corrcoef(line_speed, defect_rate)[0, 1]
# Partial correlation: correlate what is left after removing humidity from both
r_partial = np.corrcoef(
residuals(line_speed, humidity),
residuals(defect_rate, humidity),
)[0, 1]
print(f"Raw correlation, speed vs defects: r = {r_raw:.2f}")
print(f"Correlation controlling for humidity: r = {r_partial:.2f}")The raw correlation comes out clearly positive, while the partial correlation sits near zero. The pattern to remember is this: when a suspected cause loses its effect after you control for a third variable, the third variable was doing the work.
The method has limits. It removes only the linear influence of variables you measured. If humidity acts non-linearly, or the true confounder was never recorded, the leftover correlation can still mislead.
Simpson's paradox: when pooling reverses the story
A confounder can do more than weaken an effect. It can reverse the apparent direction. This is Simpson's paradox: a comparison that favours one group in every stratum favours the other group when the strata are pooled.
Suppose a team suspects that Tool Y causes more defects than Tool X. They count defects over 200 parts per tool.
| Part type | Tool X: defects / units | Tool X rate | Tool Y: defects / units | Tool Y rate |
|---|---|---|---|---|
| Simple parts | 18 / 180 | 10% | 1 / 20 | 5% |
| Complex parts | 8 / 20 | 40% | 54 / 180 | 30% |
| All parts | 26 / 200 | 13% | 55 / 200 | 27.5% |
Pooled, Tool Y looks more than twice as bad. Within each part type, Tool Y is better. The reason is that planners assigned most complex parts to Tool Y, and complex parts are inherently harder. Part type is the confounder. It influences both which tool is used and the defect rate.
Stratifying by the suspected confounder, as in the earlier chapter on stratification, is the quickest way to catch this. When an overall result and the stratified results disagree, report the stratified result and investigate why the groups differ.
Practical ways to handle confounders
You have four main tools, in roughly increasing strength.
- List candidate confounders before analysis. Use the fishbone diagram again. For each suspected cause X, ask which other inputs vary alongside it. Typical culprits are shift, operator, material lot, machine, season, product type, and time of day.
- Record them with the data. A confounder you did not collect cannot be controlled in the analysis. Add these columns to the data collection plan.
- Control for them in analysis. Stratify by the confounder, compare like with like, or use partial correlation or multiple regression. All of these only handle variables you measured.
- Break the link by design. Hold the confounder constant (run only on one material lot), or assign X at random so that no other variable can systematically track it. Randomisation is the only approach that also handles confounders you never thought of. The later chapter on confirmatory experiments covers this.
Checking reverse causation and time order
A cause must come before its effect. Before accepting a link, check the time order in your data.
- Does X change before Y changes? Timestamps on both measurements make this checkable.
- Could operators be reacting to Y by changing X? A reaction pattern shows X moving after defects rise, not before.
- If the data is only a single snapshot with no time order, say so explicitly in your findings. You cannot rule out reverse causation from such data.
A run chart with both variables on the same time axis is often enough to expose a reaction pattern.
Weighing the evidence for causation
No single test proves causation from observational data. Instead, build a case from several lines of evidence.
- Time order: X precedes Y.
- Strength and consistency: the association is large and appears in different shifts, lines, or periods.
- Dose response: more of X goes with more of Y, in a steady pattern.
- Mechanism: you can explain, from engineering or process knowledge, how X could change Y.
- Confounders addressed: the association survives stratification and adjustment for the plausible alternatives.
- Reversibility: when X is changed back, Y follows. This is the strongest of the observational signs, and it is close to an experiment.
If most of these hold, the cause is plausible and worth a confirmatory trial. If several fail, treat the root cause as unverified.
Common mistakes
- Mining for correlations. Testing dozens of variable pairs and acting on the one with the smallest p-value produces false positives. With 20 independent tests at a 0.05 significance level, you expect about one false alarm.
- Trusting a high r-squared. A high r-squared shows the regression line fits. It says nothing about whether X is the cause.
- Extrapolating beyond the data. A relationship observed between 90 and 110 units per minute may not hold at 130.
- Treating "no correlation" as "no cause". A confounder can also hide a real effect, for example when two opposing influences cancel. Absence of association does not prove absence of causation either.
- Controlling for the wrong variable. Do not adjust for a variable that sits between X and Y on the causal path (a mediator). Doing so removes part of the real effect.
Exercise
A team finds that lines running with the new coolant have a lower scrap rate (p = 0.003). Looking closer, the new coolant was only used on Line 2, which is also the newest line with the best-maintained tooling. Name the confounder, explain why the result does not yet verify the coolant as the cause, and give two ways to test it fairly.
Show answer
The confounder is the line, together with its tooling condition. It influences both which coolant is used (new coolant appears only on Line 2) and the scrap rate (Line 2 may scrap less for reasons unrelated to coolant). The coolant effect and the line effect are mixed together, so the p-value shows an association but cannot assign the lower scrap to the coolant. Two fair tests: (1) run a controlled trial that alternates old and new coolant on the same line, ideally assigning the coolant to production runs at random, so tooling condition is the same for both; (2) if a trial is not possible, compare the coolants within other lines or time periods where both were used, and check whether Line 2's scrap was already lower before the new coolant was introduced.
Exercise
In the Tool X versus Tool Y table above, a manager says "Tool Y has a 27.5% defect rate and Tool X has 13%, so we should drop Tool Y." Using the stratified numbers, give the strongest reply and say what you would check next.
Show answer
Within simple parts Tool Y has a 5% defect rate against 10% for Tool X, and within complex parts 30% against 40%, so Tool Y is better in both strata. The pooled gap exists because Tool Y was used mostly on complex parts, which have higher defect rates whatever the tool. Dropping Tool Y would likely increase defects. Next, check why complex parts were assigned to Tool Y, and whether other factors (operator, material, shift) differ between the tools. Confirm with a trial that assigns tools to parts at random within each part type.