## How to Find a Linear Regression Equation

Regression analysis is used to find equations that fit data. Once we have the equation, we can use the statistical model to make predictions. One type of regression analysis is linear analysis. When a correlation coefficient shows that data is likely to be able to predict future outcomes and a scatter graph of the data appears to form a straight line, statisticians may use linear regression to find a predictive function. If you recall from elementary algebra, the equation for a line is y = mx + b. This article shows you how to take data, calculate linear regression, and find the equation y’ = a + bx. If you like our easy to follow explanations of statistics, check out our easy to follow book, which has hundreds more examples, just like this one.

Step 1: Make 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

From the above table, Σx = 247, Σy = 486, Σxy = 20485, Σx2 = 11409, Σy2 = 40022. n is the sample size (6, in our case).

Step 2: Use the following equations to find a and b.

a = 65.1416
b = .385225

Click here if you want easy, step-by-step instructions for solving this formula.

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

*/ ?>

Step 3: Insert the values into the equation.
y’ = a + bx
y’ = 65.14 + .385225x

That’s it! Like the explanation? Check out our statistics how-to book, with a how-to for every elementary statistics problem type.

* Note that this example has a low correlation coefficient, and therefore wouldn’t be too good at predicting anything.

Feel like Cheating at Statistics? This is the Statistics Handbook that your professor doesn't want you to see. So easy, it's Practically Cheating. Find out more »

## 39 Responses to “How to Find a Linear Regression Equation”

1. ### How to Do Everything Statistics » How to Find a Linear Regression Slope said:

Nov 06, 09 at 5:53 am

[...] If formulas scare you, you can find more comprehensive instructions on how to work the formula in this article on how to find a linear regression equation. [...]

2. ### Kimble said:

Nov 06, 09 at 4:29 pm

Hei!

Let’s say I’ve plotted y in a scatter plot to make some prediction. I know that it’s possible to find functions indicating the “upper and lower” bound for y for a given x with a given percent certainty.

I’ve done some statistics in Norwegian, but I’m not sure about the English term for this. Hope someone understood what I’m trying to do.

Thanks!

3. ### Stephanie said:

Nov 07, 09 at 5:52 am

Kimble, What you are describing is linear regression — I think you’re thinking of confidence interval. Stephanie

4. ### Lauren Schultz said:

Nov 12, 09 at 11:45 am

Your explination was very helpful. I kept messing up when i put it into the calculator. I had to redo it over and overto get the answer in the ex then follow that process in my problem…

5. ### Lisa Barcomb said:

Nov 12, 09 at 7:28 pm

These questions were somewhat difficult but I tried to do my best and hopefully I will understand them as I take my test. Some of this information is not sinking in my head for some reason. I know I will never take a class like this again on line.

6. ### Donna Allen said:

Nov 13, 09 at 1:57 am

I have to agree with Lisa that I wouldn’t take another math class online. Math is not my strong suit. And, I realize now that I should have been in a classroom setting where I could ask questions face to face. This blog has been very helpful. But, unfortunately it doesn’t make up for my lack of math skills.

7. ### Mary Johnson said:

Nov 29, 09 at 3:46 pm

I was having trouble in chapter nine with the correlation coefficient, I couldn’t come up with the same answer as Math Zone using the formula to solve for r. The problems don’t show a square route in the denominator but the link to text does. I don’t know if my skills are lacking so much that I just didn’t know that but why would it show it in the text?

8. ### Stephanie said:

Dec 01, 09 at 2:41 am

There is a square root: Mathzone is missing it in a couple of the questions.

9. ### Kalynn Grabau said:

Dec 02, 09 at 10:03 am

That’s what it is. Mathzone doesn’t explain that to solce for r, you need to square root it. Now, I’m getting it, but before I was so confused. Thanks for this!

10. ### Donna Allen said:

Dec 02, 09 at 7:32 pm

I found this information very helpful and easy to follow. Compared to chapter 8, so far this has been a breeze.

11. ### Donna Allen said:

Dec 05, 09 at 12:08 am

Thank you for posting it on the main blackboard page that the square root was missing. This saved a lot of time and headache.

12. ### Tammy Sutton said:

Dec 07, 09 at 3:35 pm

On this one I found it easier (yes I know lazier) to put it into my calculator. It took me a while to remember how to use my calculator, but once I remembered, I got it down. I’m not sure if there is a part on this site that would give some directions on how to use our calculators for these problems?

13. ### Vanessa DuBarry said:

Dec 10, 09 at 5:44 pm

This blog was very helpful and it was very easy to follow, I agree with the others that taking math online is way more difficult, but thanks to this blog its a little bit easier.

14. ### AshleyB said:

Feb 20, 10 at 6:30 am

Hey guys,

I’m from the better USA! and I think I found a new spot to hangout

So, anyone care about the Olympic Games?

15. ### Alison Bryant said:

Apr 26, 10 at 12:16 pm

I found this aspect fairly easy once I got the equation down. However, I also realized that you can use the linreg function on the calculator and get the same answer.

16. ### Athar said:

May 25, 10 at 10:52 pm

so i tried using the linreg2 function: as in, A=linreg2(x,y), given both x and y.
sooo what should that tell me. coz im running this in matlab and it doesnt seem to know what it is?!?!?

17. ### math for kids said:

Nov 24, 11 at 12:56 pm

math for kids…

[...]Statistics How To» Blog Archive » How to Find a Linear Regression Equation[...]…

18. ### Physics Teacher said:

Nov 26, 11 at 6:32 pm

Your calculations for a are wrong.

I did your example as well as I used the trend line on MS Excel and I found on both cases that a=65.14

:)

19. ### Andale said:

Mar 20, 12 at 1:47 pm

You are absolutely correct! I’ve updated the page: thanks!

Stephanie

20. ### stylish_cuter said:

Apr 05, 12 at 5:34 am

how to make sure which one is X and which one is y ?

21. ### Andale said:

Apr 05, 12 at 2:41 pm

Hello!

Can you post this question on the forum? One of our moderators will be glad to help :)

22. ### Doug said:

Jun 18, 12 at 9:31 am

Ok, what am I missing? I never had statistics until college and I don’t remember us discussing this. I compute the same linear regression on my TI-84 Plus. I plug this equation into my y = table, and then use set my calculator to ask for the independent variable and then when I plug in a value of 43, I get 81.705. I can also see in my head that 38% of 43 added to 65 is not going to be equal to 99. I think what is missing in this discussion is the linear regression does its best attempt to draw a straight line through data and form the “best” equation to make predictions. You can see with any two points in the table above, computing slope, and using point-slope form, you will get a different equation. You can take the y=a + bx equation into your calculator as an estimate of y for a “new” given value of x but do not expect your original x-values to return the same y-values (in some cases, this function will return a value less than the original y and in some cases greater than the original y). I think it is also very confusing to use the form y=a+bx when algebra students are so used to y=ax + b.

23. ### Doug said:

Jun 18, 12 at 9:39 am

Also another question is in general for a given set of data, how does one know whether to use a linear, quadratic, cubic, quartic, or other form of regression. The only way I have been able to eliminate a linear regression so far, for example, is if my data contains the point (0,0) and my linear regression calculation gives a non-zero b-value then I try the next higher regression until I find an equation where the constant term is 0 so that I get a true statement i.e., 0=0 when I plug in 0 for x.

24. ### Andale said:

Jun 19, 12 at 3:09 pm

Thanks for your thoughts, Doug. This is an article about basic steps — I leave the discussions for the (bloated) textbooks. Stronger algebra students will see that y=a+bx is equal to what they are seeing. Sure, we could stick to the same equation throughout college, but why not expand minds a little? ;)

25. ### Andale said:

Jun 19, 12 at 3:13 pm

Doug,
Sometimes you don’t know — it’s a guess and check. That said, if you have the data points in a TI-89 you can guess and check pretty easily (plot both the points and the resulting graph on the same screen and see which equation fits the data best).
Stephanie

26. ### Jamal said:

Jul 10, 12 at 5:24 pm

Sheit statiscs is hard!

27. ### Andale said:

Jul 11, 12 at 10:53 am

Lol! Not really :)

28. ### America said:

Aug 21, 12 at 7:58 am

this site has been very helpful, i am so glad that i found something very helpful for my Statistics test, i never knew statistics would be easy, unless you understand the basics, this site is Awesome!!!!!!

29. ### Andale said:

Aug 22, 12 at 7:25 am

30. ### What is a Regression Equation? | said:

Oct 31, 12 at 1:35 pm

[...] several how-to articles on this site for specific regression equations, including this article on How to Calculate linear regression. You can also find regression equations on the TI89 (see this article “How to Perform TI89 [...]

31. ### Goh said:

Nov 19, 12 at 10:50 am

thx so much…i had done my homework..

32. ### kimpss said:

Dec 10, 12 at 7:08 am

Thank you so much, I had learn enough though ! to those who didn’t understand, try to analyze those E xys’ It’s pretty easy though ! I learned a lot :)

33. ### U.Muralikrishna said:

Jan 14, 13 at 8:34 pm

Does the linear regression slope value related to the tan(theta) value of the experimental line

34. ### Andale said:

Jan 22, 13 at 6:31 am

U.Muralikrishna,

Time constraints prevent me from answering stats questions in the comments…but post on our forums and our mod will be happy to help :)

Stephanie

35. ### aman said:

Mar 02, 13 at 8:03 am

whatz the standard form of the equation? y = a + bx or ax + by = c ??

36. ### Andale said:

Mar 04, 13 at 6:02 pm

The standard form is usually ax + by=c.

Stephanie

37. ### Pramod said:

Mar 07, 13 at 5:15 am

Hi,

I have one doubt. For the perfect Linear Graph y=mx+c, the m value should be close to 1 and c value should be close to 0.
In the same way, for the perfect Linear Regression equation y=a+bx, the b value should be close to 1 and a value should be close to 0.

Is this right?

38. ### Andale said:

Mar 11, 13 at 5:46 am

Hello, Pramod,

I’m not sure what you mean by the “Perfect” linear graph or linear regression equation. For the equation y=mx+c, any m value would still result in a linear graph. Could you explain what you mean by perfect?

Regards,
Stephanie

39. ### vito said:

Apr 15, 13 at 1:18 am