Checking why reversed regression slopes need not be reciprocals
Fitting y on x and fitting x on y give two different lines. This guide uses three points to show that the reversed slope is not the reciprocal of the first one.
Two regressions, two questions
Ordinary least squares picks the line that makes the squared vertical distances from the points to the line as small as possible. Vertical means in the direction of the response variable. If you regress y on x, the residuals are measured along y. If you regress x on y, they are measured along x. These are different minimization problems, so they generally produce different lines. The calculator uses slope = sum((x - xbar)(y - ybar)) / sum((x - xbar)²) and intercept = ybar - slope × xbar, with the variable in the denominator being the predictor. Which variable plays the predictor is a choice you make before the calculation.
The three-point control
Take x = 0, 1, 2 and y = 0, 2, 1. Both means are 1. The deviations of x are -1, 0, 1 and those of y are -1, 1, 0. The cross products add up to 1 + 0 + 0 = 1, and the squared deviations of x add up to 2. The slope is 1/2 = 0.5, and the intercept is 1 - 0.5 × 1 = 0.5. So y is predicted as 0.5 + 0.5x. The points do not lie on a line: at x = 1 the line gives 1, while the observed y is 2. That gap is what makes the control useful, because a perfect line would hide the difference between the two regressions. The fitted line leaves residuals of -0.5, 1 and -0.5 at x = 0, 1 and 2, which sum to zero, as least-squares residuals with an intercept always do. Their squares add up to 0.25 + 1 + 0.25 = 1.5, the smallest total any straight line can achieve for these three points when errors are measured along y.
Fitting in the other direction
Now swap the roles. The old y list becomes the predictor and the old x list becomes the response. In the calculator that means entering x as 0, 2, 1 and y as 0, 1, 2, which keeps the same three points paired the same way. The means are again 1. The cross products again add up to 1, and the squared deviations of the new predictor are 0, 1 and 1, which add up to 2, so the slope is 0.5 and the intercept is 0.5. The numbers match the first fit only because both lists have the same spread here, which is a feature of this small example. If the slope of the reversed fit were the reciprocal of the first, it would be 2. It is 0.5. Algebraically inverting the first line, solving y = 0.5 + 0.5x for x, gives x = 2y - 1, which is a different line from the refit.
What connects the two slopes
The two slopes are linked through the correlation coefficient r. The product of the slope of y on x and the slope of x on y equals r². Here r² = 0.25, and 0.5 × 0.5 = 0.25. The product equals 1 only when r² = 1, which means the points lie exactly on a line, and only then are the slopes reciprocals. The less correlated the data, the smaller the product, and the further the two slopes are from being reciprocal. Both slopes always have the same sign, since each is the covariance divided by a positive variance. In the five-point example below, one slope is 0.6 and the other 1, and their product 0.6 gives r² directly, so the correlation is about 0.775. You can therefore recover the strength of the relation from the two fitted slopes alone, which is a handy cross-check when a report lists both fits.
A five-point example
Take x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5. The means are 3 and 4. The cross products sum to 6, the squared x deviations sum to 10 and the squared y deviations to 6. Regressing y on x gives slope 0.6 and intercept 2.2. Regressing x on y gives slope 6/6 = 1 and intercept 3 - 1 × 4 = -1. The reciprocal of 0.6 would be about 1.667, not 1. The product of the slopes is 0.6, and r² = 36/60 = 0.6, so the relation holds. The data are positively related but scattered, and the two lines have visibly different steepness when plotted on the same axes.
When the points lie on a line
If the points are exactly collinear, the two regressions agree. For x = 0, 1, 2 and y = 1, 3, 5, the fit of y on x is y = 1 + 2x, with slope 2. The fit of x on y is x = -0.5 + 0.5y, with slope 0.5 and intercept -0.5. Now the slopes are reciprocals, 2 and 1/2, and the lines coincide. This is the special case people often generalize from. It is a fair rule of thumb only for nearly perfect relationships, and it fails as the scatter around the line grows.
Why the direction should be chosen first
Pick the response variable from the question you want answered, not from the layout of the spreadsheet. If you want to predict y from x, regress y on x. If you want to predict x from y, regress x on y. For example, calibrating an instrument sometimes involves predicting a true value from a reading, and the direction chosen changes the correction. Reversing a fitted equation algebraically answers a different question than refitting. Francis Galton described this effect in the 1880s as regression toward the mean, when he observed that extreme parents had children closer to average, whichever generation was used as the predictor.
Alternatives when neither variable is a response
When both variables are measured with error and neither is a response, a regression that minimizes vertical distances can understate the true slope. Methods such as total least squares, orthogonal regression or Deming regression minimize distances in both directions and treat the variables more symmetrically. They need extra assumptions, such as the ratio of the error variances, and they are not what this calculator does. The linear regression calculator here is ordinary least squares in the direction you set, with the formula shown above.
Limits of the control
The three points are a teaching control, not a data set to draw conclusions from. A line through three points says little about any real relationship, and the example makes no claim about prediction, causation or fit quality. Its job is narrow: show with numbers you can check by hand that the slope of the reversed regression is not the reciprocal of the first. State which variable is predicted whenever you report a slope, because a slope without that statement is ambiguous.
Reproduce the checks
Predict y from x
Open the Linear Regression Calculator and enter:
- X observations
0,1,2- Y observations
0,2,1
Expected output:
Slope
0.5Intercept
0.5The response residuals are measured along y.
Predict x from y
Open the Linear Regression Calculator and enter:
- X observations
0,2,1- Y observations
0,1,2
Expected output:
Slope
0.5Intercept
0.5The response direction has changed.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.
Sources
- Primary definition and convention reference ↗ · 2026-10-08