How to Calculate Trendline

How to Calculate Trendline

Scientists often apply trendlines, or best fit lines, to their data after they graph it on an x, y plot. The idea of a trendline is to reveal a linear relationship between two variables, x and y, in the y = mx + b form. Deriving the line equation that links two variables allows scientists to extrapolate, or predict, how one variable will change given any change in the other. Most of the time you cannot simply draw a line through real life data because rarely will it fit neatly. A statistical tool called regression analysis is required to calculate the best fit line accurately. Regression analysis of a large data set will easily fill both sides of a paper with numbers, so if you can find a program to do it for you, you'll save lots of time.

  • Calculator

1 Calculating the Slope (m) of the Trendline

2 Consider this data set of three

Consider this data set of three (x,y) points: (1,3) (2, 5) (3,6.5). Let n = the number of data points, in this case 3.

3 Let a equal n times

Let a equal n times the summation of all x-values multiplied by their corresponding y-values, like so:

4 A = 3 x {

a = 3 x {(1 x 3) +( 2 x 5) + (3 x 6.5)} = 97.5

5 Let b

Let b equal the sum of all x-values times the sum of all y-values, like so:

6 B =

b = (1 + 2 + 3) x (3 + 5 + 6.5) = 87

7 Let c equal n times

Let c equal n times the sum of all squared x-values, like so:

8 C = 3 x

c = 3 x (1^2 + 2^2 + 3^2) = 42

9 Let d

Let d equal the squared sum of all x-values, like so:

10 D =

d = (1 + 2 + 3)^2 = 36

11 Calculated

Plug the values that you calculated for a, b, c, and d into the following equation to calculate the slope, m, of the regression line:

12 Slope = m =

slope = m = (a - b) / (c - d) = (97.5 - 87) / (42 - 36) = 10.5 / 6 = 1.75

13 Calculating the y-intercept (b) of the Trendline

14 Consider the same data set

Consider the same data set.

15 Let e

Let e equal the sum of all y-values, like so:

16 E =

e = (3 + 5 + 6.5) = 14.5

17 Let f

Let f equal the slope times the sum of all x-values, like so:

18 F = 1.75 x

f = 1.75 x (1 + 2 + 3) = 10.5

19 Plug

Plug the values you have calculated for e and f into the following equation for the y-intercept, b, of the trendline:

20 Y-intercept = b =

y-intercept = b = (e - f) / n = (14.5 - 10.5) / 3 = 1.3

21 To reveal the final trendline equation

Plug your values for m and b into a linear equation to reveal the final trendline equation:

22 Trendline equation

Trendline equation: y = 1.75x + 1.3

Timothy Banas has a master's degree in biophysics and was a high school science teacher in Chicago for seven years. He has since been working as a trading systems analyst, standardized test item developer, and freelance writer. As a freelancer, he has written articles on everything from personal finances to computer technology.

×