Least Squares Line Calculator
Work out least squares line instantly with clear inputs, formula shown and shareable results.
About Least Squares Line Calculator
The least squares line minimises the sum of squared vertical residuals. Its slope is Σ(x−x̄)(y−ȳ)/Σ(x−x̄)², and it always passes through the point of means (x̄, ȳ).
Formulas
Least squares slope
b = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)²
Intercept
a = ȳ − b·x̄
Worked example
With the default values below, Least Squares Line Calculator returns Regression line of y = 0.6x + 2.2. Change any input above and every figure here is recalculated in your browser.
Inputs used
- x values
- 1, 2, 3, 4, 5
- y values
- 2, 4, 5, 4, 5
- Predict y at x =
- 6
Results
- Regression line
- y = 0.6x + 2.2
- Slope b
- 0.60000000
- Intercept a
- 2.20000000
- Predicted y
- 5.80000000
Step by step
- 1Values used
- 2Least squares slope
- 3Intercept
- 4Regression line= y = 0.6x + 2.2
- 5Slope b= 0.60000000
- 6Intercept a= 2.20000000
- 7Predicted y= 5.80000000
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 8 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
For x = 1..5 and y = 2, 4, 5, 4, 5?
The slope is 0.6 and the intercept 2.2, giving y = 0.6x + 2.2 and a prediction of 5.8 at x = 6.
Why squared residuals?
Squaring makes the problem differentiable with a unique closed-form solution, and it penalises large misses more heavily.
Related Calculators
- Addition Rule Of Probability Calculator
- ANOVA Two Way Calculator
- Bayesian Posterior Probability Calculator
- Beta Distribution Calculator
- Bonferroni Correction Calculator
- Bootstrap Confidence Interval Calculator
- Box Plot Calculator
- Central Limit Theorem Calculator
- Chi Square Distribution Calculator
- Chi Square Goodness Of Fit Calculator
You might also need
- Decile CalculatorAlso in Statistics & Probability
- F Distribution CalculatorAlso in Statistics & Probability
- Midrange CalculatorAlso in Statistics & Probability
- Z Test CalculatorAlso in Statistics & Probability
- Beta Distribution CalculatorAlso in Statistics & Probability
- Bonferroni Correction CalculatorAlso in Statistics & Probability
