Linear Regression – An Example

                In this video, we'll take an example of using the general straight line regression model. So, here is example given to us: we are basically given the torque which is required to open up a torsional spring of a mouse trap through a certain angle. So, as you start from zero degrees, the amount of torque which is required to open it will keep on increasing. So, we are relating it to a general straight-line model, where torque is equal to k1 plus k2 times theta. And what we want to do, is we want to find out what these two constants of the regression model are. So, let's go and see how we can apply the formulas which we learned in the previous lesson to find k1 and k2.

                So, to recap what we did in the derivation of the straight-line regression model, we have torque equal to k1 which is the intercept and k2 which is a slope. And where k2 will be given by the following formula here. So, that's the numerator, and now this one forms the denominator of the formula, and k1 is nothing but the average value of t bar minus k1 times the average value of theta bar. So, the bottom line is that hey, we need to find out this summation, we need to find this summation, and this one, and this one, and we're done. Let's go ahead and see how we can do that, and we'll do that in the table so that we can go through this, finding the summations from the individual values of the angle and the torque.

                So, if you see that these values are already given to us for the angle and the torque, so I’m going to write these down again. These are from the problem statement, and the torque is given as follows. And now what we want to do is, as we can see that hey, we need the summation of theta, so that turns out to be equal to 6.28 as i is 1 to 5. This summation here turns out to be equal to 1.18. But the other things which we have to calculate are the values of the theta squared. So, if I put down what theta squared is, I put down them here. So, we're going to sum these, and that number turns out to be this one. Then the next summation which I need to find out is theta t, and so what that means that I multiply these two quantities for each of the five data points given to us. And those turn out to be as follows, and if I add all of them up, I will get the following number right here. So, having said that, let's go and write what we have here as the value of k1 or k2. So, k2 is n summation n is 5 in our case because we have five data points. So, the summation of the theta i and t sub i values, minus the summation of the five values of theta, the summation values of the torque, and we divided by 5 times the summation of the theta squared values, and then sum the theta i values, and we square those. So, that's what we have here. So, we can now substitute the values of the values which we just found out, so it's 5 summation of theta i t sub i is right here, that’s 1.5726. The summation of theta i is right here, the summation of t sub i is right here, and let's divide by five. What is the summation of theta squared? It's given by this quantity right here, and then the summation of theta i, and then squaring it will be squaring this quantity right here. And this number here will turn out to be equal to 0.09507. Let's go and see what we get for the value of k1.

                So, let's go and find k1. k1 is nothing but t bar minus k2 theta bar. So, t bar will be the average value of all the t values minus k2, which we just found out. And theta bar will be the average value of the theta values, which is 6.28 divided by 5. So, once we calculate this value, we get 0.1166. So, our general model was torque is equal to k1 plus k2 theta. So, k1 we just found out was 0.1166, and k 2 we found from the previous slide which was this quantity right here. So, that's our general linear regression model for our torque versus theta for this particular case here. Make sure that you understand that the units of this are newton meter, and the units of this are also newton meter because torque is in newton meter. So, the intercept will be newton meter but also the slope in this case is newton meter because theta is a dimensionless quantity. And that is the end of this segment.