This page includes Step-by-Step instructions to calculate a Least Squares linear regression equation by-hand.  We will use the Temperature/Water example.


In order to find the regression equation “by-hand” we need some formulas.  

Prediction Equation

where


intercept
=

Click here for formula explanation.


Click here for derivation of the intercept equation.

 


Example: Assume that during a three-hour period spent outside, a person recorded the temperature and their water consumption.  

Use the formulas to find the Least Squares Linear Regression Equation (the line of best fit) for the temperature and the amount of water consumed.  

Temperature (F) Water Consumption (oz)
99

48

85 27
97 48
75 16
92 32
85 25
83 20

 

 

C1

C2

C3

C4

C5

C6

X

Y

75

16

 

 

 

 

83

20

 

 

 

 

85

25

 

 

 

 

85

27

 

 

 

 

92

32

 

 

 

 

97

48

 

 

 

 

99

48

 

 

 

 

 

 

TOTAL

 

 

 

Preliminary Step  

Variable Sample Mean Sample Standard Deviation
x
(temperature)
88.00 8.47
y  (water
consumption)
30.86 12.76

 


Procedure  

  1. Either print the table above or make your own copy on a sheet of paper.
  2. Enter the x’s into column C1 as in the table above.
  3. Enter the y’s into column C2 as in the table above.
  4. For each row in column C3, take each individual x value and subtract the mean of the x’s.
  5. For each row in column C4, take each individual y value and subtract the mean of the y’s.
  6. For each row in column C5, take the answer from that row of C3 and multiply it by the answer from that row of C4.
  7. Add the values in C5 and put that answer in the Total cell under the column.
  8. For each row in column C6, square the answer for that row of C3.
  9. Add the values in C6 and put that answer in the Total cell under the column.
  10.   Find the slope first.  slope = m = (total of C5)/(total of C6).

  11.   Use the slope to find the y-intercept.
           y-intercept = b = (mean of y) - slope*(mean of x)

 


Learn the Procedure for calculating correlation coefficients

Simple Linear Regression Menu    Dictionary

STATS @ MTSU