How does one measurement move with another — and is a straight line the right shape?
Fit a line to two measurements — with the residual plot beside it, never behind a toggle, because the fit succeeds whether or not a straight line was ever the right shape.
Regression & Correlation · analyze · Green Belt
Use this when
- You suspect a process input drives an output and want to know how much
- Somebody has quoted an R-squared and you want to know what the data actually looks like
- You need to predict a value at a setting you have measured around
Regression & Correlation
sandboxpicking time = 3.2597 + 0.4297 x lines on the order
Over the range in this data, picking time rises by about 0.4297 for each one-unit increase in lines on the order (p < 0.001), and the data is consistent with a slope anywhere from 0.3918 to 0.4676. The line accounts for 96.9% of the variation in picking time, and typical points miss it by about 0.7424 in the units of picking time. A fitted line describes how these two columns moved together in this data. It is not evidence that one causes the other: the same line appears when the causation runs the other way, and when something not in the data drives both. Deciding causation needs an argument regression cannot supply — usually a change made deliberately, with everything else held still.
Slope
0.4297
R²
0.9692
Adjusted R²
0.9675
r
0.9845
- Slope SE
- 0.0180
- t
- 23.818 on 18 df
- p
- p < 0.001
- 95% interval on the slope
- 0.3918 to 0.4676
- Correlation interval
- 0.960 to 0.994
- Residual std error
- 0.7424
Show the data behind these charts
| Row | lines on the order | picking time | Fitted | Residual | Leverage | Cook’s D |
|---|---|---|---|---|---|---|
| 1 | 6 | 5.4 | 5.838 | -0.438 | 0.186 | 0.049 |
| 2 | 9 | 7.7 | 7.127 | 0.573 | 0.138 | 0.055 |
| 3 | 11 | 8.5 | 7.987 | 0.513 | 0.111 | 0.034 |
| 4 | 14 | 9.4 | 9.276 | 0.124 | 0.081 | 0.001 |
| 5 | 17 | 9.9 | 10.565 | -0.665 | 0.060 | 0.027 |
| 6 | 19 | 12.4 | 11.425 | 0.975 | 0.053 | 0.051 |
| 7 | 22 | 12.4 | 12.714 | -0.314 | 0.050 | 0.005 |
| 8 | 24 | 12.9 | 13.573 | -0.673 | 0.055 | 0.025 |
| 9 | 27 | 14.6 | 14.862 | -0.262 | 0.070 | 0.005 |
| 10 | 29 | 16.8 | 15.722 | 1.078 | 0.086 | 0.108 |
| 11 | 31 | 16.9 | 16.581 | 0.319 | 0.107 | 0.012 |
| 12 | 34 | 18.5 | 17.871 | 0.629 | 0.147 | 0.072 |
| 13 | 7 | 6.7 | 6.268 | 0.432 | 0.169 | 0.041 |
| 14 | 12 | 6.8 | 8.416 | -1.616 | 0.100 | 0.293 |
| 15 | 16 | 10 | 10.135 | -0.135 | 0.066 | 0.001 |
| 16 | 21 | 12.9 | 12.284 | 0.616 | 0.050 | 0.019 |
| 17 | 26 | 14.5 | 14.433 | 0.067 | 0.064 | 0.000 |
| 18 | 30 | 16.8 | 16.152 | 0.648 | 0.096 | 0.045 |
| 19 | 33 | 16.7 | 17.441 | -0.741 | 0.132 | 0.087 |
| 20 | 36 | 17.6 | 18.73 | -1.13 | 0.179 | 0.309 |
Checks on the fit
- ClearIs a straight line the right shape?No curvature detected (quadratic term p = 0.608). Still look at the residual panel: this tests for a bend, not for every shape.
- ClearDo the residuals change sign as often as chance would?13 runs from 11 above and 9 below the line (p = 0.454). Consistent with chance — but this test is underpowered at these sample sizes and misses curvature that is plain on the plot, so it clears far more than it should.
- ClearIs any point far out in lines on the order?No point exceeds a leverage of 0.200, so no single lines on the order value dominates the fit.
- ClearWould removing one row change the answer?No row has a Cook’s distance above 1. The conclusion does not rest on any single observation.
A fitted line describes how these two columns moved together in this data. It is not evidence that one causes the other: the same line appears when the causation runs the other way, and when something not in the data drives both. Deciding causation needs an argument regression cannot supply — usually a change made deliberately, with everything else held still.
lines on the order first, then picking time. Commas or tabs; a header row is detected.
Load Anscombe’s quartet
Four datasets with the same slope, intercept, R² and correlation. Load each in turn and watch the residual panel — it is the only thing that changes.
How this is calculated
- The line is ordinary least squares: slope = Sxy/Sxx, intercept = ȳ − slope·x̄. Inference on the slope uses t = slope/SE on n − 2 degrees of freedom.
- Leverage hi = 1/n + (xi − x̄)²/Sxx, flagged above 2p/n. The leverages always sum to 2, the number of parameters.
- Cook’s distance measures how far the fitted line moves when a point is deleted, flagged above 1. Where leverage is exactly 1 it is reported as undefined rather than as zero — the point is fitted perfectly because it alone determines that part of the line, which is total influence, not none.
- Curvature is tested by adding a quadratic term and testing its coefficient. A runs test on the residual signs is weaker: on Anscombe’s second set, an exact parabola, it gives p = 0.067 and would be waved through, while the quadratic term gives p below 10⁻¹⁵.
- The correlation interval uses Fisher’s z-transformation, so it cannot run past ±1 the way a symmetric interval on r does.
- Below 6 pairs the tool refuses. R² is close to 1 by construction at that size and the residuals cannot show whether a straight line was ever the right shape.
Source: Anscombe, F.J. (1973), ‘Graphs in Statistical Analysis’, The American Statistician 27(1), 17–21; Montgomery, D.C., Peck, E.A. and Vining, G.G., Introduction to Linear Regression Analysis 5e, Ch. 2 and Ch. 4; Cook, R.D. (1977), Technometrics 19(1), 15–18.
How this is calculated
Ordinary least squares: slope = Sxy/Sxx, intercept = ybar - slope*xbar. Inference on each coefficient by t = estimate/SE on n-2 degrees of freedom, with confidence intervals from the exact t distribution. R-squared is reported alongside adjusted R-squared. The correlation interval uses Fisher's z-transformation so it cannot run past +/-1. Three diagnostics run automatically: leverage h = 1/n + (x-xbar)^2/Sxx flagged above 2p/n; Cook's distance flagged above 1, and reported as undefined rather than zero where leverage is exactly 1; and curvature tested by adding a quadratic term, fitted on the part of x-squared orthogonal to x so the coefficient and its t match the full three-parameter fit. A runs test on residual signs is also reported and labelled underpowered, because on an exact parabola of eleven points it returns p = 0.067. Prediction gives both a prediction interval for a single new observation and the narrower interval for the mean response, and flags any x outside the fitted range as extrapolation.
Source: Anscombe, F.J. (1973), 'Graphs in Statistical Analysis', The American Statistician 27(1), 17-21; Montgomery, D.C., Peck, E.A. and Vining, G.G., Introduction to Linear Regression Analysis 5e, Ch. 2 and Ch. 4; Cook, R.D. (1977), Technometrics 19(1), 15-18.
Learn the method
- Two things move together. Now what?Green Belt · 15 min · free
- What the fitted line is hidingGreen Belt · 15 min · free