You are on page 1of 3

Linear regression using the ‘Trendline’ function

You will be relieved to know that Excel has a tool that does this type of line-fitting
(known as linear regression) automatically. In Excelese it's called 'adding a trendline'.
A useful feature is that it can be set up to show the equation of the fitted line so that
you can see immediately what the gradient and intercept are:

Let's see how your best estimate of ε compares with the one that Excel comes up with.

 Go back to your original graph and delete the straight line by right-clicking on one
of the data points and selecting Delete.
 Now go to Chart Tools ribbon at the top of the screen and choose Analysis from
the Layout ribbon. Click on Trendline.
 Click on Linear Trendline, which will immediately add a trendline to your graph,
and then right-click on the new trendline and select Format trendline...
 In the dialogue box that appears, tick the three small boxes at the bottom which
will (i) set the intercept to zero (because the line has to pass through the origin in
this case), (ii) present you with the equation of the line on the graph, and (iii)
give you a number called R2 which is an indication of how good the fit is.
 Press Close and, hey presto, there is the line of best fit plotted on your graph,
plus its equation and a value for R2.

The value of ε is the number in front of x in the equation of the line i.e. the gradient of
the line. Enter this value in cell C10 and see what value it gives for the sum of squares.
How do these values compare with what you got by trial and error above? By what
percentage is the trendline value for ε greater or smaller than the published value of
3.158?

You might also like