Statistics How To

Find a Linear Regression Equation by Hand or in Excel

Probability and Statistics > Regression Analysis > Find a Linear Regression Equation

How to Find a Linear Regression Equation: Overview

Regression analysis is used to find equations that fit data. Once we have the regression equation, we can use the 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 plot of the data appears to form a straight line, you can use simple 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. Note: If you’re taking AP statistics, you may see the equation written as b0 + b1x, which is the same thing (you’re just using the variables b0 + b1 instead of a + b.

Watch the video or read the steps below to find a linear regression equation by hand. Scroll to the bottom of the page if you would prefer to use Excel:

How to Find a Linear Regression Equation: Steps

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.
find a linear regression equation

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 how to find a linear regression equation by hand!

Like the explanation? Check out the Practically Cheating Statistics Handbook, which has hundreds more step-by-step solutions, just like this one!

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

Find a Linear Regression Equation in Excel

Like the videos? Subscribe to our Youtube Channel.

Find a Linear Regression Equation by Hand or in Excel was last modified: September 4th, 2015 by Stephanie

37 thoughts on “Find a Linear Regression Equation by Hand or in Excel

  1. Kimble


    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.


  2. Stephanie

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

  3. Lauren Schultz

    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…

  4. Lisa Barcomb

    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.

  5. Donna Allen

    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.

  6. Mary Johnson

    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?

  7. Kalynn Grabau

    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!

  8. Donna Allen

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

  9. Donna Allen

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

  10. Tammy Sutton

    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?

  11. Vanessa DuBarry

    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.

  12. AshleyB

    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?

  13. Alison Bryant

    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.

  14. Athar

    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?!?!?

  15. Physics Teacher

    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


  16. Andale


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

  17. Doug

    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.

  18. Doug

    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.

  19. Andale

    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? ;)

  20. Andale

    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).

  21. America

    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!!!!!!

  22. kimpss

    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 :)

  23. Andale


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


  24. Pramod


    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?

  25. Andale

    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?


Leave a Reply

Your email address will not be published. Required fields are marked *