# 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 bis: [(ΣY)(ΣX2) – (ΣX)(ΣXY)]  /  [n(ΣX2) – (ΣX)2]

In this example, b= [(477)(222755) – (1237)(85125)]  /  [7(222755) – (1237)2] = 32.783

Step 4: Calculate b1

The formula to calculate bis: [n(ΣXY) – (ΣX)(ΣY)]  /  [n(ΣX2) – (ΣX)2]

In this example, b= [7(85125) – (1237)(477)]  /  [7(222755) – (1237)2] = 0.2001

Step 5: Place band 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.

b= 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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.822773,"math_prob":0.998957,"size":1780,"snap":"2021-43-2021-49","text_gpt3_token_len":533,"char_repetition_ratio":0.14245495,"word_repetition_ratio":0.026666667,"special_character_ratio":0.32247192,"punctuation_ratio":0.123595506,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.999966,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,4,null,4,null,4,null,4,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-17T02:52:20Z\",\"WARC-Record-ID\":\"<urn:uuid:dc578807-9f35-47bc-be92-d5dd77557363>\",\"Content-Length\":\"33524\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7a579127-968d-4ec3-bc76-28fcc2cda140>\",\"WARC-Concurrent-To\":\"<urn:uuid:4f20d5c1-ba0a-4251-bc53-f98f73ba25bd>\",\"WARC-IP-Address\":\"35.206.100.4\",\"WARC-Target-URI\":\"https://www.statology.org/linear-regression-by-hand/\",\"WARC-Payload-Digest\":\"sha1:IY2AOLNJK6PPJZAWWE5MEZE65ESSON4R\",\"WARC-Block-Digest\":\"sha1:F46AJQX6MRXSQ2SX6MTJBIGUQPFVLKAR\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585120.89_warc_CC-MAIN-20211017021554-20211017051554-00158.warc.gz\"}"}