Calculators
Home › Calculators › Regression Equation

Regression Equation Calculator

The equation itself, with every symbol earning its place.

Build the regression equation

Paired data in; equation, fitted values and residuals out.

Quick answer: b = Sxy / Sxx = 57 / 10 = 5.7; a = y-mean - b x-mean = 38.2. Equation: y-hat = 38.2 + 5.7x, R-squared 0.991, residual SD about 1.0.

Anatomy of the regression equation

Every simple regression ends in one line of algebra: ŷ = a + bx. Three symbols do the work. The ŷ (read "y-hat") is the predicted value: what the model says, distinct from the y you actually observe. The a is the intercept, the height where the line crosses the Y axis. The b is the slope, the predicted change in Y per unit of X. Everything else in a regression printout exists to judge how much trust this equation deserves.

Worked example

Study hours to marks gives ŷ = 38.2 + 5.7x. The fitted values it produces: at 2 hours, 49.6 (actual 50, residual +0.4); at 4 hours, 61.0 (actual 60, residual −1.0); at 6 hours, 72.4 (actual 72, residual −0.4). Slope in a sentence: each additional hour predicts 5.7 more marks. Intercept in a sentence: the model starts the line at 38.2 marks for zero hours, a bookkeeping anchor, since nobody in the data studied zero hours and the real relationship may curve long before that point.

Using the equation well

Plug in X values inside the observed range and the equation interpolates: reasonable predictions with the residual SD (here about 1.0 marks) as the typical error. Plug in X values outside the range and you are extrapolating on credit. Also check the equation against the plot: the same equation can describe a tight cloud or a loose one, and R² (here 0.991) is the number that tells you which.

Watch out

Swapping the variables and reusing the equation. The regression of marks on hours is not the algebraic rearrangement of the regression of hours on marks. The two slopes differ (their product is r²), because each minimizes misses in its own direction. Decide what you are predicting, then fit that way.

Where the numbers come from

b = Sxy ÷ Sxx: here 57 ÷ 10 = 5.7. Then a = y-mean − b × x-mean = 61 − 5.7 × 4 = 38.2, which forces the line through the centre of the data. Two formulas, nothing hidden. The calculator above runs them on your data and shows the same working.

Frequently asked questions

What does y-hat mean?

The predicted value of Y from the equation, marked with a hat to separate it from observed values. The gap between y and y-hat for a data point is its residual.

How do I write the regression equation from calculator output?

Take the intercept as a and the slope as b: y-hat = a + bx, with the numbers rounded to a sensible precision (two or three significant figures beyond the data's own).

Can the intercept be negative?

Yes. It means the fitted line crosses the axis below zero. For outcomes that cannot be negative, that is a sign the line should not be read near X = 0, not a calculation error.

What is the regression equation for the reverse direction?

A different equation: regressing X on Y minimises horizontal misses. Fit the direction you intend to predict; the two are linked through r but are not rearrangements of each other.