# What is the general formate for the equation of a least-squares regression line?

Feb 17, 2015

Equation for least-squares linear regression:

$y = m x + b$

where
$m = \frac{\sum \left({x}_{i} {y}_{i}\right) - \frac{\sum {x}_{i} \sum {y}_{i}}{n}}{\sum {x}_{i}^{2} - \frac{{\left(\sum {x}_{i}\right)}^{2}}{n}}$

and
$b = \frac{\sum {y}_{i} - m \sum {x}_{i}}{n}$

for a collection of $n$ pairs $\left({x}_{i} , {y}_{i}\right)$

This looks horrible to evaluate (and it is, if you are doing it by hand); but using a computer (with, for example, a spreadsheet with columns :$y , x , x y , \mathmr{and} {x}^{2}$) it isn't too bad.