2. Working with Time Series
Linear regression analysis (2/3)
Step 2: Calculating the slope cont.
We consider the July temperatures, again converted to points with i=1, ..., 6, as given in the data table.
Year | xi | yi |
2003 | 1.58 | 19.69 |
2004 | 2.58 | 17.38 |
2005 | 3.58 | 18.98 |
2006 | 4.58 | 21.12 |
2007 | 5.58 | 18.23 |
2008 | 6.58 | 18.67 |
We already calculated the centroid of the data points which is at and .
The slope a of the best-fit line
which has the smallest distance to the data points is calculated according to the method of the least squares fit to:
Again, you will find this relation derived in supplement 1 in detail. With our temperature data one calculates:
We use now the point-slope form to calculate the best-fit straight line:
Step 3: Calculating the intercept
The intercept b of the best-fit line is calculated by re-arranging the equation above:
Finally, the best-fit line becomes:
Converted to seawater temperatures in July, the best-fit line reads:
where T is the temperature in °C and t is the calendar year.