The Linear Regression Equation
Linear regression is a way to model the relationship between two variables. You might also recognize the equation as the slope formula. The equation has the form Y=a+bX, where Y is the dependent variable (that’s the variable that goes on the Y axis), X is the independent variable (i.e. it is plotted on the X axis), b is the slope of the line and a is the y-intercept.
\[a=\frac{\left ( \sum y \right ) \left ( \sum x^2 \right )-\left ( \sum x \right )\left ( \sum xy \right )}{n\left ( \sum x^2 \right )-\left ( \sum x \right )^2}\]
\[b=\frac{n\left ( \sum xy \right )-\left ( \sum x \right )\left ( \sum y \right )}{n\left ( \sum x^2 \right )-\left ( \sum x \right )^2}\]
How to Find a Linear Regression Equation: Steps
step1: ake a chart of your data, filling in the columns in the same way as you would fill in the chart if you were finding the Pearson’s Correlation Coefficient.
SUBJECT |
AGE X |
GLUCOSE LEVEL Y |
XY |
X2 |
Y2 |
1 |
43 |
99 |
4257 |
1849 |
9801 |
2 |
21 |
65 |
1365 |
441 |
4225 |
3 |
25 |
79 |
1975 |
625 |
6241 |
4 |
42 |
75 |
3150 |
1764 |
5625 |
5 |
57 |
87 |
4959 |
3249 |
7569 |
6 |
59 |
81 |
4779 |
3481 |
6561 |
Σ |
247 |
486 |
20485 |
11409 |
40022 |
step2:Use the following equations to find a and b.
\[a=\frac{\left ( \sum y \right ) \left ( \sum x^2 \right )-\left ( \sum x \right )\left ( \sum xy \right )}{n\left ( \sum x^2 \right )-\left ( \sum x \right )^2}\]
\[b=\frac{n\left ( \sum xy \right )-\left ( \sum x \right )\left ( \sum y \right )}{n\left ( \sum x^2 \right )-\left ( \sum x \right )^2}\]
a=65.1416
b = .385225
Find a:
((486 × 11,409) – ((247 × 20,485)) / 6 (11,409) – 2472)
484979 / 7445
=65.14
Find b:
(6(20,485) – (247 × 486)) / (6 (11409) – 2472)
(122,910 – 120,042) / 68,454 – 2472
2,868 / 7,445
= .385225
step3: Insert the values into the equation.
y’ = a + bx
y’ = 65.14 + .385225x
For our equation block we asume:
\[p= \sum x ,\;\; q= \sum y , \;\;r=\sum xy, \;\; w= \sum x^2\]