How To Calculate Regression Coefficient
One the most basic tools for engineering or scientific analysis is linear regression. This technique starts with a data set in two variables. The independent variable is usually called "x" and the dependent variable is usually called "y." The goal of the technique is to identify the line, y = mx + b, that approximates the data set. This trend line can show, graphically and numerically, relationships between the dependent and independent variables. From this regression analysis, a value for correlation is also calculated.
Step 1
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)
Step 2
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 "xavg" and yavg." xavg = (6 + 5 + 11 + 7 + 5 + 4 + 4) / 7 = 6 yavg = (2 + 3 + 9 + 1 + 8 + 7 + 5) / 7 = 5
Step 3
Create two new data sets by subtracting the xavg value from each x value and the yavg 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)
Step 4
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)
Step 5
Square each x1 value. x1^2 = (0^2, 1^2, -5^2, ... ) x1^2 = (0, 1, 25, 1, 1, 4, 4)
Step 6
Calculate the sums of the x1y1 values and x1^2 values. sumx1y1 = 0 + 2 + 20 – 4 – 3 – 4 + 0 = 11 sumx1^2 = 0 + 1+ 25 + 1 + 1 + 4 + 4 = 36
Step 7
Divide "sumx1y1" by "sumx1^2" to get the regression coefficient. sumx1y1 / sumx1^2 = 11 / 36 = 0.306
Things Needed
- Spreadsheet software (optional)
- Calculator
TL;DR (Too Long; Didn't Read)
For those who prefer to work directly with the equation, it is m = sum[(x_i - x_avg)(y_i - y_avg)] / sum[(x_i - x_avg)^2].
Many spreadsheets will have a variety of linear regression functions. In Microsoft Excel, you can use the "Slope" function to take the average of the x and y columns, and the spreadsheet will automatically perform all the remaining calculations.
References
- NIST/Sematech Engineering Statistics Handbook
- Tusha-Mehta.com: Trendline Coefficients and Regression Analysis
- AustinCC: How Can I Use Trendlines and Linear Regression to Analyze the Relationship Between 2 Experimental Variables?
- Pindling.org: General Statistics, Chapter 3, Regression and Correlation Learning Module
Cite This Article
MLA
McKenzie, Grant D.. "How To Calculate Regression Coefficient" sciencing.com, https://www.sciencing.com/calculate-regression-coefficient-5087094/. 13 March 2018.
APA
McKenzie, Grant D.. (2018, March 13). How To Calculate Regression Coefficient. sciencing.com. Retrieved from https://www.sciencing.com/calculate-regression-coefficient-5087094/
Chicago
McKenzie, Grant D.. How To Calculate Regression Coefficient last modified August 30, 2022. https://www.sciencing.com/calculate-regression-coefficient-5087094/