Module 12 · Analyze
Correlation and regression
A scatter plot (Module 9) shows you there might be a relationship. Regression puts a number on it: a slope, an intercept, a measure of how much of the variation the relationship explains, and — just as important — a set of diagnostics that tell you whether to trust any of it. This module covers correlation and its traps, simple linear regression by hand and by script, residual analysis, an introduction to multiple regression with more than one predictor, and what R² does and does not tell you.
Learning objectives
- Explain what a correlation coefficient measures and the traps in reading it (linearity only, not causation, sensitive to range).
- Fit a simple linear regression by hand from summary sums and reproduce it with a script.
- Read a residual plot to check whether a linear model's assumptions hold.
- Fit and interpret a multiple regression with more than one predictor, including what "holding the other predictors constant" means.
- Explain why R² alone cannot tell you a model is correct, and what adjusted R² corrects for.
Why this matters
Anscombe's quartet, introduced in Module 1 and revisited for its graphical lesson in Module 9, has one more lesson to give here, the most directly relevant to this module: all four datasets produce the identical simple regression line (slope near 0.500, intercept near 3.00) and the identical R² (0.67), yet only one of the four is a case where that line is actually the right model.[2] A regression's summary numbers — slope, intercept, R², even the slope's own p-value — cannot tell you this by themselves. Residual analysis is the tool that can, and NIST's e-Handbook is blunt about the limits of the summary statistics alone: "a high R² value does not guarantee that the model fits the data well."[1]
The scenario below is a constructed illustration, not a real incident.
A team investigating braze fillet width finds a moderate correlation with furnace temperature and, pleased with an R² over 0.45, recommends a temperature-only process control limit and closes the investigation. A more complete model, adding two more readily available process variables, very nearly doubles the explained variation — and reveals that one of the two new variables the team assumed mattered (flux mass) actually does not, once temperature and joint gap are accounted for. Both the celebration after the first model and the assumption behind the second variable were premature; only the fuller regression, checked properly, sorts out which relationships are real.
Correlation and its traps
The Pearson correlation coefficient r measures the strength of a linear relationship only, on a scale from −1 (perfect negative) to +1 (perfect positive), with 0 meaning no linear relationship — not necessarily no relationship at all. Three traps recur constantly in practice: r can be near zero for a strong curved relationship (Anscombe's set 2 again); a real correlation does not establish which variable causes which, or whether a third, unmeasured variable drives both; and computing r over a restricted range of one variable (only the parts of a process that happen to have run recently, say) can understate or overstate the true relationship across the variable's full range.
Simple linear regression
b₁ = Sxy / Sxx = Σ(x−x̄)(y−ȳ) / Σ(x−x̄)² b₀ = ȳ − b₁x̄ Least squares: the line that minimizes the sum of squared vertical distances from each point to the line. b₁ is the predicted change in y per unit change in x; b₀ is where the line crosses x = 0, which may or may not be a meaningful point depending on whether x = 0 falls inside the range of the data.
The slope's own standard error, t-statistic and p-value (Module 11's logic applied to one coefficient) test whether the slope is distinguishable from zero — whether there is a linear relationship at all, not whether the model is a good one.[3]
Residual analysis
A residual is the difference between an observed y and the model's fitted value at that x: e = y − ŷ. NIST's e-Handbook treats a plot of residuals against fitted values (or against x) as the primary check of a regression model, ahead of any summary statistic: it should show no pattern — no curve (a sign the true relationship is not linear), no funnel shape (a sign the variance is not constant), no trend over the order the data was collected (a sign of a missed time-based effect), and residuals that look reasonably close to a normal distribution.[1] Any of these patterns means the model's own assumptions do not hold, and the p-values and confidence intervals it reports are not trustworthy even if R² looks respectable.
Multiple regression
Adding a predictor to a model can never decrease R² (it can only help the least-squares fit, or do nothing), which makes plain R² a poor way to decide whether a new predictor is worth keeping. Adjusted R² corrects for this by penalizing extra predictors relative to the residual degrees of freedom, and is the more honest number to watch when comparing models with different numbers of predictors.
What R² does and does not tell you
R² is the proportion of the variation in y explained by the fitted model. It does not tell you the model's functional form is correct (Anscombe's set 2 again: a curved relationship can still produce a large R² from a straight-line fit, or a small one, depending on the data). It does not tell you the relationship is causal. It does not by itself tell you whether the effect is practically significant — a very large sample can make a tiny, unimportant slope statistically significant with a small R², and a small sample can leave a practically important relationship statistically inconclusive. And it never falls when a predictor is added, which is exactly why R² alone is not a valid way to compare a simple model against a fuller one; that comparison needs adjusted R² or the F-test on the additional predictors, not R² on its own.
Worked examples
Worked example 1: residual plots, Anscombe's quartet revisited
Real data (Module 1, S-C28), the same four datasets, examined here through their residuals.
Module 1 introduced these four sets; Module 9 looked at their scatter plots. Here, the same regression line is fitted to each (slope ≈ 0.500, intercept ≈ 3.00, R² ≈ 0.67 for all four) and the residuals — what the scatter plot's departure from that line actually looks like, quantified — are plotted against x.
Set 1's residuals scatter with no visible structure — a straight line is a reasonable model. Set 2's residuals trace a clean parabola: the true relationship is curved, and the linear fit's errors are not random noise, they are the shape of the curve the line missed. Set 3 is dominated by a single point (residual 3.241, far above every other point on that panel); without it the remaining ten points would fall almost exactly on a line, and the "0.67 R²" the summary statistics report is really one outlier's doing. Set 4 shows why: ten points sit at the same x with no information about a slope at all, and the entire regression line — slope, intercept, R² — is determined by the single point at x = 19, whose residual is essentially 0.0 because the line is, in effect, drawn straight through it and the other ten points' mean. None of this is visible in the slope, the intercept, or R² alone; all of it is visible in thirty seconds of looking at the residuals.
Worked example 2: simple vs multiple regression, braze fillet width
The data below is a constructed example, not a real production run.
Braze fillet width (mm) at the header joint, 24 joints, three candidate predictors: furnace temperature (°C), flux mass (mg), and joint gap (mm). First, temperature alone.
Temperature alone explains R² = 0.477 of the variation in fillet width, about 48 %. Adding flux mass and joint gap:
| Term | Coefficient | SE | t | p | 95% CI |
|---|---|---|---|---|---|
| Intercept | -3.869 | 0.663 | -5.83 | 0.00001 | −5.253 to −2.486 |
| Temperature | 0.00853 | 0.00112 | 7.62 | 0.0000002 | 0.00619 to 0.01086 |
| Flux mass | 0.00616 | 0.00390 | 1.58 | 0.1295 | −0.00197 to 0.01429 |
| Gap | -1.083 | 0.212 | -5.10 | 0.00005 | −1.525 to −0.640 |
Adding two predictors nearly doubles the explained variation, from about 48 % to 77 % (R² = 0.773). Both temperature and gap are highly significant, and gap's coefficient is negative — a wider gap means a narrower fillet, which matches the physical picture of a fixed amount of filler metal bridging a larger opening. Flux mass, though, has a p-value of 0.129: not statistically significant at the conventional 5 % level, and its 95 % confidence interval comfortably includes zero. A team that measured only flux mass and fillet width, and computed just their simple correlation, could easily have seen a moderate relationship and assumed flux mass mattered; in the full model, controlling for temperature and gap, that apparent effect mostly evaporates. This is precisely what "holding the other predictors constant" buys: a fairer read of whether each variable earns its place, not just how each one looks in isolation.
Show the 24 braze joints (temperature, flux mass, gap, fillet width)
| temp | flux | gap | width | temp | flux | gap | width |
|---|---|---|---|---|---|---|---|
| 598.4 | 12.66 | 0.056 | 1.2469 | 598.2 | 10.72 | 0.055 | 1.1928 |
| 608.5 | 11.24 | 0.133 | 1.2768 | 602.3 | 13.1 | 0.11 | 1.2373 |
| 595.5 | 10.77 | 0.064 | 1.232 | 604.3 | 13.11 | 0.145 | 1.1518 |
| 591.2 | 13.73 | 0.122 | 1.1548 | 602.4 | 10.58 | 0.104 | 1.2116 |
| 596.2 | 10.21 | 0.094 | 1.1649 | 598.7 | 8.77 | 0.052 | 1.241 |
| 604.4 | 11.88 | 0.1 | 1.2173 | 598.8 | 12.99 | 0.108 | 1.2256 |
| 605.6 | 11.26 | 0.101 | 1.2633 | 602.9 | 10.99 | 0.098 | 1.2803 |
| 600.8 | 8.67 | 0.067 | 1.2537 | 608.4 | 11.34 | 0.119 | 1.2618 |
| 596.2 | 9.01 | 0.056 | 1.2166 | 591.0 | 11.05 | 0.062 | 1.1544 |
| 608.3 | 12.9 | 0.114 | 1.2513 | 591.8 | 8.22 | 0.117 | 1.0924 |
| 608.6 | 11.14 | 0.06 | 1.3406 | 605.2 | 11.08 | 0.143 | 1.2045 |
| 598.7 | 12.07 | 0.057 | 1.2416 | 599.2 | 8.58 | 0.072 | 1.1866 |
Worked example 3: a correlation that stratification reverses
The data below is a constructed example, not a real production run.
Setting: a powder coating line. Panels are sprayed through one of two spray nozzles, a standard nozzle (A) and a high-flow nozzle (B), and coating thickness is measured on each panel in micrometres. The high-flow nozzle lays down more material, so the line is run faster when it is fitted. Someone pulls 40 panels' records out of the system, pairs thickness against line speed, and fits a regression, without recording which nozzle sprayed which panel.
| speed | thickness | speed | thickness |
|---|---|---|---|
| 24.4 | 41.7 | 23.2 | 42.2 |
| 24.5 | 41.2 | 19.9 | 42.1 |
| 22.1 | 39.9 | 21.5 | 43.1 |
| 20.3 | 43.3 | 25.8 | 38.6 |
| 18.4 | 43 | 25.2 | 39.8 |
| 21.1 | 42.6 | 24.8 | 39.5 |
| 21.3 | 42.5 | 21.1 | 44 |
| 18.4 | 42.2 | 21.9 | 42.6 |
| 18.4 | 43.9 | 23.4 | 43.6 |
| 26 | 39.3 | 18.5 | 44.8 |
| speed | thickness | speed | thickness |
|---|---|---|---|
| 34.4 | 58.6 | 35.7 | 56.9 |
| 32.2 | 59.9 | 30 | 60.6 |
| 37 | 55.6 | 34 | 58.1 |
| 30.5 | 60 | 33.5 | 57.4 |
| 35.4 | 58.5 | 31.6 | 60.3 |
| 37 | 55.8 | 32.6 | 57.5 |
| 31.8 | 59.5 | 36.4 | 55.3 |
| 37.2 | 56.1 | 32.5 | 57.6 |
| 37 | 56.8 | 31.2 | 60.7 |
| 30.1 | 59.9 | 35.6 | 56.7 |
Pooling all 40 panels and fitting one line gives a strong, highly significant positive relationship:
r = 0.835, R² = 0.697, slope p-value 0.000000000, residual s = 4.645 µm Read literally: every extra metre per minute of line speed buys about 1.08 µm of coating. An engineer who wanted a thicker coat and believed this number would speed the line up.
Now fit the same relationship separately within each nozzle:
| Fit | n | Slope (µm per m/min) | r | R² | Slope p-value | Mean speed | Mean thickness |
|---|---|---|---|---|---|---|---|
| Pooled, nozzle ignored | 40 | 1.0762 | 0.835 | 0.697 | 0.000000000 | 27.90 | 50.04 |
| Nozzle A only | 20 | -0.5202 | -0.763 | 0.581 | 0.000093 | 22.01 | 42.00 |
| Nozzle B only | 20 | -0.6339 | -0.895 | 0.800 | 0.000000103 | 33.79 | 58.09 |
Both within-nozzle slopes are negative, both are statistically significant, and both agree with the physics: at a higher line speed a panel spends less time in front of the gun, so it receives less powder. The pooled slope has the opposite sign, and it is the more significant of the three. Nothing is wrong with the arithmetic in any of the three fits. What is wrong is the question the pooled fit answers.
The mechanism is visible in the last two columns of Table 4. Nozzle A runs at a mean speed of 22.01 m/min and lays 42.00 µm; nozzle B runs at 33.79 m/min and lays 58.09 µm. The pooled line is not measuring what line speed does to thickness at all. It is drawing a line between two nozzles that differ in both variables at once, and the nozzle is doing all the work. This is the continuous-data form of Simpson's paradox: a relationship within every subgroup that reverses when the subgroups are combined.
The defence is not statistical, it is procedural, and Module 9 already named it: stratify before you fit. Any variable that could plausibly shift both x and y — nozzle, machine, shift, batch of raw material, operator, gauge, season — is recorded with the data and used to split it. If the split changes the answer, the split was the answer. A lurking variable that was never recorded cannot be stratified on afterwards, which is why the operational definitions and data collection sheet of Module 5 matter more to a regression than any of the arithmetic in this module. The multiple regression of Worked example 2 is the other tool for the same problem: had the nozzle been recorded as an indicator variable and put in the model alongside speed, the fit would have reported the within-nozzle slope and the nozzle offset separately, which is the honest decomposition of Figure 3's right panel.
Common mistakes
- Fitting a regression without ever looking at the scatter plot first. Consequence: Anscombe's quartet, again — identical regression output, at least one of the four datasets is the wrong model for its data. Fix: Module 9's discipline applies here directly; plot before fitting.
- Trusting R² alone and skipping the residual plot. Consequence: a curved relationship, a funnel-shaped variance, or a time trend can all sit underneath a respectable-looking R² and go unnoticed. Fix: always plot residuals against fitted values before trusting any regression output.
- Reading a correlation or a regression coefficient as proof of causation. Consequence: acting on a relationship driven by a third, unmeasured variable, or by reverse causation, produces a "fix" that does not fix anything. Fix: causal claims need a designed experiment (Module 13) or strong process knowledge, not a regression coefficient by itself.
- Interpreting a multiple regression coefficient the same way as a simple regression slope. Consequence: reporting "a 1 mg increase in flux mass changes fillet width by b" when b is actually "holding temperature and gap constant" is a different, narrower claim, and conflating the two overstates what the model says. Fix: state the "holding other predictors constant" qualifier every time.
- Using plain R² to decide whether an added predictor is worth keeping. Consequence: R² can only rise or stay flat when a predictor is added, even a useless one, so it always looks like an improvement. Fix: compare adjusted R², or test the added predictor's own coefficient directly.
- Assuming a predictor matters because its simple correlation with y is large. Consequence: Worked example 2's flux mass has a real, moderate simple correlation with fillet width, but is not a statistically significant predictor once temperature and gap are in the model — its apparent effect was substantially explained by its association with the other two variables. Fix: check a predictor's significance in the full model you intend to use, not its marginal correlation alone.
- Extrapolating a fitted line or surface outside the range of the data used to fit it. Consequence: the intercept and slope describe the fitted range; nothing guarantees the same relationship holds outside it, and a process pushed to a new operating point can behave completely differently. Fix: state the range the model was fitted over, and treat any prediction outside it as an extrapolation, not a result.
Exercises
Exercise 1: wire-bond pull strength vs bond force and bond time
Constructed example, not a real production run.
Wire-bond pull strength (N), 20 bonds, two candidate predictors: bond force (g) and bond time (ms). Tasks. (a) A simple regression of pull strength on bond force alone gives R² = 0.876. Predict, before computing, whether adding bond time will raise R² even if bond time turns out to matter very little. (b) Fit the multiple regression and report both coefficients' p-values. (c) Does bond time earn its place in the model, statistically? Compare this result with Worked example 2's flux mass.
Show the worked solution
(a) R² must rise by at least a small amount regardless, because adding any predictor to a least-squares fit can never decrease R². The real question is whether it rises by enough to matter, and whether adjusted R² agrees.
(b) Force: coefficient 0.0949, p 0.000000000. Time: coefficient 0.0313, p 0.003. R² = 0.928, R²adj = 0.919.
(c) Yes: bond time's p-value (0.003) is well under 0.05, and adjusted R² rose along with plain R² (from the one-predictor model's adjusted R² of 0.869 to 0.919), not just plain R² alone. This is the opposite outcome from Worked example 2's flux mass: there, a second predictor's simple relationship with y turned out not to hold up once the other predictors were in the model; here, bond time's effect is real and statistically supported even after controlling for bond force. The two examples together are the point: adding a predictor always raises R² a little, but only checking its own coefficient and adjusted R² tells you whether that rise means anything.
Show the 20 wire bonds (force, time, pull strength)
| force | time | strength | force | time | strength |
|---|---|---|---|---|---|
| 45.4 | 30.0 | 8.15 | 52.6 | 25.3 | 9.0 |
| 58.5 | 20.6 | 8.72 | 46.1 | 17.3 | 8.1 |
| 34.3 | 24.7 | 6.8 | 39.9 | 27.5 | 7.29 |
| 58.5 | 34.6 | 9.33 | 53.7 | 30.5 | 9.12 |
| 39.4 | 34.2 | 7.3 | 39.1 | 27.3 | 7.33 |
| 42.7 | 29.5 | 7.83 | 43.6 | 33.3 | 8.31 |
| 54.8 | 25.8 | 8.93 | 34.0 | 15.8 | 6.5 |
| 42.3 | 20.5 | 7.7 | 42.1 | 25.6 | 8.07 |
| 46.5 | 18.2 | 7.85 | 36.1 | 24.2 | 7.18 |
| 30.8 | 34.4 | 7.07 | 37.9 | 16.2 | 6.79 |
Exercise 2: a correlation of almost zero over a strong relationship
Constructed example, not a real production run.
Setting: lap-shear strength (MPa) of a structural adhesive joint against cure temperature (°C), 18 joints cured at temperatures spread across the supplier's stated 120 to 180 °C window, one joint per temperature, pulled to failure on a load frame reading to 0.01 MPa.
| temp | strength | temp | strength |
|---|---|---|---|
| 128 | 22.23 | 165 | 23.8 |
| 129 | 22.65 | 165 | 23.73 |
| 129 | 21.91 | 170 | 23.01 |
| 132 | 22.31 | 170 | 22.52 |
| 140 | 23.25 | 170 | 21.63 |
| 146 | 24.29 | 171 | 22.62 |
| 151 | 23.93 | 176 | 21.54 |
| 155 | 22.9 | 177 | 21.42 |
| 161 | 23.32 | 177 | 22.22 |
Tasks. (a) Fit a simple linear regression of strength on temperature and report the slope, r, R² and the slope's p-value. (b) On that evidence alone, what would you conclude about whether cure temperature affects strength? (c) Plot the residuals against temperature and say what the plot shows. (d) State what an r of nearly zero does and does not license you to say, and what you would do next.
Show the worked solution
(a) Slope -0.0070 MPa per °C, r = -0.146, R² = 0.0213, slope p-value 0.563, residual s = 0.875 MPa. The line is flat and the fit explains about 2 % of the variation.
(b) On the linear fit alone the temptation is to conclude "cure temperature does not affect strength, so we can cure anywhere in the window." That conclusion is wrong, and the exercise exists to make the error concrete. A p-value of 0.563 is not evidence of no effect; it is a failure to find a linear effect, and the null hypothesis being tested is about the slope of a straight line, nothing more (Module 11: never read a large p-value as proof of no difference).
(c) The residuals form a clean inverted parabola: negative at both ends of the temperature range and positive in the middle. That is the signature of a relationship with an optimum, and a straight line is the wrong model for it. Fitting temperature and its square as two predictors (Module 12's multiple regression, with temperature² simply computed as a second column) gives R² = 0.691, adjusted R² = 0.650, F(2, 15) = 16.79 with p = 0.000149, residual s = 0.5074 MPa, and both terms significant (temperature p = 0.000045, temperature² p = 0.000042). The quadratic's maximum sits at −b₁ / 2b₂ = 151.1 °C, near the middle of the window, and the residual standard deviation falls from 0.875 to 0.5074 MPa.
(d) An r of nearly zero licenses one statement: over this range, there is no useful straight-line relationship between these two variables. It does not license "there is no relationship", "temperature does not matter", or "cure anywhere in the window." What to do next: plot the raw scatter (Module 9's rule, which would have shown the curve before any arithmetic), then treat the cure temperature as a factor with an interior optimum, which is a response surface question rather than a regression one — Module 13's introduction to response surface methods is exactly the tool, and the practical answer for the process is to set the cure at the top of the curve and specify a window around it, not to leave the supplier's full range open.
Quiz
Ten questions. Score 70 % or more to mark the module complete on this device.
Answer key
- c. No strong linear relationship; a curve can still exist.
- b. Check whether the model's assumptions hold.
- d. A clear parabola.
- a. Change in y per unit x, holding others constant.
- c. Never decreases.
- b. Penalizes extra predictors.
- d. Not significant once temperature and gap are included.
- a. Causation.
- c. An extrapolation.
- b. A high R² does not guarantee a good fit.
Key takeaways
- Correlation measures only linear association, does not establish causation, and can be distorted by the range of data examined.
- Simple linear regression's least-squares line and its slope's significance test are computable by hand from summary sums and reproduced exactly by script.
- Residual plots (against fitted values or x) are the primary check of a regression model's assumptions; a respectable R² does not mean the model is correct.
- Multiple regression coefficients hold the other predictors constant, a genuinely different quantity from a simple-regression slope on the same variable alone.
- R² never falls when a predictor is added, even a useless one; adjusted R² corrects for the number of predictors and is the fairer number for comparing models.
- A predictor's simple correlation with the outcome can look meaningful and still not be a significant predictor once other, related variables are in the model.
References
All web sources accessed 2026-09-09 unless noted.
- NIST/SEMATECH. e-Handbook of Statistical Methods, 4.4.4 "How can I tell if a model fits my data?". NIST. https://www.itl.nist.gov/div898/handbook/pmd/section4/pmd44.htm
- Anscombe, F. J. (1973). Graphs in statistical analysis. The American Statistician, 27(1), 17–21. Values as reproduced in Wikipedia and the R
datasetspackage documentation (Module 1, S-E35, S-E36). https://www.sjsu.edu/faculty/gerstman/StatPrimer/anscombe1973.pdf - NIST/SEMATECH. e-Handbook of Statistical Methods. NIST, 2012 (updated). https://www.itl.nist.gov/div898/handbook/
- Montgomery, D. C. (2019). Introduction to Statistical Quality Control, 8th ed. Wiley. https://www.wiley.com/en-us/Introduction+to+Statistical+Quality+Control,+8th+Edition-p-9781119399308 (catalogue-level; general regression reference, further reading)
- ASQ. Certified Six Sigma Green Belt (CSSGB) Body of Knowledge Map 2014–2022. ASQ, 2022. https://www.asq.org/cert/resource/pdf/certification/2022-CSSGB-BoK-Map.pdf (the Green Belt scope this module is written against; no single claim rests on it)