Back to homeMathematics · Integrated Math III · Change subject
Start for free
Math III · Mathematics
Statistics · Statistics

The Least-Squares Regression Line

Coach Rivera keeps track of how many hours a week each player practices free throws and how many of 20 shots they sink in Friday's test. Emma, a new player, plans to practice 4.5 hours a week. How many shots should she expect to make? To answer, you need a line that summarizes the pattern in the data, and a way to judge how far to trust it.

Scatter plots and correlation

A line only makes sense if the points on a scatter plot roughly follow a line. The correlation coefficient $r$ (Pearson's $r$) tells you how well they do.

Three scatter plots: points rising with r close to 0.95, points with no pattern with r close to 0, and points falling with r close to negative 0.9. r ≈ 0.95positive, strong r ≈ 0no linear pattern r ≈ −0.9negative, strong

Some problems write $\sigma_x$, $\sigma_y$, $\sigma_{xy}$ instead of $s_x$, $s_y$, $s_{xy}$. They mean the same thing here.

Practice★☆☆Not started
Look at the following scatter plots representing the relationship between two statistical variables. Associate with reasoning each of the values of Pearson's correlation…

Look at the following scatter plots representing the relationship between two statistical variables. Associate with reasoning each of the values of Pearson's correlation coefficient, $r$, with its corresponding graph:

Values of $r$: $0,95$; $-0,85$; $0,05$.

x y Graph A x y Graph B x y Graph C
Solve
Practice★☆☆Not started
Indicate, for each of the following pairs of variables, whether you expect them to have a positive, negative or zero correlation: 1. The number of miles traveled by a…

Indicate, for each of the following pairs of variables, whether you expect them to have a positive, negative or zero correlation:

  1. The number of miles traveled by a car and the fuel left in its tank.

  2. A person's height and their grade on the math exam.

  3. A family's monthly income and their expenditure on leisure and culture.

  4. The time an athlete trains per day and their personal best time in a race.

Solve

The mean point and the best-fit line

Many lines can be drawn through a cloud of points. Which one is "best"? For each point, measure the vertical distance to the line. The least-squares regression line is the line that makes the sum of the squares of those distances as small as possible.

This line always passes through the mean point $(\bar x, \bar y)$, where $\bar x$ is the mean of the $x$-values and $\bar y$ is the mean of the $y$-values. Why? The line balances the points: the residuals above it cancel the residuals below it. A balance point has to be at the center of the cloud.

That gives you a ready-made point-slope equation. If the slope is $m$:

$$y - \bar y = m(x - \bar x)$$

Here are Coach Rivera's data. $x$ is hours of free-throw practice per week and $y$ is shots made out of 20.

$x$ 1 2 3 4 5
$y$ 8 10 13 14 17
Scatter plot of free throws made versus weekly practice hours with an upward regression line passing through the mean point (3, 12.4). 01020 12345 mean point (3, 12.4) hours of practice per weekshots made (of 20)
Practice★☆☆Not started
Given the following table of values for a bivariate variable: | $X$ | $2$ | $4$ | $6$ | $8$ | | :--- | :---: | :---: | :---: | :---: | | $Y$ | $10$ | $18$ | $22$ | $30$…

Given the following table of values for a bivariate variable:

$X$ $2$ $4$ $6$ $8$
$Y$ $10$ $18$ $22$ $30$
  1. a) Calculate the mean point $(\bar{x}, \bar{y})$.
  2. b) Plot the points on a small hand-drawn scatter plot and deduce the sign of the covariance $\sigma_{xy}$ without carrying out the full calculation.
Solve
Practice★☆☆Not started
In a bivariate distribution, it is known that the mean of variable $X$ is $\bar{x} = 12$ and the mean of variable $Y$ is $\bar{y} = 15$. a) What are the coordinates of…

In a bivariate distribution, it is known that the mean of variable $X$ is $\bar{x} = 12$ and the mean of variable $Y$ is $\bar{y} = 15$.

  1. a) What are the coordinates of the mean point of this distribution?
  2. b) If the regression line of $Y$ on $X$ is $y = 0,8x + a$, calculate the value of the y-intercept $a$ knowing that the line must necessarily pass through the mean point.
Solve

Computing the line from data

To get the slope you need two numbers: the variance of $x$ and the covariance of $x$ and $y$.

Practice★★☆Not started
A group of high school juniors has carried out a study on the relationship between the daily time (in hours) they spend using a well-known short-video social network…

A group of high school juniors has carried out a study on the relationship between the daily time (in hours) they spend using a well-known short-video social network ($X$) and the percentage of battery left on their mobile phone at the end of the day ($Y$). The data obtained from 6 classmates are as follows:

Hours of use ($X$) 1.5 2 3 3.5 4 5
% Battery ($Y$) 75 68 50 45 32 20

a) Calculate the mean point of the distribution $(\bar{x}, \bar{y})$.

b) Find the covariance $\sigma_{xy}$ and the linear correlation coefficient $r$. Interpret the result obtained in terms of the sign and the strength of the relationship.

c) Determine the equation of the regression line of $Y$ on $X$.

d) If a student uses the social network for 2.5 hours, what percentage of battery is estimated to be left? Is this prediction reliable? Justify your answer based on the coefficient of determination $r^2$.

1 2 3 4 5 6 20 40 60 80 100 Hours of use (X) % Battery (Y) 2.5 ? (x̄, ȳ) Actual data Regression Prediction
Solve
Practice★★☆Not started
A survey was carried out among a group of teenagers about the number of followers they have on a platform ($X$, in hundreds) and the average number of "likes" they…

A survey was carried out among a group of teenagers about the number of followers they have on a platform ($X$, in hundreds) and the average number of "likes" they receive per post ($Y$). The data is summarized in the following table:

Followers ($X$) 2 4 6 8 10
Likes ($Y$) 45 92 135 180 220

a) Plot the scatter plot and draw an approximate regression line by hand.

b) Calculate the coefficients of the regression line $y = mx + n$.

c) What is the physical meaning of the slope $m$ in this context?

d) Calculate the coefficient of determination $r^2$ and explain what percentage of the variation in "likes" is explained by the number of followers.

Solve
Practice★★★Not started
A sociologist analyzes the relationship between the weekly time spent on video games ($X$, in hours) and the concentration capacity in a specific test ($Y$, scale from 0…

A sociologist analyzes the relationship between the weekly time spent on video games ($X$, in hours) and the concentration capacity in a specific test ($Y$, scale from 0 to 100). The data from 10 teenagers yielded the following partial results:

$\sum x_i = 150$; $\sum y_i = 620$; $\sum x_i^2 = 2\,850$; $\sum y_i^2 = 41\,500$; $\sum x_iy_i = 8\,400$.

Find:

  1. The covariance $s_{xy}$ and the correlation coefficient $r$.

  2. The regression line of $Y$ on $X$.

  3. A student spends 40 hours a week on video games. Calculate their estimated score on the test. Analyze whether this estimate is an interpolation or an extrapolation and discuss its real validity in the context of the problem.

Solve

Computing the line from summary statistics

Often the problem gives you means, standard deviations, and $r$ (or the covariance) instead of raw data. Because $r = \dfrac{s_{xy}}{s_x s_y}$, the slope can be rewritten.

Practice★★☆Not started
A courier company analyzed the relationship between the distance traveled (in miles) by its bicycle couriers ($X$) and the number of calories burned according to their…

A courier company analyzed the relationship between the distance traveled (in miles) by its bicycle couriers ($X$) and the number of calories burned according to their smart devices ($Y$). After calculating the statistical parameters, the following values were obtained:

$\bar{x} = 15 \text{ mi}$; $\bar{y} = 480 \text{ kcal}$

$\sigma_x = 4,2$; $\sigma_y = 120$

$\sigma_{xy} = 453,6$

a) Calculate the linear correlation coefficient and indicate what type of dependence exists between the variables.

b) Find the regression line of the calories burned ($Y$) on the distance traveled ($X$).

c) How many calories is a courier estimated to burn if they travel 22 miles?

d) If a courier wishes to burn approximately 600 kcal, how many miles should they travel according to the regression line of $X$ on $Y$?

Solve
Practice★★☆Not started
A pet adoption center wants to predict the time it takes for a dog to be adopted ($Y$, in days) based on its age ($X$, in years). They have collected data from 10 dogs…

A pet adoption center wants to predict the time it takes for a dog to be adopted ($Y$, in days) based on its age ($X$, in years). They have collected data from 10 dogs and obtained a correlation of $r = 0,85$. The mean age is 4 years and the mean number of days until adoption is 25 days. The standard deviation of the age is 2 years and that of the days is 10 days.

a) Find the equation of the regression line.

b) Estimate how long it will take for a 0.5-year-old puppy to be adopted.

c) Estimate how long it will take for a 12-year-old senior dog.

d) Of the two previous estimates, indicate which is more reliable and why, taking into account the range of the original data (ages between 1 and 8 years).

Solve

Interpreting slope and intercept

A regression line is a model, so every number in it needs a sentence in context.

  • Slope $m$: for each additional unit of $x$, the predicted $y$ changes by about $m$ units.

  • Intercept $b$: the predicted $y$ when $x = 0$. It only has meaning if $x = 0$ is realistic and inside the data.

  • Reliability: predictions are more trustworthy when $|r|$ is close to $1$ and $x$ is within the range of the data.

Drag the sliders to see how the slope and intercept shape a line.

Practice★☆☆Not started
A study on study habits in 11th grade analyzes the relationship between the number of weekly hours dedicated to reading, $X$, and the grade obtained on the English exam,…

A study on study habits in 11th grade analyzes the relationship between the number of weekly hours dedicated to reading, $X$, and the grade obtained on the English exam, $Y$. The regression line of $Y$ on $X$ is:

$y = 0,65x + 3,2$

  1. a) Justify whether the correlation between both variables is positive or negative.
  2. b) If a student dedicates $8$ hours a week to reading, what grade is it estimated they will obtain on the exam?
Solve
Practice★☆☆Not started
A nutritionist analyzes the relationship between the weight of a group of teenagers ($X$, in pounds) and their height ($Y$, in inches). The collected data have a…

A nutritionist analyzes the relationship between the weight of a group of teenagers ($X$, in pounds) and their height ($Y$, in inches). The collected data have a correlation coefficient of $r = 0,92$ and the regression line is $y = 1,4x + 85$.

Explain the meaning of the slope ($1,4$) in the context of the problem and assess the reliability of the predictions made with this line.

Solve
Practice★★☆Not started
Look at the following scatter plot showing the relationship between the R&D investment ($X$) and the annual net profit ($Y$) of several technology companies: Knowing…

Look at the following scatter plot showing the relationship between the R&D investment ($X$) and the annual net profit ($Y$) of several technology companies:

0 R&D Investment (X) Net Profit (Y)

Knowing that the regression line is $y = 2,5x + 10$ and that the correlation coefficient is $r = 0,92$:

a) Indicate with reasoning whether there is a strong relationship between investment and profits.

b) If a company invests nothing in R&D ($x = 0$), according to the model, what would be its estimated profit? Does this value make sense in reality?

c) Explain what would happen to the slope of the line if the correlation coefficient were negative.

d) If we multiply all the profit values by 2, how would the value of the correlation coefficient $r$ change? Justify your answer.

Solve

The regression line of $x$ on $y$

Sometimes you know $y$ and want to estimate $x$. That needs a different line, one that minimizes the squared horizontal distances.

A scatter cloud with two different regression lines crossing at the mean point: the shallower line predicts y from x and the steeper line predicts x from y. y on x x on y (x̄, ȳ)

When both lines are drawn with $x$ on the horizontal axis, the line of $x$ on $y$ looks steeper, with slope $1/m'$. They meet only at the mean point, and coincide only when $|r| = 1$.

Practice★★☆Not started
In a study on sleep habits and academic performance, the following regression lines were obtained for the variables $X$ (daily hours of sleep) and $Y$ (average grade for…

In a study on sleep habits and academic performance, the following regression lines were obtained for the variables $X$ (daily hours of sleep) and $Y$ (average grade for the term):

Regression line of $Y$ on $X$: $y = 0,65x + 3,2$

Regression line of $X$ on $Y$: $x = 1,15y - 0,45$

a) Knowing that both lines intersect at the mean point of the distribution, calculate the mean hours of sleep ($\bar{x}$) and the mean grade of the students ($\bar{y}$).

b) Calculate the linear correlation coefficient $r$ from the slopes of both lines.

c) Indicate with reasoning whether the correlation is direct or inverse and whether it is strong or weak.

X (Hours of sleep) Y (Average grade) 0 5 10 15 20 5 10 15 y = 0.65x + 3.2 x = 1.15y - 0.45 G(x̄, ȳ) x̄ ȳ
Solve
Practice★★★Not started
The marks of 50 students in Economics ($X$) and Geography ($Y$) have a mean of 6.5 in both subjects. The variance of Economics is 4 and that of Geography is 2.25. It is…

The marks of 50 students in Economics ($X$) and Geography ($Y$) have a mean of 6.5 in both subjects. The variance of Economics is 4 and that of Geography is 2.25. It is known that the correlation coefficient is $r = 0,8$.

  1. If a student has obtained a 4 in Economics, estimate their mark in Geography.

  2. If another student has obtained a 9 in Geography, estimate their mark in Economics using the relevant regression line.

  3. Compare both estimates and explain why the same line cannot be used for both cases if we want to minimise the mean squared error.

Economics (X) Geography (Y) 2 4 6 8 10 0 2 4 6 8 10 x=4 y=5 y=9 x≈9.17 (6.5, 6.5) Mean point Regression Y on X Regression X on Y
Solve
Practice★★★Not started
In a study on the performance of a new cryptocurrency, the variables $X$ (advertising investment in thousands of dollars) and $Y$ (daily transaction volume in millions…

In a study on the performance of a new cryptocurrency, the variables $X$ (advertising investment in thousands of dollars) and $Y$ (daily transaction volume in millions of dollars) have been analyzed. After processing the data, the equations of the two regression lines have been obtained:

  • Regression line of $Y$ on $X$: $y = 0,85x + 1,24$

  • Regression line of $X$ on $Y$: $x = 0,92y - 0,15$

Determine with reasoning:

  1. The mean point of the distribution $(\bar{x}, \bar{y})$.

  2. Pearson's linear correlation coefficient ($r$).

  3. If an advertising investment of $\$15\,000$ is desired, what would be the expected transaction volume? Justify the reliability of this prediction based on the coefficient of determination.

2 4 6 8 10 12 2 4 6 8 x̄ ȳ G(x̄, ȳ) y = 0.85x + 1.24 Y on X x = 0.92y - 0.15 X on Y Advertising investment (X) Transaction volume (Y)
Solve

Residuals and the coefficient of determination

A prediction is rarely exactly right. The difference is the residual.

A regression line with one data point below it; the vertical gap between the actual value and the predicted value is the residual. actual y predicted ŷ residual e = y − ŷ (the vertical gap)

To describe how much of the variation in $y$ the line accounts for, use the coefficient of determination:

$$R^2 = r^2 = 1 - \frac{\sum e^2}{\sum (y - \bar y)^2}$$

For Coach Rivera's data, $R^2 = 1 - \dfrac{0.8}{49.2} \approx 0.984$. About $98.4\%$ of the variation in shots made is explained by practice time.

You can also find $r$ from a line you already have, since $m = r\,s_y/s_x$:

$$r = m\,\frac{s_x}{s_y}$$
Practice★★☆Not started
A track coach analyzes the relationship between the height of their athletes in cm ($X$) and their stride length in cm ($Y$). The data for 5 athletes are: (160, 110),…

A track coach analyzes the relationship between the height of their athletes in cm ($X$) and their stride length in cm ($Y$). The data for 5 athletes are: (160, 110), (170, 120), (175, 125), (180, 132) and (190, 145).

a) Find the regression line of $Y$ on $X$.

b) What stride length would be expected of an athlete who is 185 cm tall?

c) Calculate the prediction error (residual) for the athlete who is 180 cm tall. The error is defined as the difference between the actual value and the value estimated by the line: $e = y_i - \hat{y}_i$.

d) If the correlation coefficient were $r = 0,98$, what could you state about the reliability of the coach's predictions?

Solve
Practice★★★Not started
In a contingency table relating the education level ($X$) and the income ($Y$) of a sample, some data has been lost. We know the following parameters: $\bar{x} = 3$;…

In a contingency table relating the education level ($X$) and the income ($Y$) of a sample, some data has been lost. We know the following parameters:

$\bar{x} = 3$; $\bar{y} = 2\,400$; $s_x^2 = 1,2$; $s_y^2 = 160\,000$ and the regression line of $Y$ on $X$ is $y = 300x + 1\,500$.

  1. Calculate the coefficient of determination $R^2$ and interpret the percentage of the variance in income that is explained by the education level.

  2. If an individual has an education level of $X=5$ and their actual income is $\$3\,200$, calculate the prediction error (residual) made by the line.

1 2 3 4 5 6 1500 2000 2500 3000 3500 Education level (X) Income (Y) y = 300x + 1500 Residual = 200 Mean point (3, 2400) Prediction (5, 3000) Actual data (5, 3200)
Solve
Practice★★★Not started
The relationship between the number of daily hours of sunlight ($X$) and the electricity consumption for heating ($Y$) in a large office over 12 months is analysed. The…

The relationship between the number of daily hours of sunlight ($X$) and the electricity consumption for heating ($Y$) in a large office over 12 months is analysed. The data is summarised as:

$\bar{x} = 9$; $\bar{y} = 450$; $s_x = 3,2$; $s_y = 85$ and $s_{xy} = -210$.

  1. Calculate the regression line of $Y$ on $X$.

  2. Calculate the regression line of $X$ on $Y$.

  3. Explain the meaning of the sign of the covariance in this context and determine what percentage of the variability in electricity consumption does not depend on the hours of sunlight.

Solve

Interpolation, extrapolation, and outliers

A regression line drawn solid inside the range of the observed data and dashed beyond it, showing interpolation is reliable and extrapolation is not guaranteed. data range extrapolating(outside the data range) inside the range: reliable outside: no guarantee

Nothing guarantees that a trend continues beyond the data. The lemonade line predicts $-168$ cups at $0$°F, and Coach Rivera's line would predict $49.8$ shots out of 20 for someone who practices $20$ hours a week. The arithmetic is right, but the answer is nonsense.

A line can also be the wrong kind of model. Suppose a phone's charge level is measured as it charges. The points curve and level off near $100\%$, but a line keeps climbing.

Phone charge percentage versus minutes charging: the points curve and level off near 100 percent while a straight line keeps rising past 100 percent. 100% (full) minutes chargingcharge (%) the line passes 100%!

Finally, outliers can distort a line. A point far from the pattern lowers $|r|$. A point far to the left or right of the other $x$-values can also tilt the line toward itself.

Rising scatter points with one outlier at the lower right; the fit with the outlier is flatter than the fit without it. outlier fit without outlier fit with outlier

Back to the start: Emma plans $4.5$ hours a week. That is between $1$ and $5$ hours, so it is interpolation, and $r \approx 0.992$ is very strong. The prediction of about $16$ shots out of 20 is trustworthy.

Practice★☆☆Not started
The charging time of a mobile phone battery ($X$, in minutes) and the percentage of charge reached ($Y$, in %) have been measured. The results are shown in the following…

The charging time of a mobile phone battery ($X$, in minutes) and the percentage of charge reached ($Y$, in %) have been measured. The results are shown in the following graph:

10 20 30 40 50 60 20 40 60 80 100 0 X (min) Y (%)

If the equation of the orange line is $y = 0,5x + 10$:

  1. a) Estimate the percentage of charge after $60$ minutes.
  2. b) Is it a functional or statistical relationship? Reason your answer by observing the position of the points with respect to the line.
Solve
Practice★☆☆Not started
A courier company knows that the cost of a delivery, $Y$ (in dollars), depends on the weight of the package, $X$ (in pounds), according to the regression line…

A courier company knows that the cost of a delivery, $Y$ (in dollars), depends on the weight of the package, $X$ (in pounds), according to the regression line $y = 2,5x + 5$.

If the correlation coefficient is $r = 0,98$, which of the following statements is correct?

  1. For every pound increase in weight, the cost increases by exactly $2,5$ dollars.

  2. Predictions made for packages of a similar weight to those studied will be very reliable.

  3. If a package weighs $0$ pounds, the cost will necessarily be $0$ dollars.

  4. The relationship between weight and cost is inverse.

Solve
Practice★★★Not started
Given the following scatter plot corresponding to the variables $X$ (age of a car in years) and $Y$ (market value in thousands of dollars), the regression line of $Y$ on…

Given the following scatter plot corresponding to the variables $X$ (age of a car in years) and $Y$ (market value in thousands of dollars), the regression line of $Y$ on $X$ has been drawn. It is observed that there is an outlier at the coordinates $(1, 2)$.

  1. If we remove this point from the data set, what would you expect to happen to the absolute value of the correlation coefficient? And to the slope of the regression line?

  2. If the original line is $y = -1,5x + 20$, calculate the estimated value for a 10-year-old car and argue about the suitability of using this model for cars older than 15 years.

x > 15 (Invalid) Age X (years) Value Y (thousands $) 0 2 4 6 8 10 12 14 16 5 10 15 20 y = −1.5x + 20 Estimate (10, 5) Outlier (1, 2)
Solve

Changing units and working backward

Changing units. Suppose you replace $Y$ by $Y' = cY + d$. This could be a currency conversion, a tax, or Celsius to Fahrenheit. The new line is found by applying the same change to the old line.

Working backward. The facts $m = r\,s_y/s_x$, $m\,m' = r^2$, and $R^2 = r^2$ let you recover missing pieces. Remember that $r$ has the same sign as the slope.

Practice★★☆Not started
The relationship between the price of a monthly subscription to a music platform ($X$, in dollars) and the number of hours users listen to music per month ($Y$) has been…

The relationship between the price of a monthly subscription to a music platform ($X$, in dollars) and the number of hours users listen to music per month ($Y$) has been studied. It is known that:

  • The variance of $X$ is $\sigma_x^2 = 4$.

  • The variance of $Y$ is $\sigma_y^2 = 25$.

  • The regression line of $Y$ on $X$ is $y = -1,2x + 42$.

a) Determine the covariance $\sigma_{xy}$ between both variables.

b) Calculate the linear correlation coefficient $r$.

c) How would the correlation coefficient vary if we decided to express the listening time in minutes instead of hours? Reason your answer.

Solve
Practice★★★Not started
A marketing team is studying the relationship between the "likes" obtained on an Instagram post ($X$) and the sales generated for a product ($Y$). They have observed…

A marketing team is studying the relationship between the "likes" obtained on an Instagram post ($X$) and the sales generated for a product ($Y$). They have observed that the regression line of $Y$ on $X$ is $y = 0,04x + 150$. However, they realize that the sales data were recorded without sales tax (21%).

If we define a new variable $Y' = 1,21Y$ to include the tax:

  1. What will be the new equation of the regression line of $Y'$ on $X$?

  2. How will the original Pearson's correlation coefficient be affected? Justify your answer based on the properties of linear transformations in statistics.

Solve
Practice★★★Not started
Given a bivariate distribution where the coefficient of determination is $R^2 = 0,81$, it is known that the regression line of $Y$ on $X$ has a positive slope and passes…

Given a bivariate distribution where the coefficient of determination is $R^2 = 0,81$, it is known that the regression line of $Y$ on $X$ has a positive slope and passes through the points $(2, 5)$ and $(6, 11)$.

  1. Calculate Pearson's correlation coefficient.

  2. Determine the variance of variable $Y$ if we know that the standard deviation of $X$ is $s_x = 2,5$.

  3. Find the equation of the regression line of $X$ on $Y$.

X Y 0 2 4 6 8 10 5 10 15 Regression line (2, 5) (6, 11) R² = 0.81 sₓ = 2.5
Solve

Summary

See all the exercises in this section