Linear Regression Calculator

Find lines of best fit step by step

The calculator will find the line of best fit for the given set of paired data using the least squares method, with steps shown.

Related calculator: Quadratic Regression Calculator

Comma-separated.
Comma-separated.

If the calculator did not compute something or you have identified an error, or you have a suggestion/feedback, please write it in the comments below.

Your Input

Find the line of best fit for $$$\left\{\left(1, 2\right), \left(2, 5\right), \left(3, 7\right), \left(4, 11\right), \left(5, 15\right)\right\}$$$.

Solution

The number of observations is $$$n = 5$$$.

Generate the following table:

$$$x$$$$$$y$$$$$$x y$$$$$$x^{2}$$$$$$y^{2}$$$
$$$1$$$$$$2$$$$$$2$$$$$$1$$$$$$4$$$
$$$2$$$$$$5$$$$$$10$$$$$$4$$$$$$25$$$
$$$3$$$$$$7$$$$$$21$$$$$$9$$$$$$49$$$
$$$4$$$$$$11$$$$$$44$$$$$$16$$$$$$121$$$
$$$5$$$$$$15$$$$$$75$$$$$$25$$$$$$225$$$
$$$\sum$$$$$$15$$$$$$40$$$$$$152$$$$$$55$$$$$$424$$$

The line of best fit is $$$y = m x + b$$$.

$$$m = \frac{n(\sum xy)-(\sum x)(\sum y)}{n(\sum x^2)-(\sum x)^2} = \frac{5 \cdot 152 - \left(15\right)\cdot \left(40\right)}{5 \cdot 55 - 15^{2}} = \frac{16}{5}$$$

$$$b = \frac{(\sum y)(\sum x^2)-(\sum x)(\sum xy)}{n(\sum x^2)-(\sum x)^2} = \frac{\left(40\right)\cdot \left(55\right) - \left(15\right)\cdot \left(152\right)}{5 \cdot 55 - 15^{2}} = - \frac{8}{5}$$$

Thus, the line of best fit is $$$y = \frac{16 x}{5} - \frac{8}{5}$$$.

Answer

The line of best fit is $$$y = \frac{16 x}{5} - \frac{8}{5} = 3.2 x - 1.6$$$A.