Home /
Expert Answers /
Calculus /
6-linear-regression-is-used-to-find-the-best-slope-a-and-intercept-b-of-a-linear-f-pa121
(Solved): 6. Linear regression is used to find the best slope \\( a \\) and intercept \\( b \\) of a linear f ...
6. Linear regression is used to find the best slope \\( a \\) and intercept \\( b \\) of a linear function \\( f(x)=a x+b \\) to approximate a set of data \\( \\left(x_{i}, y_{i}\\right), i=1, \\ldots, n \\). The slope and intercept are found by minimising the sum of square errors: \\[ F(a, b)=\\sum_{i=1}^{n}\\left(f\\left(x_{i}\\right)-y_{i}\\right)^{2}=\\sum_{i=1}^{n}\\left(a+b x_{i}-y_{i}\\right)^{2} . \\] Use multivariable optimisation to show that the values of \\( a \\) and \\( b \\) that minimise this expression are \\[ b=\\frac{n \\sum_{i=1}^{n} x_{i} y_{i}-\\left(\\sum_{i=1}^{n} x_{i}\\right)\\left(\\sum_{i=1}^{n} y_{i}\\right)}{n \\sum_{i=1}^{n} x_{i}^{2}-\\left(\\sum_{i=1}^{n} x_{i}\\right)^{2}}, \\quad a=\\frac{1}{n} \\sum_{i=1}^{n} y_{i}-\\left(\\frac{1}{n} \\sum_{i=1}^{n} x_{i}\\right) b . \\] (You will use linear regression in the second half of this unit!)