Question Video: Finding the Equation of a Regression Line of a Linear Regression Model Mathematics

The following table shows the relation between the lifespan of cars in years and their selling price in thousands of pounds. Find the equation of the line of regression in the form 𝑦 hat = π‘Ž + 𝑏π‘₯, writing π‘Ž and 𝑏 to 3 decimal places.

07:38

Video Transcript

The following table shows the relation between the lifespan of cars in years and their selling price in thousands of pounds. Find the equation of the line of regression in the form 𝑦 hat is equal to π‘Ž plus 𝑏π‘₯, writing π‘Ž and 𝑏 to three decimal places.

In this question, we’re given some information given to us in the form of a table. We’re given the lifespan of a number of cars, which is measured in years, and we’re also told the selling price of those cars in thousands of pounds. The question wants us to use this table to find the line of regression which best fits this data. We need to give our answer in the form 𝑦 equals π‘Žπ‘₯ plus 𝑏, giving our values of π‘Ž and 𝑏 to three decimal places of accuracy. In answering this question, we’re going to use the least squares regression method to find our line of best fit. So the first thing we should do is recall how we do this.

To find the line of regression by using least squares regression, we can find the values of π‘Ž and 𝑏 by using the following formula. First, our value of 𝑏 is equal to 𝑠 sub π‘₯𝑦 divided by 𝑠 sub π‘₯π‘₯, where it’s worth pointing out here 𝑠 sub π‘₯𝑦 is a measure of the covariance between π‘₯ and 𝑦 and 𝑠 sub π‘₯π‘₯ is a measure of the variance of π‘₯. We can find these by using the following formula: 𝑠 sub π‘₯𝑦 is equal to the sum of π‘₯ times 𝑦 minus the sum of π‘₯ multiplied by the sum of 𝑦 over 𝑛. And 𝑠 sub π‘₯π‘₯ is equal to the sum of π‘₯ squared minus the sum of π‘₯ all squared over 𝑛, where 𝑛 is the number of data points we’re given. Similarly, we can find the value of π‘Ž is equal to the mean of 𝑦 minus 𝑏 times the mean of π‘₯.

And remember, we can find the mean of a value by summing over this value and dividing by their number. So the mean of 𝑦 is the sum of 𝑦 over 𝑛, and the mean of π‘₯ is the sum of π‘₯ over 𝑛. Now, these formulas look very intimidating. However, we only need to notice there are four things we need to calculate to fully find the values of π‘Ž and 𝑏. We need to find the sum of π‘₯. We need to find the sum of 𝑦. We need to find the sum of π‘₯ multiplied by 𝑦. And we need to find the sum of π‘₯ squared. Then, all we need to do is plug these values into our formula to find the values of π‘Ž and 𝑏.

Before we find these four values, there is one thing worth pointing out. In this question, we’re told that the car’s lifespan is given by the variable π‘₯ and the selling price of our car is given by the variable 𝑦, but this is not always given to us. When it’s not given to us, we remember π‘₯ is our independent variable and 𝑦 is our dependent variable, so we would need to look at the information we’re given to determine which variable is independent and which variable is dependent. And in this case, it makes sense for the car’s lifespan to be our independent variable because it is the one affecting the selling price of the car. So let’s start by finding the sum of our π‘₯-values and the sum of our 𝑦-values.

To find the sum of our π‘₯-values, all we need to do is to add all of the π‘₯-values given to us in the table. Adding all of these π‘₯-values together, we get 25. So the sum over π‘₯ is equal to 25. We can then do the same for the sum over 𝑦. We’re just going to need to add together all of our 𝑦-values. We just add all of these values together into our calculator giving us 553. So the sum of 𝑦 is equal to 553. But there are two more expressions we need to find. We need to find the sum of π‘₯𝑦, and we need to find the sum of π‘₯ squared. Let’s start with the sum of π‘₯ squared. This means we’re going to need to square all of our π‘₯-values before we add them together.

Our first π‘₯-value is five, so we get five squared. Our second π‘₯-value is two, so we need to add on two squared. Our third π‘₯ value is two, so we need to add on another two squared. And we need to continue doing this until we’ve added the square of all of our π‘₯-terms. This gives us the following expression for the sum of π‘₯ squared. And if we calculate this expression, we see it’s equal to 97. All that’s left to do now is to find the sum of π‘₯ multiplied by 𝑦. And to do this, we need to look at the columns of our table. In the first column of our table when π‘₯ is equal to five, we have 𝑦 is equal to 71. So when we’re adding together all of our π‘₯ multiplied by 𝑦, we need to multiply these together. We get five multiplied by 71.

We’re then going to do exactly the same in the second column of our table. In this column, we see when π‘₯ is equal to two, 𝑦 is equal to 83. So we need to multiply these together and add the result. And we need to carry this on for every single column in our table. This gives us the following expression for the sum of π‘₯𝑦. And if we calculate this expression, we get the sum of π‘₯𝑦 is equal to 1857. We’re now almost ready to find the values of π‘Ž and 𝑏. However, there is one more thing we need to note. We need to find the value of 𝑛, and it’s our number of data points. We can see from the table, we have eight data point, so our value of 𝑛 is eight.

Now that we’ve found the sum of π‘₯, the sum of 𝑦, the sum of π‘₯ squared, the sum of π‘₯𝑦, and 𝑛, we’re ready to start finding the values of π‘Ž and 𝑏. Let’s start with finding the value of 𝑠 sub π‘₯𝑦. We just need to substitute our values for the sum of π‘₯𝑦, the sum of π‘₯, the sum of 𝑦, and 𝑛 into our formula. Doing this, we get 1857 minus 25 multiplied by 553 over eight. And if we calculate this, we get 1031 divided by eight. We’ll then do exactly the same thing to find the value of 𝑠 sub π‘₯π‘₯. Remember, the sum of π‘₯ squared is 97, the sum of π‘₯ is equal to 25, and our value of 𝑛 is equal to eight, so this gives us 97 minus 25 squared over eight. And if we calculate this, we get 151 divided by eight.

We’re now ready to find the value of 𝑏. 𝑏 will be the quotient of these two values. So the exact value of 𝑏 is going to be 1031 over eight divided by 151 over eight. Of course, remember, whenever we’re dividing two fractions, we can instead take the reciprocal of the second fraction and multiply. This gives us 1031 over eight multiplied by eight over 151. We can cancel the shared factor of eight in the numerator and denominator, and this just leaves us with 1031 divided by 151. Now the question wants us to give the answer to three decimal places. However, we’ll do this at the end. Instead, let’s now find an expression for the value of π‘Ž.

Once again, to find the value of π‘Ž, we need to substitute in our values for the sum of 𝑦, the sum of π‘₯, 𝑛, and 𝑏. This gives us π‘Ž is equal to 553 over eight minus 1031 over 151 multiplied by 25 over eight. And it’s very important we use the exact value of 𝑏 when we calculate this expression. Otherwise, when we round our value of π‘Ž, we might get the wrong answer. And if we calculate this expression, we get that π‘Ž is equal to 7216 divided by 151.

But remember, the question wants us to give our values of π‘Ž and 𝑏 to three decimal places. Let’s start with our value of π‘Ž. Writing this out in its decimal expansion, we get 47.7880 and this expansion continues. To write this to three decimal places, we need to look at our fourth decimal place to determine whether we need to round up or around down. The fourth decimal place is zero. This is less than five, so we need to round down. So our value of π‘Ž is 47.788 to three decimal places.

Let’s now do the same for our value of 𝑏. Writing out the decimal expansion of our fraction, we get 6.827 and this expansion continues. We look at the fourth decimal place to determine whether we need to round up or round down. We see this is equal to eight which is greater than or equal to five. So we need to round up, giving us that to three decimal places our value of 𝑏 is 6.828. And remember, the question wants us to give this in the slope–intercept form of a line. We get 𝑦 hat is equal to 6.828π‘₯ plus 47.788 which is our final answer.

Therefore, given a table with different cars’ lifespans and their selling price, we were able to find the line of regression giving the coefficients to three decimal places. We got 𝑦 hat would be equal to 6.828π‘₯ plus 47.788.

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy.