Back to homeMathematics · Algebra 2 · Change subject
Start for free
Algebra 2 · Mathematics
Statistics · Statistics

"Bivariate Data: Covariance, Correlation, and Regression Lines"

Emma wants to make the varsity basketball team. Every week she logs the hours she spends practicing free throws and how many shots she sinks in a 20-shot test.

Hours practiced ($X$) 1 2 3 4 5
Shots made out of 20 ($Y$) 8 11 12 15 19

The dots climb, but you want numbers. How strong is the pattern? Does it change if she records time in minutes? How many shots should she expect after 4.5 hours, and can she trust that prediction? Let's build the tools to answer all of this.

The mean point and the standard deviations

Start with each variable on its own. These are the marginal parameters: the mean $\bar x$ and standard deviation $\sigma_x$ of the $x$-values, and the same for $y$.

For spread, divide by $n$:

$$\sigma_x = \sqrt{\frac{\sum (x_i-\bar x)^2}{n}} = \sqrt{\frac{\sum x_i^2}{n}-\bar x^2}$$

The second form is faster by hand: you only need $\sum x_i^2$ and the mean. On a calculator, use the $\sigma_x$ value, not the $S_x$ value, which divides by $n-1$. Some problems write $s_x$ instead of $\sigma_x$. In this page they mean the same thing. Some problems also call the mean point the center of gravity.

Scatter plot of Emma's practice hours and shots made, with the mean point G(3, 13) marked by dashed lines to the axes 1 2 3 4 5 0 10 20 hours practiced per week (X) shots made (Y) G (3, 13)
Practice★☆☆Not started
A group of friends analyzes the relationship between the hours they spend playing a video game per week ($X$) and the score obtained in the last tournament ($Y$). The…

A group of friends analyzes the relationship between the hours they spend playing a video game per week ($X$) and the score obtained in the last tournament ($Y$). The data for four of them is: $(2, 150)$, $(4, 300)$, $(6, 450)$ and $(8, 500)$.

Calculate the coordinates of the center of gravity $(\bar{x}, \bar{y})$ of this bivariate distribution and represent it on a scatter plot along with the previous points.

Hours [X] Points [Y] 2 4 6 8 10 100 200 300 400 500 600 (2, 150) (4, 300) (6, 450) (8, 500) 5 350 G(x̄, ȳ)
Solve
Practice★☆☆Not started
Given the following table of values representing the number of followers on a social network in thousands ($X$) and the advertising income in dollars ($Y$) of 5…

Given the following table of values representing the number of followers on a social network in thousands ($X$) and the advertising income in dollars ($Y$) of 5 influencers:

$X$ (followers) 10 20 30 40 50
$Y$ (revenue) 100 150 250 300 450

Calculate the marginal means $\bar{x}$ and $\bar{y}$.

Solve
Practice★★☆Not started
A sociological study analyzes the relationship between the number of weekly hours teenagers dedicate to reading for pleasure ($X$) and their score on a reading…

A sociological study analyzes the relationship between the number of weekly hours teenagers dedicate to reading for pleasure ($X$) and their score on a reading comprehension test ($Y$). The data from a sample of 5 students is collected in the following table:

Hours ($X$) 2 4 5 8 11
Score ($Y$) 62 70 75 88 95
  1. a) Calculate the marginal means $\bar{x}$ and $\bar{y}$.
  2. b) Determine the marginal standard deviations $\sigma_x$ and $\sigma_y$.
  3. c) Represent the center of gravity of the distribution on a scatter plot.
2 4 8 10 12 60 70 80 90 100 6 78 Reading hours (X) Score (Y) G(6, 78) x̄ ȳ
Solve

What covariance measures

Draw a vertical line through $\bar x$ and a horizontal line through $\bar y$. They cut the scatter plot into four regions. For each point, look at its deviations $x_i - \bar x$ and $y_i - \bar y$ and multiply them.

Scatter plot split into four quadrants around the mean point; the upper right and lower left quadrants give positive products of deviations and the other two give negative products (+) · (+) = + (−) · (+) = − (−) · (−) = + (+) · (−) = − (x̄, ȳ)

Check it with Emma. Her deviations are $x - 3$: $-2, -1, 0, 1, 2$ and $y - 13$: $-5, -2, -1, 2, 6$. The products are $10, 2, 0, 2, 12$, which add up to $26$. So $\sigma_{xy} = \dfrac{26}{5} = 5.2 > 0$: more practice goes with more shots made.

Practice★☆☆Not started
State, without performing calculations, what sign you expect the covariance $\sigma_{xy}$ to have in the following situations. Justify your answer based on the…

State, without performing calculations, what sign you expect the covariance $\sigma_{xy}$ to have in the following situations. Justify your answer based on the relationship between the variables:

  1. a) $X$: Speed of a car, $Y$: Time taken to travel a fixed distance.
  2. b) $X$: Hours studying a language, $Y$: Number of words known in that language.
  3. c) $X$: A person's shoe size, $Y$: Their score on the History exam.
Solve
Practice★★☆Not started
Observe the following scatter plot representing the relationship between the advertising investment of 8 small businesses and their monthly profits (both in thousands of…

Observe the following scatter plot representing the relationship between the advertising investment of 8 small businesses and their monthly profits (both in thousands of dollars).

10 20 30 40 50 60 70 80 90 100 10 20 30 40 50 60 Advertising investment (thousands $) Profits (thousands $)
  1. a) Justify, without performing calculations, whether the sign of the covariance will be positive or negative.
  2. b) Choose with reasoning which of the following values could be the Pearson correlation coefficient ($r$): $-0,85$; $0,12$; $0,91$; $1,5$.
  3. c) What would happen to the value of $r$ if we decided to express the data in dollars instead of thousands of dollars?
Solve

Computing covariance from sums

Subtracting the means from every value is slow. There is a shortcut that needs only the totals of a table.

Practice★☆☆Not started
In a study on physical performance, the resting heart rate ($X$) and the time in seconds taken to recover the normal heart rate after exertion ($Y$) are measured. It is…

In a study on physical performance, the resting heart rate ($X$) and the time in seconds taken to recover the normal heart rate after exertion ($Y$) are measured. It is known that the sum of the products of the variables is $\sum x_i y_i = 15200$, the number of individuals is $n = 10$, and the means are $\bar{x} = 70$ and $\bar{y} = 20$.

Use the simplified formula $\sigma_{xy} = \frac{\sum x_i y_i}{n} - \bar{x} \bar{y}$ to calculate the covariance. What does the sign of the result indicate about the relationship between heart rate and recovery time?

Solve
Practice★★☆Not started
A streaming platform wants to check if there is a relationship between the length of a series (in number of seasons, $X$) and the mean user rating (out of 10 points,…

A streaming platform wants to check if there is a relationship between the length of a series (in number of seasons, $X$) and the mean user rating (out of 10 points, $Y$). The following parameters are available after analyzing 50 series:

$\sum x_i = 150 \quad \sum y_i = 325 \quad \sum x_i^2 = 580 \quad \sum y_i^2 = 2200 \quad \sum x_i y_i = 940$

  1. a) Calculate the covariance $\sigma_{xy}$.
  2. b) Interpret the result obtained in the context of the problem: do longer series tend to have better or worse ratings?
Solve

Changing units: shifts and stretches

What if Emma records time in minutes instead of hours? Or a teacher adds 5 bonus points to every score? These are linear changes: $X' = aX + b$ and $Y' = cY + d$.

Practice★★★Not started
It is known that the relationship between heating expenditure ($Y$, in dollars) and the mean outside temperature ($X$, in $^\circ C$) during winter follows a bivariate…

It is known that the relationship between heating expenditure ($Y$, in dollars) and the mean outside temperature ($X$, in $^\circ C$) during winter follows a bivariate distribution with a correlation coefficient of $r = -0,85$. The mean temperature was $8$ $^\circ C$ with a standard deviation of $3$ $^\circ C$, while the mean expenditure was $\$150$ with a variance of $400\,\$^2$.

If for next year a climate change is forecast that will cause all temperatures to rise by $2$ $^\circ C$ and the price of gas to increase so that all expenditures are multiplied by $1,2$:

  1. a) How will these changes affect the new correlation coefficient? Justify your answer without performing exhaustive calculations.
  2. b) Calculate the new covariance between temperature and expenditure after applying both transformations.
  3. c) Find the new regression line of $Y$ on $X$.
Solve

The correlation coefficient r

Covariance depends on units. To get a pure number, divide out the units.

Four scatter plots showing correlation about 0.9, 0.5, 0, and negative 0.9 r ≈ 0.9 r ≈ 0.5 r ≈ 0 r ≈ −0.9
Practice★☆☆Not started
Match each of the following values of the linear correlation coefficient ($r$) with its corresponding scatter plot, briefly reasoning your answer: $r = 0,95$ $r = -0,80$…

Match each of the following values of the linear correlation coefficient ($r$) with its corresponding scatter plot, briefly reasoning your answer:

  • $r = 0,95$

  • $r = -0,80$

  • $r = 0,05$

x y A B C
Solve
Practice★☆☆Not started
A nutritionist studies the relationship between the grams of sugar ($X$) and the kilocalories ($Y$) of five types of energy bars. She has obtained the following marginal…

A nutritionist studies the relationship between the grams of sugar ($X$) and the kilocalories ($Y$) of five types of energy bars. She has obtained the following marginal parameters:

  • Mean sugar: $\bar{x} = 12$ g

  • Mean energy: $\bar{y} = 210$ kcal

  • Standard deviations: $\sigma_x = 3$ g and $\sigma_y = 25$ kcal

  • Covariance: $\sigma_{xy} = 60$

Calculate the linear correlation coefficient ($r$) and interpret whether there is a strong relationship between both variables.

Solve
Practice★☆☆Not started
Look at the following scatter plot showing the relationship between the outside temperature ($X$) and the heating consumption ($Y$) in a school building during a winter…

Look at the following scatter plot showing the relationship between the outside temperature ($X$) and the heating consumption ($Y$) in a school building during a winter week.

Which of the following statements about the parameters is correct?

  1. The covariance will be positive because as the temperature increases, the consumption increases.

  2. The correlation coefficient $r$ will be close to $-1$ because the relationship is inverse and clear.

  3. The mean point will be located at the origin $(0,0)$.

Outside temperature (X) Heating consumption (Y)
Solve

The coefficient of determination

How much does knowing $X$ help you predict $Y$? Squaring $r$ answers it.

Bar showing 96.6 percent of the variation in shots made explained by hours practiced and 3.4 percent from other factors variation in shots made (Y) explained by hours practiced: 96.6% other factors: 3.4%
Practice★☆☆Not started
If the coefficient of determination of a bivariate distribution is $R^2 = 0,81$, calculate the value of the correlation coefficient $r$ (assuming the relationship is…

If the coefficient of determination of a bivariate distribution is $R^2 = 0,81$, calculate the value of the correlation coefficient $r$ (assuming the relationship is direct) and explain what percentage of the variation in variable $Y$ is explained by variable $X$.

Solve
Practice★★☆Not started
In a basketball training session, the distance to the basket in feet ($X$) and the number of baskets scored out of every 10 attempts ($Y$) are recorded for a group of…

In a basketball training session, the distance to the basket in feet ($X$) and the number of baskets scored out of every 10 attempts ($Y$) are recorded for a group of players. The summary data is:

$\bar{x} = 4,5 \text{ ft} \quad \sigma_x = 1,2 \text{ ft}$

$\bar{y} = 6 \text{ baskets} \quad \sigma_y = 1,8 \text{ baskets}$

$\sigma_{xy} = -1,944$

  1. a) Calculate the Pearson correlation coefficient and interpret its strength and direction.
  2. b) Calculate the coefficient of determination $r^2$ and explain what percentage of the variation in successful shots is explained by the distance to the basket.
Solve

Parameters from frequency tables

When many people share the same values, data come in a two-way frequency table. Each cell $f_{ij}$ counts how many cases have $X = x_i$ and $Y = y_j$.

Here $X$ is hours studied and $Y$ is a quiz score out of 10 for 15 students.

$X \setminus Y$ 6 8 10 Total
1 3 1 0 4
2 1 3 1 5
3 0 1 5 6
Total 4 5 6 15

The marginal distribution of $X$ is the last column (the row totals). The marginal distribution of $Y$ is the last row (the column totals). The totals must add up to $N$ both ways. If a total is missing, subtract the known cells.

When the table uses intervals such as $[0, 5)$, replace each interval by its midpoint ($2.5$ for $[0, 5)$) and then use the same formulas.

Comparing spread: the coefficient of variation

To compare the spread of variables measured in different units, divide by the mean: $CV = \dfrac{\sigma}{|\bar x|}$. For example, 8th-grade heights with mean $62$ in. and $\sigma = 3$ in. have $CV \approx 4.8\%$. Weights with mean $110$ lb and $\sigma = 15$ lb have $CV \approx 13.6\%$. The weights show more relative dispersion, even though $15$ is not "bigger" than $3$ in any meaningful way.

Practice★★★Not started
In a language academy, the relationship between the weekly hours of personal study ($X$) and the score on the final exam ($Y$) of a group of students has been observed.…

In a language academy, the relationship between the weekly hours of personal study ($X$) and the score on the final exam ($Y$) of a group of students has been observed. The joint frequency table is as follows, where three values ($a, b, c$) have been lost:

$X \setminus Y$ $40$ $60$ $80$ Total $n_i$
$2$ $4$ $2$ $0$ $a$
$5$ $1$ $b$ $3$ $10$
$8$ $0$ $1$ $5$ $c$
Total $n_j$ $5$ $9$ $8$ $22$
  1. a) Calculate the values of $a, b$ and $c$.
  2. b) Determine the marginal distribution of the variable $Y$ and calculate its mean and variance.
  3. c) Calculate the mean exam score ($Y$) conditional on the students studying $5$ hours per week ($X=5$).
Solve
Practice★★★Not started
A survey has been carried out on the number of books read per year ($X$) and the score on a reading comprehension test ($Y$). The results are grouped in the following…

A survey has been carried out on the number of books read per year ($X$) and the score on a reading comprehension test ($Y$). The results are grouped in the following table:

$X \setminus Y$ $[0, 20)$ $[20, 40)$ $[40, 60)$
$[0, 5)$ $8$ $2$ $0$
$[5, 10)$ $1$ $12$ $3$
$[10, 15)$ $0$ $4$ $10$

Using the class midpoints for both variables:

  1. a) Calculate the center of gravity of the distribution.
  2. b) Calculate the Pearson linear correlation coefficient.
  3. c) Which of the two variables shows a greater relative dispersion? Use the coefficient of variation to justify your answer.
Solve

Regression lines and predictions

A regression line is the best-fit line through the cloud (the least-squares line). There are two of them, depending on which variable you want to predict.

A residual is a miss: $\text{residual} = \text{observed} - \text{predicted}$. A positive residual means the point lies above the line.

Back to Emma. Her line of $Y$ on $X$ has slope $\dfrac{5.2}{2} = 2.6$, so $y - 13 = 2.6(x - 3)$, which is $y = 2.6x + 5.2$. For $4.5$ hours, $y = 2.6(4.5) + 5.2 = 16.9$, so she should expect about $17$ shots made out of $20$. With $r \approx 0.98$ and $4.5$ inside her data range, that prediction is trustworthy.

Practice★★☆Not started
The relationship between a family's weekly food expenditure ($X$) and their weekly income ($Y$), both in dollars, has been studied. The following data has been obtained:…

The relationship between a family's weekly food expenditure ($X$) and their weekly income ($Y$), both in dollars, has been studied. The following data has been obtained:

$\bar{x} = 180, \quad \sigma_x^2 = 900, \quad \bar{y} = 600, \quad \sigma_y^2 = 2500, \quad \sigma_{xy} = 1200$

  1. a) Find the equation of the regression line of $Y$ on $X$.
  2. b) If a family spends $\$250$ on food, what would their estimated income be according to the model?
  3. c) Is this prediction reliable? Justify your answer by calculating the correlation coefficient.
Solve
Practice★★☆Not started
The relationship between the price of a plane ticket ($X$) and how many days in advance it is bought ($Y$) is analyzed. It is known that the correlation is $r = -0,82$.…

The relationship between the price of a plane ticket ($X$) and how many days in advance it is bought ($Y$) is analyzed. It is known that the correlation is $r = -0,82$.

If the standard deviations are $\sigma_x = 45 \text{ \$}$ and $\sigma_y = 12 \text{ days}$, and the means are $\bar{x} = 150 \text{ \$}$ and $\bar{y} = 25 \text{ days}$:

  1. a) Calculate the covariance of the distribution.
  2. b) Calculate the regression line of $X$ on $Y$ to estimate the ticket price based on the days in advance.
  3. c) What price would be estimated for a ticket bought 40 days in advance?
Solve
Practice★★★Not started
A streaming platform analyzes the relationship between the number of followers of a streamer (variable $X$, in thousands) and the monthly income from subscriptions…

A streaming platform analyzes the relationship between the number of followers of a streamer (variable $X$, in thousands) and the monthly income from subscriptions (variable $Y$, in dollars). The following summary data is known after studying $20$ content creators:

$\sum x_i = 400$

$\sum y_i = 60.000$

$\sum x_i^2 = 12.000$

$\sum y_i^2 = 250.000.000$

$\sum x_i y_i = 1.500.000$

Calculate:

  1. a) The covariance $s_{xy}$ and the marginal standard deviations $s_x$ and $s_y$.
  2. b) The linear correlation coefficient. What percentage of the variation in income is explained by the number of followers?
  3. c) A streamer decides to invest in advertising to increase their follower base from $25.000$ to $35.000$. According to the linear model, by how much is their monthly income estimated to increase?
Solve

Working backward from the two lines

Often a problem hands you the regression lines and asks for the parameters.

The two regression lines, Y on X and X on Y, crossing at the mean point of a scatter plot Y on X X on Y (x̄, ȳ)
Practice★★☆Not started
A farmer observes that the yield of their orange harvest depends on the hours of sunshine received during the ripening stage. The regression lines obtained from…

A farmer observes that the yield of their orange harvest depends on the hours of sunshine received during the ripening stage. The regression lines obtained from historical data are:

Regression line of $Y$ on $X$: $y = 0,85x + 12$

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

  1. a) Determine the center of gravity $(\bar{x}, \bar{y})$ of the distribution.
  2. b) Calculate the Pearson correlation coefficient from the slopes of the two regression lines.
Hours of sunshine (X) Yield (Y) 0 y = 0.85x + 12 x = 0.92y - 4 (x̄, ȳ) x̄ ȳ
Solve
Practice★★★Not started
In a study on the real estate market in a coastal city, the equations of the two regression lines relating the sale price of apartments, $Y$ (in hundreds of thousands of…

In a study on the real estate market in a coastal city, the equations of the two regression lines relating the sale price of apartments, $Y$ (in hundreds of thousands of dollars), to their area, $X$ (in square feet), have been obtained:

  • Regression line of $Y$ on $X$: $y = 0,012x + 0,5$

  • Regression line of $X$ on $Y$: $x = 65y - 20$

Determine with reasoning:

  1. a) The center of gravity of the distribution $(\bar{x}, \bar{y})$.
  2. b) The Pearson linear correlation coefficient, $r$, and interpret its sign and strength.
  3. c) If an apartment has an area of $120$ $m^2$, what would its estimated price be? Is this estimate reliable? Justify your answer using the coefficient of determination.
20 40 60 80 100 120 140 0,5 1,0 1,5 2,0 2,5 Area X (sq ft) Price Y ($100k) G(56.8; 1.18) y = 1.94 y = 0.012x + 0.5 (Y on X) x = 65y - 20 (X on Y)
Solve
Practice★★☆Not started
In a sample of 100 homes, the area in $m^2$ ($X$) and the monthly electricity consumption in $kWh$ ($Y$) are studied. The following information is known: The center of…

In a sample of 100 homes, the area in $m^2$ ($X$) and the monthly electricity consumption in $kWh$ ($Y$) are studied. The following information is known:

  • The center of gravity is $G(90, 350)$.

  • The variance of the area is $400$.

  • The regression line of $Y$ on $X$ is $y = 0,6x + 296$.

  1. a) What is the value of the covariance $\sigma_{xy}$?
  2. b) Given that the standard deviation of consumption is $\sigma_y = 15$, calculate the correlation coefficient.
  3. c) If a home has an area of $120 \text{ m}^2$, calculate the residual (prediction error) if the actual observed consumption was $375 \text{ kWh}$.
Solve

Special cases and the angle between the lines

The two regression lines always cross at the mean point. The stronger the correlation, the closer together they are.

Why can the lines be perpendicular only when $r = 0$? Perpendicular lines (not horizontal/vertical) have slopes multiplying to $-1$. Writing both lines as $y = mx + b$, the slopes are $\dfrac{\sigma_{xy}}{\sigma_x^2}$ and $\dfrac{\sigma_y^2}{\sigma_{xy}}$. Their product is $\dfrac{\sigma_y^2}{\sigma_x^2} > 0$, never $-1$. So the only perpendicular option is a horizontal line meeting a vertical one.

Practice★★★Not started
A sociologist studies the relationship between the age of emancipation of young people ($X$) and the per capita income level of their region ($Y$). When plotting the…

A sociologist studies the relationship between the age of emancipation of young people ($X$) and the per capita income level of their region ($Y$). When plotting the scatter plot, they observe that the center of gravity is $G(28, 1400)$. One of the regression lines is $y = -50x + 2800$. Given that the variance of age is $s_x^2 = 9$ and the variance of income is $s_y^2 = 360.000$:

  1. a) Calculate the covariance $s_{xy}$ and the linear correlation coefficient.
  2. b) Obtain the equation of the regression line of $X$ on $Y$.
  3. c) Determine the angle formed by both regression lines. Does this angle alone allow you to claim that the correlation is strong? Justify your answer by comparing it with the value of $r$.
Solve
Practice★★★Not started
Two variables $X$ and $Y$ have marginal standard deviations $s_x = 4$ and $s_y = 6$. It is known that the two regression lines are perpendicular to each other. a) What…

Two variables $X$ and $Y$ have marginal standard deviations $s_x = 4$ and $s_y = 6$. It is known that the two regression lines are perpendicular to each other.

  1. a) What is the value of the covariance $s_{xy}$ and the correlation coefficient $r$?
  2. b) What does this result imply for the predictive capacity of the linear model?
  3. c) If we added a new point $(x, y)$ to the distribution that coincided exactly with the center of gravity, would the value of the correlation coefficient change? Reason your answer.
Solve
Practice★★★Not started
Given a bivariate distribution, it has been verified that the standard deviations of both variables are equal ($s_x = s_y$). a) Prove algebraically that, in this case,…

Given a bivariate distribution, it has been verified that the standard deviations of both variables are equal ($s_x = s_y$).

  1. a) Prove algebraically that, in this case, the linear correlation coefficient coincides with the slope of the regression line of $Y$ on $X$.
  2. b) If the regression line of $Y$ on $X$ is $y = 0,6x + 2$, what is the coefficient of determination?
  3. c) What would the slope of the regression line of $X$ on $Y$ be under these conditions?
r = 1 y = 0.6x + 2 Δx = sₓ Δy = m·sₓ 2 sₓ sᵧ If sₓ = sᵧ then: m = r·(sᵧ/sₓ) = r = 0.6
Solve

Summary

See all the exercises in this section