Supplement 2.1: Point Clouds and Linear Regression Lines (1/3)

A point cloud is considered, with i=1...n data points P( x i , y i ) , where n is a natural number (left graph below). We search for a regression line which best approximates the distribution of data points. For this, the equation of a straight line, shown as blue broken line in the diagrams,

f(x)=ax+b

is investigated, and in particular the points P( x i ,f( x i )) on that line having the same x coordinates as the data points (right graph below, click on the graph titles to switch sides).

The difference between data points and points on the line having the same x values is y i f( x i ) . These differences, shown in the graph below for points P( x 1 , y 1 ) and P( x 1 ,f( x 1 ) ) as an example, provide a means to find the best-fit line that represents the data points. This best-fit line should indeed have minimum differences to the data points!

Alternatively, one could also investigate the differences between data points and points on the line having the same y values. This would lead to a regression analysis with respect to y.

In the following equations, we investigate the regression analysis with respect to x.

It would not be useful to simply add up the differences and find a minimum by varying the line parameters since the differences are positive and negative. Instead, we get rid of the + or - sign of differences by squaring them, and we calculate the mean square deviation

S= 1 n i=1 n ( y i f( x i ) ) 2 ,

here:                           S= ( y 1 f( x 1 ) ) 2 +...+ ( y 6 f( x 6 ) ) 2 6

Substituting f( x i ) with f( x i )=a x i +b yields:

S(a,b)= 1 n i=1 n ( y i (a x i +b) ) 2

where a is the slope and b is the intercept of the straight line.

The centroid of data points

To find the best fit straight line, parameters a and b of the straight line shall be chosen such that the squared mean deviation

S(a,b)= 1 n i=1 n ( y i (a x i +b) ) 2

is a minimum. For this, we calculate the derivative of S and set it to zero.

However, S depends on two variables, a and b. Therefore we calculate the derivative in two steps. In a first step we differentiate S with respect to b and keep a as a constant. Second, we differentiate S with respect to a and keep b as a constant. (In advanced calculus, S is called a function of two variables, and we calculate the partial derivatives of S with respect to a und b)

Differentiation with respect to b yields:

S'(b)= 2 n i=1 n ( y i (a x i +b) )
S'(b)= 2 n ( i=1 n y i a i=1 n x i i=1 n b )

With              1 n i=1 n y i = y ¯ 1 n i=1 n x i = x ¯ 1 n i=1 n b =b

where x ¯ and y ¯ are the arithmetic mean of the x i and y i coordinates, it follows:

S'(b)=2 y ¯ 2a x ¯ 2b

The minimum of S(b) follows from setting S'(b)=0 , and one obtains:

y ¯ =a x ¯ +b

This looks like the equation of a straight line. However, x ¯ and y ¯ are point coordinates (the mean values). The point P( x ¯ , y ¯ ) is the arithmetic mean of the points P( x i , y i ) , denoted as their centroid.

Zoom Sign
points in the diagram
Centroid P( x ¯ , y ¯ ) of the data points.
The centroid P( x ¯ , y ¯ ) is a point lying on the regression line of the point cloud P( x 1 , y 1 ),P( x 2 , y 2 ),...P( x n , y n ) .