Deriving the least squares estimators of the slope and intercept (simple linear regression)

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024
  • I derive the least squares estimators of the slope and intercept in simple linear regression (Using summation notation, and no matrices.) I assume that the viewer has already been introduced to the linear regression model, but I do provide a brief review in the first few minutes. I assume that you have a basic knowledge of differential calculus, including the power rule and the chain rule.
    If you are already familiar with the problem, and you are just looking for help with the mathematics of the derivation, the derivation starts at 3:26.
    At the end of the video, I illustrate that sum(X_i-X bar)(Y_i - Y bar) = sum X_i(Y_i - Y bar) =sum Y_i(X_i - X bar) , and that sum(X_i-X bar)^2 = sum X_i(X_i - X bar).
    There are, of course, a number of ways of expressing the formula for the slope estimator, and I make no attempt to list them all in this video.

Комментарии • 201

  • @AnDr3s0
    @AnDr3s0 4 года назад +161

    Finally, someone who made it simple to understand! Thank you!

    • @victoriabrimm5014
      @victoriabrimm5014 4 года назад +4

      Right! i went through like a million videos trying to understand this one segment and this was the first to do it.

    • @agustinlawtaro
      @agustinlawtaro 3 года назад

      True.

    • @cmacompilation4649
      @cmacompilation4649 9 месяцев назад

      please, how is it possible to consider Beta variable (when taking derivatives) and then consider Beta constant (to take it out of the sum) ???

    • @cleisonarmandomanriqueagui9176
      @cleisonarmandomanriqueagui9176 4 месяца назад

      Best video . i was looking for something like this

    • @TheJolgo
      @TheJolgo 2 месяца назад

      This guy literally skipped vital parts of the proof xD

  • @sajibmannan
    @sajibmannan 3 года назад +2

    Question: 6:24 Why and how beta zero hat is multiplied with n? Does n mean sample size? What's the reasoning behind n adjoining with beta zero hat?

  • @mautasimsiddiqui8618
    @mautasimsiddiqui8618 2 года назад

    Thank you so much.

  • @gan_luo1909
    @gan_luo1909 2 года назад

    saved my life

  • @sajibmannan
    @sajibmannan 3 года назад +38

    My god, you explained this so easily. It took me hours trying to understand this before watching this video but still couldn’t understand it properly. After watching this video, it's crystal-clear now. ❤️

    • @DHDH_DH
      @DHDH_DH 8 месяцев назад

      me, too. I spent a whole morning figuring this. He is a savior

  • @anuraghavsai5575
    @anuraghavsai5575 3 года назад +48

    This is an underrated video.

    • @divitisaitezaa2599
      @divitisaitezaa2599 3 года назад +1

      @Isaiah Matias is it?

    • @MustaphaFaridah
      @MustaphaFaridah 27 дней назад

      @@divitisaitezaa2599🎉😂 🎉🎉😮we🎉 are y😂 🎉😢🎉

  • @马克粟粟
    @马克粟粟 2 года назад +7

    I have gone through tons of materials on this topic and they either skip the derivation process or go direct into some esoteric matrix arithmetics. This video explains everything I need to know. Thanks.

  • @aaskyboi
    @aaskyboi 4 года назад +17

    I can't thank you enough for this brilliant explanation!

  • @tezike
    @tezike 4 года назад +7

    holy hell I wish you were my econometrics professor. mine is useless

  • @amberxv4777
    @amberxv4777 2 года назад +7

    I don't usually comment on teaching videos. But this really deserves thanks for how clearly and simply you explained everything. The lecture I had at the university left much to be desired

  • @lukewong3157
    @lukewong3157 2 года назад +1

    Why can we set the partial derivative to Zero?

  • @monojitchatterjee3185
    @monojitchatterjee3185 4 года назад +12

    Absolutely beautiful derivation!
    Crystal clear!
    Thanks very much.

  • @danverzhao9912
    @danverzhao9912 2 года назад +6

    Thank you so much! This explanation is literally perfect, helped me so much!

    • @jbstatistics
      @jbstatistics  2 года назад +1

      Thanks for the kind words! I'm glad to be of help!

  • @JFstriderXgaming
    @JFstriderXgaming 4 года назад +7

    My Physical Chemistry teacher spent ~1.5 hrs showing this derivation and I got completely lost. Watching your video, it's so clear now. Thank you for your phenomenal work.

  • @alimortadahoumani1134
    @alimortadahoumani1134 10 месяцев назад +3

    unbelievably perfect video, one of the best videos I have watched in the statistics field, so rare to find high-quality in this field idk why

  • @Harshavardhan-no7ri
    @Harshavardhan-no7ri 3 года назад +1

    did we consider beta not hat and beta hat as variables for partial derivation in this problem usually they are constant in straight line right ? why did we take them as variables , if any one knows the answer plse do reply me

  • @deborahsakazhila4068
    @deborahsakazhila4068 4 года назад +8

    Hi, do you have a video on deriving coefficients in multiple regression?

    • @mattstats399
      @mattstats399 Год назад

      That is a fun derivation using linear algebra and calculus. First step is the same here which is taking the first derivative and setting it equal to zero. The book "The Elements of Statistical Learning" has a good proof. I'd say one needs a calc 1 and linear algebra background first though.

  • @nak6608
    @nak6608 3 года назад +4

    phenomenal video. Thank you for taking the time to explain each step of the derivations such as the sum rule for derivation. Thank you for helping me learn.

  • @valeriereid2337
    @valeriereid2337 Год назад +2

    The best part of this video is finally figuring out where that "n" came from in the equation for beta-naught-hat. Thank you so very much for making this available.

  • @kaanaltug455
    @kaanaltug455 4 года назад +3

    Wait, at 6:45, how do you divide the summations by n and get (y) itself? y-sub-i isn't a constant, so how does the division even work?

    • @kaanaltug455
      @kaanaltug455 4 года назад +3

      OOHHH NOOOO, ITS THE MEAN. NOW I GOT IT. JUST GONNA LEAVE THIS HERE JUST TO SHOW HOW STUPID I CAN BE

    • @noopyx3414
      @noopyx3414 4 года назад

      I'm new to this formula and the big data field, what mathematical knowledge should I learn prior to watch this video? Thank you

    • @kaanaltug455
      @kaanaltug455 4 года назад +1

      @@noopyx3414 Oh man, you're lucky. I just logged in to RUclips. Prior to this formula, I'd really suggest you check out Brandon Fultz's Statistics 101: Linear Regression series. There he explains what this formula and other stuff regarding the topic, are all about.

    • @noopyx3414
      @noopyx3414 4 года назад

      @@kaanaltug455 Thank you very much!

  • @soryegetun529
    @soryegetun529 3 года назад +1

    finally, I've understood this bloody thing. Thank u sooooo much m8.

    • @jbstatistics
      @jbstatistics  3 года назад +1

      I'm glad you found it helpful!

  • @TanzinaYeasmin-i9j
    @TanzinaYeasmin-i9j Год назад +1

    যদিও ভাষা বুঝিনি।তবে ম্যাথ দেখেই বুঝা যাচ্ছে 😑

    • @jbstatistics
      @jbstatistics  Год назад

      যতক্ষণ বুঝতে পেরেছেন 🙂

  • @augustinejunior3361
    @augustinejunior3361 3 года назад +2

    I never thought that I could understand simple linear regression using this approach. Thank you

  • @process6996
    @process6996 5 лет назад +6

    Glad you're back!

    • @jbstatistics
      @jbstatistics  5 лет назад +3

      Thanks! Glad to be back! Just recording and editing as I type this!

  • @louism.4980
    @louism.4980 8 месяцев назад +1

    This is incredible, thank you so much! :)

  • @wallyduboss9464
    @wallyduboss9464 23 дня назад

    like I said earlier, this is very good but I am fuzzy on the nxB0 part. Can someone explain that a little more.

  • @menghongpor2667
    @menghongpor2667 4 года назад +2

    At 10:52 timeline, how can we switch the role of X sub i and Y sub i? Could you help explain how this happens?

    • @harveywilliams7013
      @harveywilliams7013 3 года назад +1

      In the first step, we choose to expand (Xi - Xbar) but we could have chosen to expand (Yi - Ybar) and it would follow a similar route.

  • @cmacompilation4649
    @cmacompilation4649 9 месяцев назад

    please, how is it possible to consider Beta variable (when taking derivatives) and then consider Beta constant (to take it out of the sum) ???

  • @anangelsdiaries
    @anangelsdiaries 5 месяцев назад

    The result represent the minimas since the original function that we were minimizing is convex and open upwards, so the only way for a critical value to exist is for it to be a minimum.

  • @wallyduboss9464
    @wallyduboss9464 25 дней назад

    very well done. i understand, and that's miraculous

  • @pkeric2626
    @pkeric2626 4 года назад +3

    Thanks so much, this was so easy to follow and comprehend!

  • @firstkaransingh
    @firstkaransingh 2 года назад

    Excellent....haha... Excellent....
    Evil laugh.
    I finally understood this.

  • @nomann5244
    @nomann5244 9 месяцев назад

    your video is great but you have told that you have discussed elsewhere why we should use square of the deviation not the absolute value but didn't mention where you have discussed it or didn't give the link of the video. this is bad.

  • @ghunter958
    @ghunter958 4 года назад +2

    Really, really good explanation!! Thank you!!

  • @natachajouonang2710
    @natachajouonang2710 3 года назад +1

    Amazing and super helpful video! Extremely simple and easy to follow! But please, quick question: Why did you switch the Xi and Xbar at 7:51? This drastically changes the ending solution.

    • @malolanbalaji98
      @malolanbalaji98 3 года назад

      When he removes the inner paranthesis, the term Xi becomes negative and Xbar becomes positive. So when you multiply it by (-ve)Beta, the signage of both terms reverses

  • @egnos
    @egnos 5 лет назад +3

    2:24, where did you discuss why it makes sense to minimize the sum of squared residuals ?

    • @aakarshan01
      @aakarshan01 4 года назад +2

      makes it more sensitive to bigger errors. And it's differentiable at all points. In the Mod function , it is not differentiable at the point it pivots up

    • @SuperYtc1
      @SuperYtc1 4 года назад

      @@aakarshan01 but why not to power 1.5? why not to power 4? why is it exactly power 2?

    • @aakarshan01
      @aakarshan01 4 года назад +1

      @@SuperYtc1 you can.but there is no need to. The differentiability is achieved in square. Why calculate a bigger number that could lead to problems since power 4 of a decimal number of more likely to break the minimum number limit of a float than a square. But in theory, you can

  • @Wuaners
    @Wuaners День назад

    Amazing. thank you!

  • @zumichetiapator
    @zumichetiapator 4 месяца назад

    finally got my doubt resolved.😊

  • @hellothere9298
    @hellothere9298 8 месяцев назад +1

    Thank you very much sir !

  • @oliviapiche2501
    @oliviapiche2501 21 день назад

    Congratulations on being the best!

  • @daniyal98
    @daniyal98 4 года назад +1

    one video on youtube that actually explains something properly

  • @Zydres_Impaler
    @Zydres_Impaler Год назад

    thanks a lot for simplifying the derivation

  • @mobileentertainment212
    @mobileentertainment212 Год назад

    In which video does he discuss why the we use squared residuals?

  • @mahimapatel8706
    @mahimapatel8706 5 месяцев назад

    the simplification is the most confusing
    but i got it

  • @Murraythis
    @Murraythis 2 года назад

    Amazing video! Slight bumps where my own knowledge was patchy but you provided enough steps for me to work those gaps out.

  • @aron4317
    @aron4317 5 месяцев назад

    Beautiful video, good explanation

  • @AnuarPhysics
    @AnuarPhysics 3 года назад

    Nice trick! Adding an intelligent zero huh?
    Thanks for this video!

  • @_The_Sage_
    @_The_Sage_ Год назад

    Do you have the version for GLM?

  • @loden5677
    @loden5677 10 месяцев назад

    This was really helpful thanks!

  • @yixuanliu8368
    @yixuanliu8368 Год назад

    you have no idea how you saved my life, I was struggling so hard to find out why xi(xi-xbar)=(xi-xbar)^2 and etc. you are the first one I found explained that.

  • @TheMatthyssen
    @TheMatthyssen 10 месяцев назад

    thank you for actually explaining it, most of videos are just like "hi, if you want to solve this, plug in this awesome formula and thats it, thank you for watching :)"

  • @trunghieuoan8040
    @trunghieuoan8040 7 месяцев назад

    It seems like the 7:48 second part is wrong, the brackets are broken and the punctuation is changed incorrectly

    • @jbstatistics
      @jbstatistics  7 месяцев назад +1

      No, what's in the video is correct.

  • @jackhasfun4752
    @jackhasfun4752 11 месяцев назад

    thank you so much, this video has cleared all my confusions cuz the book im reading just says 'by doing some simple calculus'

  • @LucyMburu605
    @LucyMburu605 3 месяца назад

    Thanks alot it really helped

  • @jingyiwang5113
    @jingyiwang5113 9 месяцев назад

    Thank you so much for such a clear explanation! It helps me a lot in preparing for my upcoming final exam.

  • @sanjidajahan3727
    @sanjidajahan3727 11 месяцев назад

    Finally you cleared my doubts sir😭😭❤️‍🩹
    And my professor couldn't

  • @stretch8390
    @stretch8390 Год назад

    Easiest subscribe of my life.

  • @satyarath7723
    @satyarath7723 3 года назад

    Thanks a lot sir I really got this what I need indeed. 🙏🙏🙏🙏🙏🙏🙏🙏There is no words for appreciation of your efforts

  • @olympusexothermic1752
    @olympusexothermic1752 Год назад

    Thank you so much am really enjoying and understanding what your teaching

  • @DHDH_DH
    @DHDH_DH 8 месяцев назад

    at 10:43, can you please tell me why we can easily swap the roles of x and y? Is it based on any properties or formulas?

    • @jbstatistics
      @jbstatistics  8 месяцев назад

      The initial term is sum (X_i - X bar)(Y_i - Y bar). While in the video I split up the (Y_i - Y bar) term, leaving (X_i - X bar) intact, I could have just as easily split up the (X_i - X bar) term instead, and using the same steps as I did in the video, end up with sum (Y_i - Y bar)X_i.

  • @IS-xm8bc
    @IS-xm8bc 4 года назад

    Why do we take sum of squared residuals and not only residuals and do their partial derivative wrt alpha and beta

  • @francismali5840
    @francismali5840 6 месяцев назад

    Ouch😂😂😂 God is faithful 🙏🙏

  • @preethidonthu2433
    @preethidonthu2433 2 года назад

    Thank u soooo much! For explaining this. You made my day

  • @reinier5355
    @reinier5355 3 года назад

    great video, my summary just gave the formula with the text: 'just remember this' hate that

  • @翔_shaun
    @翔_shaun 4 года назад

    THANKS GOD FINALLY SOMEONE TRIED TO DERIVE THE FORMULA,
    INSANE THAT NEARLY ALL OTHER RESOURCES OMIT THIS SHIT

  • @forheuristiclifeksh7836
    @forheuristiclifeksh7836 3 месяца назад

    least square mthod vs

  • @mattiasmalmgren8723
    @mattiasmalmgren8723 Год назад

    10:11 I don't understand. If the term sum of (Yi-Y_bar) is 0, then whey is not the first term also 0. It is the same, just multiplyed with Xi instead of X_bar. Also I did not understand the multiply through thing. Make this clearer please in a new video.

    • @jbstatistics
      @jbstatistics  Год назад +1

      If I made a new video to illustrate each point somebody doesn't understand, I'd have 8000 videos on just the binomial distribution. Almost all of them would be painful for most to watch, explaining how to raise a number to a power, what the binomial coefficient is, what factorials are, then a detailed discussion on why a calculator gives an error if you try to get 72!, etc.
      How many hours do you think went into this? Just the 12 minutes plus upload time?
      This video is very clear, but it requires some background knowledge on summation basics that you do not seem to have. I could spend half an hour discussing in painstaking detail why we can take X bar out front, but I assume that people are comfortable with the notion that multiplicative constants can come out front of the summation, and, as I say in the video "X bar is a constant with respect to the summation." Why? It's not changing as i changes (I don't see a subscript i on it). Multiplicative values that change as i changes, such as X_i, cannot come out front of course. That is a fundamentally different situation; one thing is changing as i changes, the other is not. Those are basics of working with summations.
      Since X_i cannot come out front of the summation, there is no reason to believe that sum (X_i - X bar)X_i equals 0, even though sum (X_i - X bar) does. This is straightforward to show for oneself with a very simple example. Suppose n = 2 and X_1 = 4, X_2 = 6. Then X bar = 5, sum (X_i - X bar) = -1 + 1 = 0, and sum (X_i - X bar)X_i = (-1)*4 + 1*6 = 2. We don't typically have to show an example like that though, as there is no reason to believe it's 0 in the first place. And since it's equivalent to sum (X_i - X bar)^2, it'll only be 0 if all the X values are equal.
      (a+b)^2 = (a+b)(a+b) = (a+b)a + (a+b)b. This isn't an esoteric notion. At some point, the learner has to fight for themselves to understand the things they don't grasp at first.
      A derivation like this only makes sense if one is comfortable with the basics of working with summations. If I always explain every bit of background required, every video would be very long and just terrible.

    • @mattiasmalmgren8723
      @mattiasmalmgren8723 Год назад

      @@jbstatistics OK, maybe I can work it out with help from your last comment. I'll try. Thanks.

  • @Sulegibongtoo176
    @Sulegibongtoo176 2 года назад

    Wow many university lecturers can’t explain it this well!

  • @eltuneyvazzade8845
    @eltuneyvazzade8845 2 года назад

    Very helpful video to understand. Many thanks!

  • @IvanJacobsvelocity
    @IvanJacobsvelocity 3 года назад

    thank you 100^100 times

  • @Dupamine
    @Dupamine Год назад

    Where can i learn more about how do summations work? You talked about so many rules of summations which i wasnt familiar with . Can you explain where i can find such rules?

    • @mattstats399
      @mattstats399 Год назад +1

      They don't teach summations enough in school in my opinion. The biggest thing to know is that summations are linear operators, meaning Sum(ax+by)= asum(x)+bsum(y) where a and b are constants and x and y are being summed by the summation.

    • @Dupamine
      @Dupamine Год назад

      @@mattstats399 is there some book Or website where I can see examples of advanced summations?

    • @mattstats399
      @mattstats399 Год назад

      @@Dupamine Not really. The best way is to do more problems that deal with summations. My background is statistics, so areas like mean, variance, and maximum likelihood are full of them.

    • @Dupamine
      @Dupamine Год назад

      @@mattstats399 I am studying some advanced statistics and I find such complex summations such as summations in elementary symmeteic functions where you sum over different patterns of things and also multiply something. Or summations where j is not equal to k. And this is nothing. I've seen summations with like so many things written beneath it. I don't know how to handle these summations

  • @zhuwenhao4852
    @zhuwenhao4852 9 месяцев назад

    I love jbstatitics.

  • @fisher4651
    @fisher4651 2 года назад

    LEGEND, HAVE TO SAY YOU ARE BETTER THAN A PROFFESOR

  • @matheshs-y8b
    @matheshs-y8b 2 месяца назад

    thank you so much

  • @bdrgn
    @bdrgn 3 года назад

    Great tutorial! I could use some ideas of how to better teach the material.

  • @xavieribanez-padron4857
    @xavieribanez-padron4857 9 месяцев назад

    god bless you brother

  • @singsongsou1865
    @singsongsou1865 4 года назад +1

    Thanks a lot!!!

  • @atomu9663
    @atomu9663 Год назад

    Good video Thanks!

  • @alexa-lv6di
    @alexa-lv6di 3 года назад

    How do we do this if we have three or more unknown parameters?

  • @fma-d8j
    @fma-d8j 2 года назад

    Thank you very much. This video helped me a lot.

  • @dalkeiththomas9352
    @dalkeiththomas9352 3 года назад

    You sir are AMazing

  • @girlstrends8204
    @girlstrends8204 8 месяцев назад

    you make it sooo easy

  • @1UniverseGames
    @1UniverseGames 3 года назад

    How can we find the intercept and slope value of B0 and B1

  • @DHDH_DH
    @DHDH_DH 8 месяцев назад

    You are awesome! I am not a native speaker and still struggling with the master program courses in the US, but your instruction is so helpful. I appreciate your great help

    • @jbstatistics
      @jbstatistics  8 месяцев назад

      Thanks! I'm happy to be of help!

  • @ezozakamolova885
    @ezozakamolova885 11 месяцев назад

    Thank you so much

  • @naderelzik5474
    @naderelzik5474 Год назад

    10:29 why is the sum of the deviations is always 0 ?

    • @avellanedam
      @avellanedam Год назад

      When we split Sum(Yi - Ybar) into Sum(Yi) - Sum (Ybar), we get Sum (Yi) - n*Ybar. Then we know from descriptive statistics that Ybar = Sum(Yi)/n, therefore Sum(Yi) = n*Ybar, if we substitute Sum(Yi) in the Sum (Yi) - n*Ybar, we get n*Ybar - n*Ybar = 0

  • @jesabumaras4758
    @jesabumaras4758 2 года назад

    Thank you very to clear explanation ❤

  • @promasterliuss
    @promasterliuss Год назад

    good explanation!

  • @anonymousAI-pr2wq
    @anonymousAI-pr2wq 2 года назад

    Thanks for the video. Just wondering why x and y can be considered constant when differentiate against B0 or B1? Is it because of partial differentiation or X and Y are known numbers?

    • @yaweli2968
      @yaweli2968 2 года назад

      I think you are arguing why Bo hat and B1 hat should be considered constants for the sample.They are clearly not going to change for that sample.

  • @edforwardgaming69420
    @edforwardgaming69420 4 года назад

    Aku gangerti soal nya bu nur, jawab song

  • @joansome951
    @joansome951 Год назад

    Great job! Thank you sir!

  • @tastypie2276
    @tastypie2276 3 года назад

    Thank you very much! Very clear and interesting explanation!

  • @asad_rez
    @asad_rez 3 года назад

    Thank you for explaining in such details ❤️

  • @MahnoorNaveed-
    @MahnoorNaveed- 2 года назад

    thank u so much.

  • @AJ-et3vf
    @AJ-et3vf 2 года назад

    Awesome video sir! Thank you!

  • @frequencyspectra1
    @frequencyspectra1 2 года назад

    Excellent video

  • @hawasadiki5292
    @hawasadiki5292 6 месяцев назад

    Thank you

  • @muhammaddzakyrafliansyah3587
    @muhammaddzakyrafliansyah3587 2 года назад

    You made it simpler than my lecturer do. Thank you!

  • @existentialrap521
    @existentialrap521 2 года назад

    Yeah iiiight thx G

  • @wuttinanlerkmangkorn7009
    @wuttinanlerkmangkorn7009 3 года назад

    Best explanation, thank you so much