In the previous chapter, we learnt to describe the relationship between numerical variables. If there is a relationship, we can recognise when it is linear or non-linear, strong or weak, and positive or negative.
We can draw a line, by eye, that best fits the points in a scatter plot. The images below show some examples of a line of best fit. The line of best fit does not necessarily go through the data points. It is positioned so that it minimises the overall distance from the points.
Constructing a line of best fit in this way can be very useful because the line summarises all of the data points in a way that allows us to predict the value of the response (dependent) variable that corresponds to a given value of the explanatory (independent) variable, or vice-versa. However, it takes a certain amount of judgement to choose the position and angle of the line. Constructing the line by eye is not very reliable, especially if the scatter plot does not show a strong relationship.
Fortunately, there are mathematical calculations that we can use to determine a line of best fit with more consistency. In this lesson, we will learn to construct a least-squares regression line.
Try moving the points to see how the least-squares regression line follows the data.
The number of points above and below the line should be equal or differ by 1.
The least-squares regression line is a straight line, so it can be represented by a linear function, in gradient-intercept form: y=mx+c, where y is the predicted value of the response (dependent) variable, x s our explanatory (independent) variable, m is the gradient of our line, and c is the vertical intercept (or y-intercept) of our line.
It is common practice to use the symbol \hat{y} (which is pronounced "y-hat"), instead of y, as the variable for the predicted value of the response variable.
Unless we are working with a very small data set, the calculations to determine the least-squares regression line are too tedious to do by hand. In this course, we will use technology for these calculations.
Use technology to find the line of best fit for the data below.
x | 24 | 37 | 19 | 31 | 32 | 22 | 14 | 30 | 23 | 40 |
---|---|---|---|---|---|---|---|---|---|---|
y | -7 | -8 | -3 | -6 | -9 | -8 | -2 | -8 | -8 | -12 |
Write the equation with the coefficient and constant term to the nearest two decimal places.
The least-squares regression line is a straight line with equation of the form:
Now that we can determine the equation of the least-squares regression line, we are able to make important observations about the original data. When we are analysing data, it is important that we consider the context.
In the calculator examples above, y represents the vocabulary (the response variable) and x represents the number of pages read per day (the explanatory variable).
We found the least squares regression line in the form y=mx+c, to be y=14.87x+30.26.
The m value displayed is the gradient of the least-squares regression line. Since this is a positive number, it indicates that there is a positive relationship between the variables. In the context of this example, this tells us that for each additional page of reading per day, a child's vocabulary increases by approximately 15 words.
The c value provided is the vertical intercept of the line of best fit and, in the context of this example, tells us that a child that does no reading would have a vocabulary of approximately 30 words.
Given a least squares squares regression line of the form y=mx+c:
The m value shows the gradient:
if the gradient is positive, when the explanatory increases by 1 unit, the response variable increases by m units.
if the gradient is negative, when the explanatory increases by 1 unit, the response variable decreases by m units.
The c value shows the vertical intercept (also known as the y-intercept):
when the explanatory variable is 0, the value of the response variable is c.
When we interpret the vertical intercept, we need to consider if it makes sense for the explanatory variable to be zero and the response variable to have a value indicated by c.
The price of various second-hand Mitsubishi Lancers are shown below.
\text{Age} | 1 | 2 | 0 | 5 | 7 | 4 | 3 | 4 | 8 | 2 |
---|---|---|---|---|---|---|---|---|---|---|
\text{Value } \\ (\$) | 16\,000 | 13\,000 | 21\,990 | 10\,000 | 8600 | 12\,500 | 11\,000 | 11\,000 | 4500 | 14\,500 |
Find the equation of the Least Squares Regression Line for the price (y) in terms of age (x). Round all values to the nearest integer.
State the value of the y-intercept.
The value of the y-intercept indicates that when a Mitsubishi Lancer is brand new, its value is, on average, ⬚ dollars.
Does the interpretation in the previous part make sense in this context?
State the gradient of the line.
Which of the following is true?
Given a least squares squares regression line of the form y=mx+c
The m value shows the gradient:
if the gradient is positive, when the explanatory increases by 1 unit, the response variable increases by m units.
if the gradient is negative, when the explanatory increases by 1 unit, the response variable decreases by m units.
The c value shows the vertical intercept (also known as the y-intercept):
when the explanatory variable is 0, the value of the response variable is c.
The correlation coefficient was introduced in the previous chapter as a measure that tells us the strength of a relationship between two variables. It is denoted by the letter r. The sign of r also tells us the direction of the relationship.
A perfect positive correlation has a value of 1. That means that if we graphed the variables on a scatter plot, it would show that all the data points lie exactly on a straight line with a positive gradient.
A perfect negative correlation has a value of -1 in which case all data points lie exactly on a straight line with a negative gradient.
A value of 0 indicates that there is no relationship between the variables.
To be more descriptive about the relationship between variables, we can further divide up the line to indicate other values with descriptions like "weak", "moderate" and "strong", in the figure below.
The strength of correlation depends on the size of the r value, so we can ignore the positive or negative sign:
if the size is less than 0.5, then we have a weak correlation;
if the size of the correlation is greater than 0.8, then we have a strong correlation.
if the size is between 0.5 and 0.8, then we a moderate correlation.
Given the following data:
x | 1 | 4 | 7 | 10 | 13 | 16 | 19 |
---|---|---|---|---|---|---|---|
y | 4 | 4.25 | 4.55 | 4.4 | 4.45 | 4.75 | 4.2 |
Calculate the correlation coefficient and give your answer to two decimal places.
Choose the best description of this correlation.
The correlation coefficient, r, tells us the strength and direction of the correlation between two variables.
If r is negative the direction of the correlation is negative. If r is positive the direction of the correlation is positive.
The strength of the correlation depends on the size of r as shown below:
When we discuss the coefficient of determination or the value of r^2, we can already tell that it must be related to the value of the correlation coefficient (r) and something to do with measuring the relationship between two variables.
r^2 tells us the proportion of the response variable (y) that can be explained by the variation in the explanatory variable (x).
For example, if r^2=0.92 then we can say that 92\% of the variation in the response variable is explained by the variation in the explanatory variable.
Alternatively, we can say that 8\% of the variation in the response variable is not explained by the variation in the explanatory variable.
Unlike the correlation coefficient, the coefficient of determination is always a positive value, so it does not indicate if there is a positive or negative relationship between variables.
The closer r^2 is to 1, the more the variation in the response variable is explained by the variation in the explanatory variable.
If we already have the value of r, we can square the value to get r^2.
So if r=0.8, then r^2=0.64, and if r=-0.9, then r^2=0.81.
If we don't already have the value of r, our calculators will calculate it for us. In fact, the r^2 value is given on the same screen as the r value.
Just as with r values when two variables have a strong relationship, that is r^2 is close to 1, we cannot say that one variable causes change in the other variable.
A linear association between two data sets is such that the coefficient of determination, r^2, is 0.80.
Calculate the correlation coefficient if the relationship is negative. Give your answer to four decimal places.
Hence choose the option that best describes the strength of the relationship.
A linear association between two data sets is such that the correlation coefficient is -0.72.
What proportion of the variation can be explained by the linear relationship? Give your answer to the nearest percent.
The heights (in \text{cm}) and the weights (in \text{kg}) of 8 primary school children is shown on the scattergraph below.
Calculate the value of the coefficient of determination. Give your answer to two decimal places.
Calculate the value of the correlation coefficient. Give your answer to two decimal places.
What percentage of the variation in weight is accounted for by the height of the child? Give your answer to the nearest whole percent.
Consider these two comments on the claim “The weight of a child is primarily influenced by their height.”
Which do you think is most correct?
r^2 tells us the proportion of the response variable (y) that can be explained by the variation in the explanatory variable (x).