Multiple Regression: Two Independent Variables Case - Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys it's Jonathan Lambert with the mathematics development and support service at the national college of college of ireland and in this video video dealing with multiple linear regression it's not actually gonna be shortly there's a lot involved here and we're gonna try to estimate the coefficients for a multiple linear regression model but in this case not too simple in your regression model when we have one independent variable when we actually have two independent variables and maybe just to motivate this I have something that I have actually already don't you to excel to the excel data analysis toolpak and where I have a dependent variable Y and I have two independent variables x1 and x2 and I have set of observations have 5 observations across those independent variables and what I'd like to actually find is the line the best fit I actually are the plane the best fit that actually goes to don't that close to that dataset really what we're trying to estimate is we're trying to estimate these particular coefficients here but Excel is already done for us so to do that and well let's just look at the line the line of best fit that we're trying to estimate is is y is if the b0 plus b1 times the exponent variable plus b2 times the X 2 variable so we really want to estimate b0 b1 and b2 once we have that we actually have our plane name which is the relationship between the independent and dependent variables so let me just actually rewrite this data down here cuz we're gonna have there's a lot of calculations involved and actually just got around two Y values to one a whole number so we're actually gonna be estimating these values here yeah so we'll hopefully we will be close enough where our calculations by hand so the Y values so we're gonna have our Y values and and then we're gonna have our X 1 values and our x2 values and so we have minus 3.7 and we have 3.5 we have 2.5 we have 11 eleven point five and we have five point seven and then we have three four five six and two and then we have eight five seven three and one okay that's our set data let me just actually I've got a ruler here cuz I'm gonna try to keep is me as mean as me as possible yeah so let me just like she just do a line across here right that's our date it okay and I'm just try to keep everything in line here right so that's our yeah I'll do is I'll just put a little fire down here I don't stick keep these values separated okay there you go there's our data and what we'd like to do at the cockily 0p wanna beat you know there's a lot of formulas involved in this okay so what I'm gonna do is I'm just gonna give you the formulas yeah okay and then what we're gonna do is we're just gonna warm it yeah I will do another video on how we in relation to how we can actually calculate these formulas and derived okay and so the b0 value at the b0 value B 0 is equal to the average of the Y's - the be warm value times the average of the x one variable - the b2 values times the average of the x two variable so it's actually calculating intercept we need to have we need to have the b1 coefficients and the B two coefficients calculate it so we really need to know what's the formula for the B wanted to be two coefficients so for b1 maybe the form looks something like this it's a bit complicated now but let's just bear with it and it's the sum of the x2 squared values times the sum of the X 1 Y value so there's like a cross product going on here and minus the sum of the X 1 values X 2 values times the sum of the X two Y values and that needs to be divided by paint it needs to be divided by the sum of the x1 squared values times the sum of the x2 squared values minus the sum of the X 1 X 2 is all to be squared okay yeah to be 2 values but the b2 values we just flip we flip the distinct the coefficients um hey so we're gonna flip the coefficients so to be 2 values and it's gonna be just so many it's gonna be the sum of the x1 squared values you do a I flip the coefficient here I'm sorry the in to say yeah that was representing the variable at times the sum of the X to Y values - well that's gonna be the same imma flip X 1 X 2 times the sum of the X 1 Y values and that's divided by this denominator remains the same it's the sum of the x1 squared values times the sum of the x2 squared values minus the sum of the x1 x2 squared values okay so it's not obvious but unfortunately this is actually a transformation with these these X's here in these wires aren't actually representing these values here so we've got another small set format allows calculate these summations yeah so what we have is this is that we have we have the disown the sum of the X the X I squared values is simply equal to the sum of the x1 so the X I squared values the main variables that's a big X in this time yeah and minus the sum of the x warm exercise the X I squared values over n-name so now these variables here ok are dealing with these variables up here okay but let's iterate it across how many independent variables we have I mean so we got two independent variables so I'll be initially 1 when I is 1 and this becomes when I is 1 and the formulas just say write it down when I is equal to 1 this formula here becomes the sum of the x1 squared values is equal to the sum of the x1 squared values minus the sum of the X 1/2 B squared values over N when I is equal to 2 this formula here maybe I'll just put a formula in red ok this formula this formula here ok and becomes when I is equal to 2 becomes well the sum of the x2 squared values is equal to the sum of the X 2 variables squared minus the sum of the X 2 variable to be squared over over n okay so what we what we're able to do here now with this particular formula here is to calculate this value here this value here this value here this value here this value here and this value here ok so we've sort of got nearly a toward of the formula nearly at the formula just with our formula there hey and then we have si we have the cross-product of the independent variables with the dependent variables so we have a formula says that the sum of the X I Y is and is equal to and the sum of the variable X I times the widest the cross product here of the variable times the Y the times the dependent variable and minus the sum of the X I times the sum of the sum of the wires okay over N okay so now once again when I is equal to 1 and I is equal to 2 when I is equal to 1 this becomes the sum of the X 1 Y values are equal to the sum of the X 1 Y values minus the sum of the X ones times the sum of the wires over N okay and then when I is equal to 2 we have this is the sum of the X 2 y values is equal to the sum of the X 2 wires minus the sum of the X 2's times the sum of the wires over / n okay once again just formally here depending on how many independent variables we have okay and will be evaluated for each one so now we have X 1 Y and we have X 2 y so now we have X 1 Y and we have X 2 y we have X 2 y and we also have x one why do you only thing that we're missing now is this cross product of the of the two independent variables okay and maybe what I'll do is I'll just write that down me in the cross product of the two independent variables the final one name the final one to do to calculate the final one to calculate is where we have the sum of the X 1 X 2 s is equal to the sum of the X 1 variable times the X 2 variable s the cross product of the independent variables Hey - the storm of the X 1 times the sum of the X 2 / / n okay so we have to do all these calculations yeah and so let's get started okay so you can probably see what we need from a calculation perspective as I said we need to calculate we need to calculate the squared of the independent variable we'll need to do that name we need to calculate the cross product of each independent variable to dependent variable okay and that's sort of does Allah justify everything that we need so let's do that so we need to calculate the square so we're gonna have to calculate x1 squared we're going to calculate x2 squared we're gonna have to calculate x1 times y okay I'm gonna have to calculate x 2 x times y I mean so let me do it is here so we have and say I'll just make sure how my calculator here so that we mean we need precision here okay and so the X 1 variable squared well 3 squared is 9 mm-hm 4 squared is 16 5 squared is 25 6 squared is 36 and 2 squared is 4 okay and the X 2 variables squared - 8 that's 64 and that gives us 5 5 is 25 7 squared is 49 3 squared is 9 and 1 squared is 1 now the cross product the X 1 variable times the independent variable so it's tree times minus 3.7 gives us a value of like this is a value of minus 11 point 1 and it's 4 times 3.5 which gives us a value of 14 then it's 5 times 2 point 5 which gives us a value of 12 point 5 and then it's 6 times 11 point 5 gives us a value of 69 and then it's 2 times 5.7 gives us a value of in this case we have eleven point four okay and then we have the second independent variable times the Y value so the cross product for the second independent variable times the dependent variable so in this case we have it's eight times minus 3.7 gives us a value of minus twenty nine point six and then it's five times three point five gives us a value of 17 point five okay and then it's seven times two point five gives us a value of seventeen point five as well okay seventeen point five and then it's three times eleven point five gives us a value of 24 point five okay and I find it's one time 5.7 gives us a 5.7 so one check these two here again five times 3.5 here's the value of 17 by five and seven times two point five gives the value also of 70mm five brilliant okay so now we have all of these done but what we require is we actually require and the summations two summations of doles particular of those everything here on the right hand side of these these particular values are are actually are independent on our dependent variable it's been calculated wait and then what we're going to do is want to bring them together this is like sums of squares going on here bringing them together to give us these coefficients that feed in the feed into the parameters so what we need to do now is we need to sum all of these guys okay and so we need our Sigma values and typically we would write all of our summations on the knee here but I'm just gonna do them on the top here so there's so many x1 squared values is gonna be 9 plus 16 plus 25 plus 26 plus 4 gives this value of 90 actually maybe I'll write that down here so what I have now is I've just calculated okay and the sum the sum of the X 1 so this is the so DX 1 squared values yeah actually let me write that down a little bit differently yeah yeah so there for a moment let me just cover this right here so I want to write it down as the sum of the x1 squared values is actually equal to its equal to 90 brilliant and now this x2 squared values the second independent variables squared is 64 plus 25 plus 49 plus 9 plus 1 gives the value of 148 actually I'm just checked out again so you have 64 plus 25 plus 49 plus 9 plus 1 gives us a hundred 48 so we now we have the sum of the x2 squared values is 148 let's do the cross-product of the x1 and the wires okay yeah so we have a minus 11 point 1 plus 14 plus 12 point 5 plus 69 plus 11.4 gives us a value of ninety five point eight so now we have the sum of the X 1 y values is equal to ninety five point eight and then finally let's look here the final one here this role is the cross product of the second independent variable with the dependent variable gives us minus twenty nine point six plus seventeen point five plus seventeen point five plus forty four point five plus five point seven gives us a value of we have the sum of the x - y values is equal to forty five point six okay what else do we need here well we're going to need other things we're going to need the sum of the X values the X 1 values is sum of the x two values and we're also going to need to sum of the Y values so we need to solve a sovereign independent variables so does sum of the X ones is equal to but what we got here we have three plus four plus five plus six plus two gives us a value of twenty we needed some of the x2 values and what we've got we have eight plus five plus seven plus three plus one gives the value of 24 and finally we needed some of the Y values sort of some of the Y values we have minus three point seven plus three point five plus two point five plus eleven point five plus five point seven gives us a value of or the solar wires is equal to nineteen nineteen point five okay so we're nearly there now and we've got all of these things now calculated and we need to really what we need to now do is substitute them into our formulas okay so we've calculated all of these i suppose i say the squares and the cross products of the independent variables with the dependent variable and so on and then what we need to do is we need to start plugging them in here so i'm gonna do this calculation here which is just some of the small x one squared first of all which is simply equal to this sum here okay so let's have a look at that so we're gonna now have and so it's the sum of the small x one squared is equal to well it's equal to the sum of the force independence squared yeah okay so that is ninety so it's equal to 19 - okay the sum of the force independent variable okay which is 22 B squared that's 22 B squared divided by and how many observations we have and we've got five well how many pairings of observations and we have five sets of observations so that's the first value and the second one is the sum of the X 2 squared values and is equal to the sum of the X 2 the square root of these sum of the squares of the X 2 variable okay which is 148 okay 148 - and the sum of the X 2 variable which is sum of the X 2 variable which is 24 - B squared that's 24 - B squared over 4 over 5 right let's just do them two calculations so now what we have is the first one is we have 90 minus 20 squared which needs to be divided by 5 because this is a value that comes out nice and no matter of 10 okay then we have ahold of 48 - we have 24 - B squared divided by 5 and that gives us at 42 42 point 42.8 there okay brilliant so what we've actually just calculated now is we've calculated this and we've also calculated this thing here thanks so it's continuing on now and let's calculate this the cross product yeah okay of the X ones okay and the force independent variable is the dependent variable so now we have the sum of the X 1 Y's is equal to well what is it it's it's the sum of the cross product of the independent variable the Force One with the dependent variable so it's the sum of X 1 Y which is ninety five point eight so what's 95 point eight - minus the sum of the X ones okay times some otherwise okay so there's so many X 1 oops some of the X ones is 20 so it's minus 20 times the sum of the Y's which is nineteen point five and that needs to be divided by divided by 5 and then the second one when I is equal to 2ei we have the sum of the X two wires is equal to the cross products the sum of the X 2 variable times the dependent variable so to sum of the X 2's which is times the Y's which is forty five point six that's forty five point six - and there's some of the x 2.is x is some other wires so just some of the x 2.is is 24 so it's times 24 times nineteen point five over five which gives us well nearly there we are and so now in this case here let's just do the force we have ninety five point eight minus 20 times nineteen point 5 divided by 5 gives us a value of seventeen seventeen point eight and then here we have this is its forty five point six minus 24 times nineteen point five divided by five gives the value of minus 48 so minus 48 nearly there now and then finally what we have so now what we'll actually calculated here is we've tackled this and we've calculated i fit this so the final thing to calculate is actually it's actually this guy it's actually just going here okay so now we have the sum sum of the x 1 x 2 s is equal to the sum of the cross product of the force independent variable with the second independent variable well she didn't do that calculations and let me actually just go back here and so we have to actually do and the x ones the x ones times the x tools we haven't done that calculation yeah well three eight is 24 four five is twenty-five seven is twenty five and six threes is 18 and two ones is 2 okay so let's just sum these up so we have 24 plus 20 plus 25 plus 18 plus two because this value of 99 so now we have actually the sum the sum of the X 1 X 2 s is is 99 okay so this table always looks like this this table ain't gonna change this table is always going to have this particular form here okay and which is important to here to keep an eye on yep so now just continuing on now we have this one of the X 1 X 2 s is the cross product of the X 1 X 2 variable which is 99 okay - to so many X ones well there's so many X ones is 20 times there's so many ex tools which is 24 okay divided by five which gives us a value of in this case we have it's 99 minus 20 times 24 divided by 5 gives the value gives this value of 3 okay so now we're good to go so now we have all of these coefficients ok so we have all the coefficients and now what we can do is we can now calculate we can Oakley rb0 rb1 and rb2 all right so what I'm gonna do is we're going to need all of these values here these are all very important for us right I'm just got this sheet here and these are the justa finda stuff I suppose the final sort of set of values that we're going to look that with that we actually require I mean let me just maybe fold this over here so here we don't and now I'm ready to calculate there B the B value for something so to be 1 value was a so let's have a look at this here so we have to calculate the B one's force so RB 1 values are it's the sum of the small x2 squared values and there's the sum of the small X 2 squared values is 22 42.8 okay times the sum of the small X 1 Y values or there's a small X 1 Y values is 17 17 point 8 - the so many x1 x2 is a small X 1 X 2 which is tree ok times the sum of the X 2 wires are the sum of the X 2 y is minus is minus 48 and that needs to be divided by that needs to be divided by and the sum of the sum of the x1 squared values there's so many X 1 squared values which is 10 K times the sum of the X 2 squared values sum of the X 2 squared values is 42.8 and - there's so many X 1 X 2 's to be squared so sum of the X 1 X 2 is to be squared which is tree to be squared ok that's the B 1 value ok let's actually just do that calculation here so now I have B 1 is equal to let's just do the numerator 22.8 x 17.8 oh 22 point each time 17.8 gives us value minus times minus is a plus a plus 3 times 48 it's gonna give us a value of that's seven hundred and twenty seven point two eight four divided by hey this denominator here is important because it's shared this denominator is shared in the be two value so I'll just do this calculation here so this is a tree hold ten times that's three hundred and twenty eight minus minus nine gives us a value of three hundred nineteen so that's three hundred nineteen so when we do the division here we end up with let's do it we have seven two seven point eight four divided by three one nine gives us a value of it's approximately two point two eight is rb1 coefficient rb2 coefficient the b2 is the sum of the x1 squared and we've already got the x1 squared so they're in the denominator here they're ten okay at times somebody X to Y so the X to Y is minus 48 okay and - there's so many X 1 X 2 s which is tree okay times there's so many x1 wires which is which is 17.8 which all needs to be divided by this common denominator here okay it's common across b1 and b2 hey this denominator which is ten times twenty two point eight minus three - B squared which now gives us a b2 value okay and we have that's four that's - 480 a minus 3 times 17 point eight gives us a value of minus five hundred forty three point four which needs to be divided by 319 which gives us a value of let's divide that by three one line which gives us a value of minus one point six seven ok so that's era b1 now so now we have our B walnut our B - here's our B one value here here's our b2 value right here and finally we need to calculate our B zero value okay so let's have a look at the B 0 so the B zero value our b0 is equal to it's the average of the Y is okay so it's the average of the Y as well we know what the average of the Y's are as well as some of the Y's is nineteen point five so the army Aya's is nineteen point five over five okay - to be one value which is two point two eight times the average of the x ones well the sum of the x ones is twenty so it's times twenty over over five - and the B - value which is - which is minus one point six seven a times DX two values well the average of the x two values and the X two values of some of the excuse is 24 so it's times 24 over over five which gives their B zero value gonna be squash their that was yeah okay so let's see what we have so we have it's nineteen point five divided by five because it's not value here there's gonna be negative so it's minus two point two eight times 20 divided by 5 gives us that value there - sighs - plus and one point six seven times 24 divided by 5 gives us a value of it's two point seven nine six so we have B 0 is equal to two point seven nine six so the equation of the line now this is our this was our final and guess a parameter that was required so the equation of the line don't forget is y is equal to b0 plus b1 times x1 plus b2 times x2 so our line actually becomes y is equal to two point seven nine six B 1 is two point two eight plus two point two eight times our X 1 values and minus one point six seven times our x two values and that is the model that we've just estimated okay and we could 1 then we'll calculate residuals and so on but that's our model let's just see how down that fares out against what we actually did earlier on oh there you go the intercept we've previously calculated with a don't forget of rounding and things like that in here and I will around the original the original at dependent variables you next you know the intercept as to excel the data analysis toolpak is two point seven nine which is what we have here okay and the x1 value is two point two seven two point two to eight we have which is this rounded decimals and then finally the coefficient the B the B 2 is minus one point six seven here as minus one point six seven so even with a bit rounding yeah we actually got these pretty bang on yeah so look guys I do appreciate that there was a lot of work involved and uh yeah I mean this video was after taking about 26 27 minutes there to to do yeah but once again this is Jonathan Lambert with the mathematics development and support service at the national college of Ireland and I hope that this video was in some way intuitive more importantly I actually hope that was helpful for you and thanks for watching okay bye-bye
Info
Channel: Maths and Stats
Views: 110,658
Rating: 4.8802762 out of 5
Keywords: Statistics, Multiple Regression, Multiple Regression by Hand, Two Independent Variable Case, Regression Slope, Regression Intercept
Id: m-k84cCves8
Channel Id: undefined
Length: 27min 18sec (1638 seconds)
Published: Tue Apr 30 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.