Example Method of Least Squares
The given example explains how to find the equation of a straight line or a least square line by using the method of least square, which is very useful in statistics as well as in mathematics.
Example:
Fit a least square line for the following data. Also find the trend values and show that $$\sum \left( {Y – \widehat Y} \right) = 0$$.
$$X$$

1

2

3

4

5

$$Y$$

2

5

3

8

7

Solution:
$$X$$

$$Y$$

$$XY$$

$${X^2}$$

$$\widehat Y = 1.1 + 1.3X$$

$$Y – \widehat Y$$

1

2

2

1

2.4

0.4

2

5

10

4

3.7

+1.3

3

3

9

9

5.0

2

4

8

32

16

6.3

1.7

5

7

35

25

7.6

0.6

$$\sum X = 15$$

$$\sum Y = 25$$

$$\sum XY = 88$$

$$\sum {X^2} = 55$$

Trend Values

$$\sum \left( {Y – \widehat Y} \right) = 0$$

The equation of least square line $$Y = a + bX$$
Normal equation for ‘a’ $$\sum Y = na + b\sum X{\text{ }}25 = 5a + 15b$$ — (1)
Normal equation for ‘b’ $$\sum XY = a\sum X + b\sum {X^2}{\text{ }}88 = 15a + 55b$$ —(2)
Eliminate $$a$$ from equation (1) and (2), multiply equation (2) by 3 and subtract from equation (2). Thus we get the values of $$a$$ and $$b$$.
Here $$a = 1.1$$ and $$b = 1.3$$, the equation of least square line becomes $$Y = 1.1 + 1.3X$$.
For the trends values, put the values of $$X$$ in the above equation (see column 4 in the table above).
RITUMUA MUNEHALAPEKE220040311
July 2 @ 2:56 am
The table below shows the annual rainfall (x 100 mm) recorded during the last decade at the Goabeb Research Station in the Namib Desert
Year Rainfall (mm)
2004 3.0
2005 4.2
2006 4.8
2007 3.7
2008 3.4
2009 4.3
2010 5.6
2011 4.4
2012 3.8
2013 4.1
Determine the least squares trend line equation, using the sequential coding method with 2004 = 1 . (10)