Identify and separate the x and y values of your data points. If you are using a spreadsheet, enter them into adjacent columns. There should be the same number of x and y values. If not, the calculation will be inaccurate, or the spreadsheet function will return an error.
x = (6, 5, 11, 7, 5, 4, 4)
y = (2, 3, 9, 1, 8, 7, 5)
Calculate the average value for the x values and the y values by dividing the sum of all the values by the total number of values in the set. These averages will be referred to as "x_avg" and y_avg."
x_avg = (6 + 5 + 11 + 7 + 5 + 4 + 4) / 7 = 6
y_avg = (2 + 3 + 9 + 1 + 8 + 7 + 5) / 7 = 5
Create two new data sets by subtracting the x_avg value from each x value and the y_avg value from each y value.
x1 = (6 - 6, 5 - 6, 11 - 6, 7 - 6 ... )
x1 = (0, -1, 5, 1, -1, -2, -2)
y1 = (2 - 5, 3 - 5, 9 - 5, 1 - 5, ... )
y1 = (-3, -2, 4, -4, 3, 2, 0)
Multiply each x1 value by each y1 value, in order.
x1y1 = (0 * -3, -1 * -2, 5 * 4, ... )
x1y1 = (0, 2, 20, -4, -3, -4, 0)
Square each x1 value.
x1^2 = (0^2, 1^2, -5^2, ... )
x1^2 = (0, 1, 25, 1, 1, 4, 4)
Calculate the sums of the x1y1 values and x1^2 values.
sum_x1y1 = 0 + 2 + 20 - 4 - 3 - 4 + 0 = 11
sum_x1^2 = 0 + 1+ 25 + 1 + 1 + 4 + 4 = 36
Divide "sum_x1y1" by "sum_x1^2" to get the regression coefficient.
sum_x1y1 / sum_x1^2 = 11 / 36 = 0.306