In the previous screencast, I showed you how you can make a general linear regression model of a single regressor variable, and this means that we only have one independent variable x. We are now going to consider the case when we have multiple regressor variables. In multi-linear regression, we have n regressor variables. So we have x_1, x_2, x_n and those are all inputs into the output, which again is why. We're also going to have p plus 1 parameters, where p is the number of different functions of x_1, x_2 up to x_n that we are interested in. So this actually looks a lot more complicated than it actually is in practice, but this is the generalization. We're going to work through an example here where we have an exam score. So we're going to try to predict the exam score, which is our output y, using some mathematical regression model that's going to use as inputs the hours studied, which is going to be x_1, and the hours of sleep the night before the exam, which is x_2. As a first-order model, we're just going to come up with a simple linear model in x_1 and x_2, which is shown down here. Y equals an intercept Beta_naught plus Beta_1 x_1 plus Beta_2 x_2. So what are the functions of x_1 and x_2 that we are going to be using in this regression model? We'll need to create a column for x_1 on this spreadsheet and for x_2. This is such a simple model that we've already got x_1 and x_2 on the spreadsheet. So let's go ahead and work through this in Excel. I've got this spreadsheet on the course website. You can go ahead and download it if you want to work along with me. We go out and collect experimental data. Remember you always need experimental data in order to make a regression model. I've got my exam score over here on the left. That's our dependent variable. I have my two independent regressive variables here. We have hours studied and hours of sleep the night before the exam. So we're going to go ahead and use the regression tool, is just like we did for the single regressive variable, but now we've got two different variables. Right now, remember, the model that we're working through right now is just this simple model here, where y is just proportional to x_1 and x_2. So we've already prepared the spreadsheet for the two functions of x_1 and x_2. F1 of x_1 and x_2 is just x_1, f2 of x_1 and x_2 is just equal to x_2. If we wanted to, we could add on more complicated terms. For example, we could add on Beta_3 times x_1 times x_2 if we wanted to. We could also add in quadratic terms and the sky is the limit for the different types of terms that you could add on here to see what effect they have on your model. Remember, ultimately, what you're trying to do is to find a good model with a good adjusted R-squared without having too many terms in your model. So we're all set to use the regression tool. I go up here to the Data, Data Analysis, and we're going to go ahead and click on Regression. Click OK. The y input range is going to be the output, and I'm selecting the top row, so I'm going to click on Labels here. The x-range then is the two columns corresponding to our functions of x_1 and x_2, which are just simply x_1 for the first one and x_2 for the second one. Oh, I'm also going to select Residuals because that'll give us our model predictions, and I'm going to go ahead and click OK. Now it spits out this regression. I can highlight those autoscale. What we end up with, the important thing is the intercept. So that's Beta_0. The coefficient to x_1 is 2.53 and the coefficient to x_2 is 1.21. So we can substitute the coefficients we got here using the regression tool, back into our original model to getting mathematical equation that relates the hours studied for the exam and the hours of sleep the night before the exam to the exam score. So this is just a predictive model. Now we go over here to this residual output and this gives us the predicted based upon our model. Now it's hard to plot this because we have two independent variables. But what we can do is I can go over here to the predicted, and I'm just going to copy that, and I'm going to go ahead and paste over here. I've already put that label predicted, so I'm just going to paste the values. Now that's the predicted based upon our model. If we have a good model, the predicted should line up quite nicely with the actual. So you notice some of these are pretty good, especially that first row. Some of these are not quite as good as others, but if I plotted the actual, so I'm going to go ahead and select that as a function of the predicted or vice versa. It doesn't really matter. If I plot this on a scatter plot. If we've got a good model, then these value should lie on our x equals y line. So I'm going to go ahead and format this real quick. So I've scaled both axes, going from 70 to 100, I've added predicted score on the y-axis, actual score on the x axis, and if our model is doing a good job, then predicted should equal actual for all of our points and that all the data points should lie on a y equals x line. We can go ahead and go up here to Insert, Shape, and we can just put in a line here just manually, just to show graphically if we've got a good model or not. Again, if we've got a good model, all of the data points, the predicted versus actual, should lie close to that line. So this is a pretty good model. We can go back to our regression output and we can look at the adjusted R squared. We have about a 0.962 for our adjusted R squared, which is pretty good. Let's see if we can improve this model a little bit. Let's go ahead and add in a third term, which is a second order term. It just multiplies x_1 by x_2. So now we've got another function, that function of x_1 and x_2 is just x_1 times x_2. So now on our Excel spreadsheet, in order to include this third term or fourth term here, then we need to include a third column in our Excel data. So I'm going to go ahead and just right-click and insert a column. This was our predicted. I'm just going to go ahead and let's just delete those for now. Now we're going to add in x_1 times x_2, and I'm just going to drag down and type in equals. I'm going to do this vector times the x_2 vector, Control, Shift, Enter. Now we've got our third input into the regression tool. So we go back up to Data, Data Analysis, Regression, and I'm going to just now modify the input x range to be these three columns instead of the two we had, because we're adding in a third parameter into our model. I'm going to go ahead and click OK. We get a new spreadsheet. I'm going to format this just to scale the output, and we've got our coefficients here. Now the adjusted R squared you notice, is actually a little bit smaller, it's 0.958 than what we had with the first model. The first model we had 0.961. So adding that third term actually doesn't improve our model. We would have to look at something different. As a model designer, you have liberty in choosing what types of terms to include in your model. So you might hypothesize what happens if I add in maybe an x_1 squared term or an x_1 squared times x_2 term, or a one over x_1 term, or anything that involves x_1 and x_2, and for completeness, we can just come up with the mathematical equation that relates x_1 and x_2 to the output. There should actually be in x_1 in here, like that. So that's the general mathematical equation that we just created. One more thing here in this screencast, just showing you just another example of what you might want to do. Remember this here is a linear model, because it's linear in the coefficients. It doesn't have to be linear in these functions of x_1 and x_2. We just have coefficients multiplied by functions of x_1 and x_2. So this would be a function here. This is a function here, and this is another function. I hope you enjoyed this screencasts, and thanks for watching.