What Is Least Squares Regression Line?
The least squares regression line is the straight line ŷ = a + bx that makes the sum of squared vertical distances from the points as small as possible. It is the standard way to fit a line to paired data.
The slope is b = Sxy ÷ Sxx, or r × sy ÷ sx if you only have summary statistics. The intercept is a = ȳ − b·x̄, which forces the line through the point of means.
Choose raw data or summary mode, enter your values, and optionally add an x value to predict y.
How to Use the Least Squares Regression Line Calculator
- Choose raw data or summary statistics.
- Enter the values. For summary mode you need both means, both standard deviations and r.
- Read the slope, intercept and equation, and add an x value if you want a prediction.
Least Squares Regression Line Formula
Slope
Intercept
Least Squares Regression Line Variables Explained
| Symbol | Meaning | Notes |
|---|---|---|
| b | Slope of the line | r × sy / sx |
| a | Intercept | ȳ − b·x̄ |
| r | Correlation coefficient | |
| ŷ | Predicted value of y | a + bx |
Least Squares Regression Line Worked Example
With the example values loaded in the calculator above, the steps are:
- n = 8, x̄ = 4.5, ȳ = 9.075.
- Sxx = Σ(x − x̄)² = 42, Sxy = Σ(x − x̄)(y − ȳ) = 83.1.
- Slope b = Sxy ÷ Sxx = 1.97857.
- Intercept a = ȳ − b·x̄ = 9.075 − 1.97857 × 4.5 = 0.171429.
- Prediction: ŷ = 0.17143 + 1.9786 × 9 = 17.9786.
Result: Least squares regression line = ŷ = 0.17143 + 1.9786x; Slope (b) = 1.97857.
Worked example from summary statistics
Suppose x̄ = 10, sx = 2, ȳ = 50, sy = 8 and r = 0.6.
Slope = 0.6 × (8 ÷ 2) = 2.4. Intercept = 50 − 2.4 × 10 = 26. The line is ŷ = 26 + 2.4x.
What the slope and intercept mean
The slope is the predicted change in y for each one unit increase in x. The intercept is the predicted y when x = 0, which is only meaningful if x = 0 is a sensible value in your data.
Where Least Squares Regression Line Is Used
Fitting a trend line
Get the equation of the best fit line through paired data.
Prediction
Estimate y for a new x inside the data range.
Statistics coursework
Find the line from means, standard deviations and r alone.
Common Least Squares Regression Line Mistakes to Avoid
- Check that the scatter plot looks roughly linear before trusting the line.
- Do not predict far outside the x values you measured.
Least Squares Regression Line Terms and Definitions
- Least squares
- A fitting rule that minimises the sum of squared vertical errors.
- Residual
- The observed y minus the predicted y for a point.
Least Squares Regression Line FAQs
How do you find the slope of the least squares regression line?
Divide Sxy, the sum of products of deviations, by Sxx, the sum of squared x deviations. With summary statistics it is r times sy divided by sx.
How do you find the intercept?
Subtract the slope times the mean of x from the mean of y.
Does the least squares line always pass through the means?
Yes. The point (x̄, ȳ) always lies on the line.
Can I get the line without the raw data?
Yes. Means, standard deviations and r are enough, using the summary mode.
Why squares and not absolute errors?
Squaring gives a single clean formula and treats large misses more heavily. Absolute errors need iterative methods.