If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

# Second regression example

Second Regression Example. Created by Sal Khan.

## Want to join the conversation?

• Do you have any video on multiple regressions?
Thank you.
• This would really be great, the examples on here are really helping me revise but would love to check if I'm getting correct answers to the practice problems I've gotten as part of my course.. :)
(1 vote)
• why not add any practise for this topic?
• yeah...practice would be GREAT! it would really help me remember how to do it if I had to muscle through a few on my own.
• i notice that here, Sal has used an alternate way of stating m... in earlier vid (Regression Line Example) he showed it as:
m = mean x * mean y - mean xy / (mean of x)^2 - mean of x^2. Sal noted (at minute of that video) that we might see it reversed in some statistics books, but that didn't matter b/c it was just multiplying by -1.
in the version here m = mean xy - mean x*mean y / mean of x^2 - (mean of x)^2

wouldn't changing these reverse the direction of the slope (i.e from positive to negative or negative to positive, depending on the data set)?
• Actually to the from one to the other you have to multiply both the numerator and the denominator by -1.

So essentially you're multiplying it by -1/-1 = 1, and that means it won't affect the slope at all! (:
• Thanks for this. How about Multiple Regressions?
• Do you have a vid on multiple regression?
• Why do we know that the average x and average y will always be on the regression line?
• Look up the videos of 'Proof of minimizing squared error to regression line'. You will get your answer in part 3.
• Works like a charm. Just finished manually computing a least squares regression on both nominal and real US GDP from 1970 to 2012 in Excel (index=1970) which is data that I I just happened to looking at a lot lately, then plotted both GDP measures and the regressions on a line chart.

Perfect.

I tested it by dropping a linear regression on the data and presto! My manually computed regressions both disappeared beneath the built in linear trendline tool..

Many, many thanks. Onto R-squared.
• Is the formula for the slope/intercept of the line of best fit to be memorized? I know it can be re-derived, but just wondering.
• I think that's a great question. My opinion is: If you know how to derive it, it's easier in the long run to keep deriving it every time. Because the work of memorizing is wasted, but the work of deriving gives something in return. (Also, memorization is prone to error). (However, I'm a liar, because for the problem in this video, I just used my notes and copied the formulas. That's the 3rd option - refer to notes).
4 videos from now ("covariance and the regression line") you'll learn that the slope is (cov(x,y))/(cov(x,x)); then b is still ybar -m*xbar. This is an easier thing to remember, and interesting to know. Again, I think the best option is to review the derivation and if you want get it from notes to calculate.
(1 vote)
• can anyone tell me, what's the difference between least square regression and squared error of regression line?