01

Inverting a fitted line

A simple linear regression gives you y = mx + b. Predicting x from a target y is straightforward algebra: subtract the intercept, divide by the slope.

Inverse equationx = (y − b) / m
equivalently  x = (1/m)·y − b/m

The inverse is also a straight line, with slope 1/m and intercept −b/m. Both are shown in the result panel so you can write the inverse model down directly.

02

The catch: two different regressions

Inverting the fitted line is not the same as fitting x on y. Ordinary least squares minimises vertical distances, so swapping the axes changes which distances are minimised and produces a different line.

The two approaches
MethodMinimisesResult
Regress y on x, then invertvertical residualsslope 1/m
Regress x on y directlyhorizontal residualsa shallower or steeper line
Both agree only whenr = ±1perfect linear fit

Regression to the mean. Inverting a y-on-x model systematically under-predicts extreme x values when the correlation is imperfect. For prediction, fit the direction you actually need.

03

Worked example

A model fitted to house data gives price = 2 × area + 1 (in whatever units). To find the area that produces a price of 9, invert: x = (9 − 1)/2 = 4.

The check line recomputes 2 × 4 + 1 = 9, confirming the inversion. That verification matters: a sign error in the intercept is easy to make and produces a plausible-looking wrong answer.

04

Practical cautions

  • Stay inside the data range. Inverting a regression line to predict far outside the observed x values is extrapolation and is unreliable.
  • Check the slope is not near zero. A flat line cannot be inverted — the tool rejects m = 0 outright, but m = 0.001 will produce enormous and meaningless x values.
  • Report the uncertainty. A prediction interval for x is not the mirror of the one for y; it needs its own calculation.
05

Which line to invert

There are two regression lines through the same data: one that minimises vertical distances and one that minimises horizontal distances. They are different lines unless the correlation is perfect.

The two least-squares lines
LineMinimisesInverting it gives
y on xVertical residualsA different line from x on y
x on yHorizontal residualsA different line from y on x
Both, when r = ±1Nothing — they coincideThe same line

The gap between them grows as the correlation weakens. At r = 0.9 the two lines are close enough that the choice rarely matters; at r = 0.5 it changes the prediction substantially. Whichever line you invert, say which one it was.

?

Frequently asked questions

How do I predict x from y using a regression line?

Rearrange y = mx + b into x = (y − b)/m. For y = 2x + 1 and a target of 9, x = 4.

Is this the same as regressing x on y?

No. Inverting a y-on-x fit and fitting x-on-y directly give different lines unless the correlation is perfect, because the two methods minimise different residuals.

What if the slope is zero?

Then the line is horizontal and no x value corresponds to a given y — the inverse does not exist. The tool reports an error.

Why is the inverse slope the reciprocal?

Because slope is rise over run. Swapping the axes swaps rise and run, so the new slope is the old one inverted.

Can I invert a multiple regression?

Not with a single formula. With several predictors you must solve a linear system, and the answer is generally a plane or hyperplane rather than a line.