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 contact us.

Your Input

Find the line of best fit for {(1,2),(2,5),(3,7),(4,11),(5,15)}\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=5n = 5.

Generate the following table:

xxyyxyx yx2x^{2}y2y^{2}
1122221144
22551010442525
33772121994949
44111144441616121121
55151575752525225225
\sum151540401521525555424424

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

m=n(xy)(x)(y)n(x2)(x)2=5152(15)(40)555152=165m = \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=(y)(x2)(x)(xy)n(x2)(x)2=(40)(55)(15)(152)555152=85b = \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=16x585y = \frac{16 x}{5} - \frac{8}{5}.

Answer

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