Home Â» How to Perform Linear Regression by Hand

# How to Perform Linear Regression by Hand

Simple linear regression is a statistical method you can use to quantify the relationship between a predictor variable and a response variable.

This tutorial explains how to perform simple linear regression by hand.

### Example: Simple Linear Regression by Hand

Suppose we have the following dataset that shows the weight and height of seven individuals:

Use the following steps to fit a linear regression model to this dataset, using weight as the predictor variable and height as the response variable.

Step 1: Calculate X*Y, X2, and Y2

Step 2: CalculateÂ Î£X,Â Î£Y,Â Î£X*Y, Î£X2, and Î£Y2

Step 3: CalculateÂ b0

The formula to calculate b0Â is:Â [(Î£Y)(Î£X2) â€“ (Î£X)(Î£XY)]Â  /Â  [n(Î£X2) â€“Â (Î£X)2]

In this example,Â b0Â = [(477)(222755) â€“ (1237)(85125)]Â  /Â  [7(222755) â€“Â (1237)2] =Â 32.783

Step 4: CalculateÂ b1

The formula to calculate b1Â is:Â [n(Î£XY) â€“ (Î£X)(Î£Y)]Â  /Â  [n(Î£X2) â€“Â (Î£X)2]

In this example,Â b1Â = [7(85125) â€“ (1237)(477)]Â  /Â  [7(222755) â€“Â (1237)2] =Â 0.2001

Step 5: Place b0Â andÂ b1 in the estimated linear regression equation.

The estimated linear regression equation is:Â Å· =Â b0 + b1*x

In our example, it isÂ Å· = 0.32783 + (0.2001)*x

### How to Interpret a Simple Linear Regression Equation

Here is how to interpret this estimated linear regression equation:Â Å· = 32.783 + 0.2001x

b0Â = 32.7830. WhenÂ weightÂ is zero pounds, theÂ predicted height is 32.783 inches.Â Sometimes the value for b0Â can be useful to know, but in this example it doesnâ€™t actually make sense to interpretÂ b0Â since a person canâ€™t weigh zero pounds.

b1Â = 0.2001. A one pound increase inÂ weightÂ is associated with a 0.2001Â inch increase in height.

### Simple Linear Regression Calculator

We can double check our results by inputting our data into the simple linear regression calculator:

This equation matches the one that we calculated by hand.