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

Covariance and Correlation

Before you start, make sure you know: Representation on the plane (Math 8 (Pre-Algebra))
Before you start, make sure you know: Representation on the plane (Integrated Math I)

Coach Rivera tells the basketball team: "The more you practice free throws, the more you make." Is that true? How strong is the link? And if a player practices 6 hours a week, how many free throws should she make? In this page you turn a scatter plot into numbers: one number that measures the trend (the correlation coefficient) and one line that makes predictions (the regression line).

Functional or statistical?

Some pairs of variables are tied by an exact formula. Others only show a tendency. Statistics lives in the second group.

Two scatter plots: side length versus perimeter of squares lies exactly on a line, while height versus weight of teenagers is a loose upward cloud Square: P = 4 · side Height and weight: a trend
Practice★☆☆Not started
In statistics, it is essential to distinguish between a relationship that can be calculated with an exact formula and one that only shows a trend. State whether the…

In statistics, it is essential to distinguish between a relationship that can be calculated with an exact formula and one that only shows a trend. State whether the relationship between the following pairs of variables is functional or statistical (correlation):

  1. a) The number of hours a 12th grade student spends playing video games and their grade in the Economics exam.
  2. b) The side length of a square and its perimeter.
  3. c) The gallons of gas put into a car and the total amount to pay at the gas station.
  4. d) The height of a teenager and their body weight.
Solve

Scatter plots and direction

Three scatter plots: points rising (positive correlation), points with no pattern (no correlation), and points falling (negative correlation) positive none negative
Practice★☆☆Not started
The direction of the relationship between two variables tells us how one varies when the other changes. Determine whether there is a positive correlation, negative…

The direction of the relationship between two variables tells us how one varies when the other changes. Determine whether there is a positive correlation, negative correlation, or if the variables are uncorrelated in the following cases:

  1. a) The number of absences from class and the final grade for the course.
  2. b) A person's shoe size and their average grade in Math.
  3. c) The outside temperature in summer and the energy consumption of air conditioning units.
  4. d) The age in years of a mobile phone and its resale price on the second-hand market.
Solve
Practice★☆☆Not started
Observe the following scatter plot representing the relationship between weekly training hours ($X$) and the points scored in a season by a group of basketball players…

Observe the following scatter plot representing the relationship between weekly training hours ($X$) and the points scored in a season by a group of basketball players ($Y$).

0 2 4 6 8 10 12 10 20 30 40 Training hours (X) Points scored (Y)

Based on the shape of the scatter plot, answer:

  1. a) Is it a direct or inverse relationship?
  2. b) How would you describe the strength of the correlation: strong or weak?
  3. c) What sign do you expect the covariance $\sigma_{xy}$ to have for this data?
Solve

Strength and the eyeballed line

Two clouds can both rise and still be very different. In one the points hug a line, in the other they are spread out.

Three scatter plots with positive trend: a tight cloud with strong correlation, a wider cloud with moderate correlation, and a scattered cloud with weak correlation strong: r ≈ 0.95 moderate: r ≈ 0.6 weak: r ≈ 0.2

When the cloud looks linear, you can draw a line of best fit by eye: a straight line through the middle of the cloud, with about as many points above as below.

Practice★☆☆Not started
A small study has been carried out on the number of books read per year ($X$) and the grade in English ($Y$) of five students. The data obtained is as follows:…

A small study has been carried out on the number of books read per year ($X$) and the grade in English ($Y$) of five students. The data obtained is as follows:

$(2, 5), (4, 6), (5, 8), (7, 8), (10, 9)$

Draw a scatter plot for this data in your notebook. Then, draw a freehand line of best fit (regression line) and comment on whether the relationship appears linear to you.

Solve
Practice★☆☆Not started
We compare two scatter plots represented in the following charts. Both show a direct relationship between the variables. a) In which of the two graphs are the points…

We compare two scatter plots represented in the following charts. Both show a direct relationship between the variables.

Graph A x y Graph B x y
  1. a) In which of the two graphs are the points closer to a possible regression line?
  2. b) Which of the two will have a correlation coefficient $r$ closer to $1$?
  3. c) If in graph A the value of $r$ is $1$, what reasonable value (between $0$ and $1$) could you assign to graph B?
Solve
Practice★★☆Not started
Match each of the following scatter plots with the value of the Pearson correlation coefficient ($r$) that corresponds to it with reasoning: Values of $r$: $-0,92$;…

Match each of the following scatter plots with the value of the Pearson correlation coefficient ($r$) that corresponds to it with reasoning:

Values of $r$: $-0,92$; $0,05$; $0,65$; $1$.

A B C D
Solve

Center of gravity and covariance

To put a number on the direction, start from the "middle" of the cloud.

Draw a vertical line at $\bar x$ and a horizontal line at $\bar y$. They cut the plane into four quadrants. For each point, multiply how far it is from $\bar x$ by how far it is from $\bar y$:

  • upper right: both differences positive, product positive;

  • lower left: both negative, product positive;

  • upper left and lower right: opposite signs, product negative.

A scatter plot divided into four quadrants by the means of x and y; most points lie in the upper right and lower left quadrants, where the product of deviations is positive (x̄, ȳ) + + − − Most points are in + quadrants: covariance is positive

The average of these products is the covariance. If most points sit in the "+" quadrants, it is positive. If most sit in the "−" quadrants, it is negative.

Practice★☆☆Not started
The "center of gravity" of a bivariate distribution is the point formed by the means of both variables, denoted as $(\bar{x}, \bar{y})$. A group of friends has recorded…

The "center of gravity" of a bivariate distribution is the point formed by the means of both variables, denoted as $(\bar{x}, \bar{y})$. A group of friends has recorded the time they spend on social media per day ($X$, in minutes) and their mobile phone battery life ($Y$, in hours):

$(45, 18), (60, 16), (90, 14), (120, 10), (150, 7)$

Calculate the coordinates of the center of gravity of this distribution.

Solve
Practice★☆☆Not started
The covariance $\sigma_{xy}$ informs us about the direction of the joint variation of two variables. Without performing all the complex calculations, observe the…

The covariance $\sigma_{xy}$ informs us about the direction of the joint variation of two variables. Without performing all the complex calculations, observe the following data relating the temperature of a soft drink ($X$, in $^\circ C$) and the time it has been out of the fridge ($Y$, in minutes):

Time ($Y$) 5 10 15 20 25
Temperature ($X$) 6 9 13 18 22
  1. a) As time increases, does the temperature tend to increase or decrease?
  2. b) Justify, according to your previous answer, whether the covariance will be positive, negative, or zero.
Solve

Covariance from a two-way table

When many individuals share the same pair of values, data come in a two-way table (joint frequency table). Each cell $f_{ij}$ counts how many individuals have $x = x_i$ and $y = y_j$. If the values are grouped in intervals, use the class midpoints as $x_i$ and $y_j$.

You can often see the direction without calculating. Put $x$ increasing down the rows and $y$ increasing across the columns. If the big counts lie along the top-left to bottom-right diagonal (like $3$ and $3$ above), the relationship is positive. If they lie along the other diagonal, it is negative. If counts are spread evenly, there is little or no relationship.

Practice★★☆Not started
A survey was carried out on the number of children ($X$) and the number of bedrooms in the home ($Y$) in an apartment building. The results are presented in the…

A survey was carried out on the number of children ($X$) and the number of bedrooms in the home ($Y$) in an apartment building. The results are presented in the following joint frequency table (two-way table):

$X \setminus Y$ 1 2 3
0 5 3 0
1 2 8 4
2 0 3 10
  1. Find the marginal distributions of $X$ and $Y$.

  2. Calculate the marginal mean of children ($\bar{x}$) and the marginal mean of bedrooms ($\bar{y}$).

  3. Is there a dependence between the two variables? Reason your answer by observing the frequencies in the table.

Solve
Practice★★★Not started
The heights of a sample of couples (man, woman) have been organized in the following two-way table (data in cm): | Man ($X$) \ Woman ($Y$) | [150, 160) | [160, 170) |…

The heights of a sample of couples (man, woman) have been organized in the following two-way table (data in cm):

Man ($X$) \ Woman ($Y$) [150, 160) [160, 170) [170, 180)
[165, 175) 4 2 0
[175, 185) 1 6 3
[185, 195) 0 2 5

Using the class midpoints:

  1. a) Calculate the covariance of the distribution.
  2. b) Calculate the Pearson correlation coefficient.
  3. c) Is there a strong relationship between the heights of the members of the couple in this sample?
Solve

The correlation coefficient $r$ and $r^2$

Covariance depends on units. Dividing by both standard deviations removes the units.

A bar showing the total variation in y, with 81 percent explained by the line and 19 percent unexplained total variation in y 81% explained by x other: 19% r = 0.9, so r² = 0.81

For Emma, $r^2 = 0.9^2 = 0.81$: about $81\%$ of the variation in quiz scores is explained by study time. The other $19\%$ comes from everything else (sleep, difficulty, luck).

Practice★☆☆Not started
The Pearson correlation coefficient, $r$, is a dimensionless measure that ranges within a specific interval. From the following values, state which ones are not possible…

The Pearson correlation coefficient, $r$, is a dimensionless measure that ranges within a specific interval. From the following values, state which ones are not possible for a correlation coefficient and explain why:

  1. a) $r = 0,85$
  2. b) $r = -1,2$
  3. c) $r = 2,5$
  4. d) $r = -0,4$
  5. e) $r = 0$
Solve
Practice★★☆Not started
In a study on the price of daily menus ($X$) and the distance to the city center ($Y$) in miles, the following measures have been obtained for a sample of 50…

In a study on the price of daily menus ($X$) and the distance to the city center ($Y$) in miles, the following measures have been obtained for a sample of 50 restaurants:

  • Mean of the prices: $\$\bar{x} = 12,5$

  • Mean of the distances: $\bar{y} = 3,2$ miles

  • Standard deviation of the price: $\$sx = 2,1$

  • Standard deviation of the distance: $s_y = 1,4$ miles

  • Covariance: $s_{xy} = -2,35$

Calculate the Pearson correlation coefficient. If a restaurant decides to increase the price of all its menus by $\$2$ due to inflation, how would this change affect the value of the correlation coefficient? Justify your answer based on the properties of this parameter.

Solve
Practice★★☆Not started
A streaming music application analyzes the relationship between the age of its users ($X$) and the number of different artists they listen to per month ($Y$). The…

A streaming music application analyzes the relationship between the age of its users ($X$) and the number of different artists they listen to per month ($Y$). The following sums are known for a sample of $n = 10$ users:

$$\sum x_i = 240 \quad \sum y_i = 150 \quad \sum x_i^2 = 6200 \quad \sum y_i^2 = 2850 \quad \sum x_i y_i = 3100$$
  1. Calculate the Pearson correlation coefficient.

  2. Determine the coefficient of determination $R^2$ and interpret its meaning: what percentage of the variation in the number of artists listened to is explained by the user's age?

Solve

Changing units

What happens to $s_{xy}$ and $r$ if you switch from hours to minutes, or from dollars to cents?

Practice★★★Not started
A sociological study analyzes the relationship between the number of books read per year ($X$) and the score in a mental agility test ($Y$). The covariance is $12,5$. By…

A sociological study analyzes the relationship between the number of books read per year ($X$) and the score in a mental agility test ($Y$). The covariance is $12,5$. By doubling the number of books read by all respondents and adding 5 points to everyone in the mental agility test, you are asked to:

  1. a) Reason what happens to the new covariance $\sigma'_{xy}$.
  2. b) If the original correlation coefficient was $r = 0,75$, what will the new coefficient $r'$ be after the changes? Justify your answer analytically.
  3. c) Will the reliability of the predictions change after these modifications to the data?
Solve

The regression line

To predict $y$ from $x$, use the line that fits the cloud best in the least-squares sense: it makes the sum of the squared vertical distances from the points to the line as small as possible. That vertical distance is called a residual.

Practice★★☆Not started
An organic farmer observes the relationship between the amount of natural fertilizer used ($X$, in pounds) and the potato yield ($Y$, in pounds). The data obtained is…

An organic farmer observes the relationship between the amount of natural fertilizer used ($X$, in pounds) and the potato yield ($Y$, in pounds). The data obtained is summarized in the following table:

$X$ 1 2 3 4 5
$Y$ 12 18 25 28 32
  1. Calculate the regression line of $Y$ on $X$.

  2. What yield would be expected if $3,5$ pounds of fertilizer were used?

  3. Is the previous prediction reliable? Justify your answer by calculating the correlation coefficient.

Solve
Practice★★☆Not started
An e-sports club wishes to analyze whether there is a relationship between the weekly hours its players dedicate to individual training ($X$) and their accuracy index in…

An e-sports club wishes to analyze whether there is a relationship between the weekly hours its players dedicate to individual training ($X$) and their accuracy index in competitive matches ($Y$), measured out of 100. The data for a sample of 6 players are as follows:

Training hours ($X$) 10 15 12 20 8 18
Accuracy index ($Y$) 72 81 75 92 68 88

For this study:

  1. Represent the scatter plot associated with this two-dimensional distribution.

  2. Calculate the center of gravity of the distribution.

  3. Determine the covariance $s_{xy}$ and interpret the sign obtained in the context of the problem.

Sₓᵧ > 0 5 10 15 20 25 Training hours (X) 60 70 80 90 100 Accuracy index (Y) x̄ ȳ G(x̄, ȳ)
Solve
Practice★★★Not started
The relationship between the investment in R&D ($X$, in millions of $) and the net profit ($Y$, in millions of $) of 10 technology companies is investigated. The…

The relationship between the investment in R&D ($X$, in millions of $) and the net profit ($Y$, in millions of $) of 10 technology companies is investigated. The following sums have been obtained:

$\sum x_i = 100$; $\sum y_i = 160$; $\sum x_i^2 = 1100$; $\sum y_i^2 = 2800$; $\sum x_i y_i = 1720$

  1. a) Calculate the center of gravity of the distribution.
  2. b) Find the Pearson correlation coefficient.
  3. c) Determine the equation of the regression line of $Y$ on $X$.
  4. d) If a company decides not to invest anything in R&D ($x = 0$), what profit is it estimated to have? Comment on the validity of this estimation outside the data range.
Solve

Two regression lines and $r$

You can also predict $x$ from $y$. That gives a second line, the regression line of $x$ on $y$, with its own slope.

The two regression lines, y on x and x on y, both rising and crossing at the center of gravity (x̄, ȳ) line of y on x line of x on y
Practice★★☆Not started
The two regression lines of a bivariate variable are: Regression line of $Y$ on $X$: $y = 0,85x + 12,4$ Regression line of $X$ on $Y$: $x = 0,72y + 5,1$ Given that the…

The two regression lines of a bivariate variable are:

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

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

Given that the variance of the variable $X$ is $s_x^2 = 16$, calculate:

  1. The Pearson correlation coefficient $r$.

  2. The covariance $s_{xy}$ of the distribution.

  3. The coordinates of the center of gravity $(\bar{x}, \bar{y})$.

10 20 30 40 50 60 10 20 30 40 50 60 X Y x̄ ȳ (x̄, ȳ) y = 0.85x + 12.4 x = 0.72y + 5.1 s²ₓ = 16
Solve
Practice★★★Not started
A data analyst for a streaming* platform is studying the relationship between the time a user spends watching trailers ($X$, in minutes) and the time they spend watching…

A data analyst for a streaming platform is studying the relationship between the time a user spends watching trailers ($X$, in minutes) and the time they spend watching full content ($Y$, in minutes). After analyzing thousands of profiles, they have determined that the equations of the two regression lines are:

  • Regression line of $Y$ on $X$: $y = 1,2x + 45$

  • Regression line of $X$ on $Y$: $x = 0,3y - 12$

From this information, solve:

  1. a) Calculate the arithmetic means of both variables, $\bar{x}$ and $\bar{y}$.
  1. b) Determine the Pearson correlation coefficient, $r$, and interpret the degree of relationship between the two variables.
  1. c) If a user has spent 10 minutes watching trailers, what is the expected content viewing time? Is this prediction reliable? Reason the answer based on the coefficient of determination.
0 2 4 6 8 12 10 30 40 50 60 70 80 57 Time on trailers (X) [min] Time on content (Y) [min] y = 1.2x + 45 (Y on X) x = 0.3y - 12 (X on Y) (x̄, ȳ) x̄ ≈ 2.34 ȳ ≈ 47.81 Prediction (x=10)
Solve
Practice★★★Not started
Given the regression lines $y = -2x + 10$ and $x = -0,4y + 4$, reason whether the following statements are true or false, proving it by calculating the corresponding…

Given the regression lines $y = -2x + 10$ and $x = -0,4y + 4$, reason whether the following statements are true or false, proving it by calculating the corresponding parameters:

  1. a) The correlation between the variables is positive because both slopes have the same sign.
  2. b) The center of gravity of the distribution is the point $(3, 4)$.
  3. c) The variables have a perfect functional dependence.
  4. d) The variance of $Y$ is greater than the variance of $X$.
X Y 2 4 6 8 10 0 2 4 6 8 10 12 y = −2x + 10 x = −0.4y + 4 (3, 4) CG (0, 10)
Solve

Finding missing parameters

Hard problems give you a few statistics and ask for others. Keep this toolbox handy.

To find Use
Covariance $s_{xy} = \dfrac{\sum xy}{n} - \bar x \bar y$ or $s_{xy} = m_{yx}\, s_x^2$
Correlation $r = \dfrac{s_{xy}}{s_x s_y}$, or $r = \pm\sqrt{m_{yx} m_{xy}}$
Slope of $y$ on $x$ $m_{yx} = \dfrac{s_{xy}}{s_x^2} = r\,\dfrac{s_y}{s_x}$
Slope of $x$ on $y$ $m_{xy} = \dfrac{s_{xy}}{s_y^2} = r\,\dfrac{s_x}{s_y}$
Means intersection of the two lines
Sign of $r$ sign of the slopes

Remember that $s_x$ and $s_y$ are positive. The sign of $r$ always comes from the slope.

Practice★★★Not started
In a study on the performance of electric scooter batteries, the ambient temperature ($X$, in $^\circ C$) and the actual range achieved ($Y$, in miles) are analyzed. The…

In a study on the performance of electric scooter batteries, the ambient temperature ($X$, in $^\circ C$) and the actual range achieved ($Y$, in miles) are analyzed. The following data are known:

  • The variance of the temperature is $s_x^2 = 16$.

  • The regression line of the range on the temperature is $y = -0,85x + 42$.

  • The coefficient of determination is $R^2 = 0,7225$.

Calculate:

  1. a) The covariance between the temperature and the range.
  2. b) The standard deviation of the range, $s_y$.
  3. c) What would happen to the correlation coefficient if we decided to measure the temperature in degrees Fahrenheit using the transformation $F = 1,8X + 32$? Justify your answer based on the properties of correlation.
Solve
Practice★★★Not started
A Math retake exam has been taken. It is observed that the relationship between the grades of the first exam ($X$) and those of the second ($Y$) follows a linear trend.…

A Math retake exam has been taken. It is observed that the relationship between the grades of the first exam ($X$) and those of the second ($Y$) follows a linear trend. It is known that:

  • $\bar{x} = 4$; $\bar{y} = 6$

  • The two regression lines intersect forming a very small angle, and it has been calculated that the product of their slopes is $0,81$.

  • Both slopes are positive.

  1. a) Find the Pearson correlation coefficient and state what percentage of the grade of the second exam is explained by the grade of the first.
  2. b) If the standard deviation of $X$ is half that of $Y$, find the equation of the regression line of $Y$ on $X$.
  3. c) If a student got a $2$ in the first exam, what grade is estimated for them in the second?
Exam 1 Grade (X) Exam 2 Grade (Y) 2 4 6 8 10 2 4 6 8 10 Y on X X on Y (4, 6) Center of gravity x=2 y=2.4
Solve

Using the line wisely

A regression line is a tool for estimating, so you must know when to trust it.

A scatter plot with a regression line; the part over the data range is reliable interpolation and the dashed prolongation outside the data is risky extrapolation inside the data: interpolate extrapolate: risky
Practice★★☆Not started
A courier company studies the relationship between the weight of parcels ($X$, in pounds) and the shipping cost ($Y$, in $\$…

A courier company studies the relationship between the weight of parcels ($X$, in pounds) and the shipping cost ($Y$, in $\$$). After calculating the parameters, they find that the regression line of $Y$ on $X$ is $y = 1,5x + 4,2$ and the correlation coefficient is $r = 0,98$.

  1. State whether the relationship between weight and cost is direct or inverse.

  2. Explain what the value $1,5$ means in the context of the problem (slope of the line).

  3. If a parcel weighs $0$ pounds (an empty parcel or a very light envelope), what cost does the line predict? Does this value make physical sense?

  4. Calculate the coefficient of determination and comment on the quality of the linear fit.

2 4 6 8 Weight X (lb) 5 10 15 20 Cost Y ($) Δx = 2 lb Δy = $3 m = 1.5 y = $4.20 (Fixed cost, x=0) y = 1.5x + 4.2 r = 0.98 R² = 0.96
Solve
Practice★★★Not started
A video game company wants to predict the monthly expenditure on microtransactions ($Y$, in dollars) of its players based on their weekly hours of play ($X$). The…

A video game company wants to predict the monthly expenditure on microtransactions ($Y$, in dollars) of its players based on their weekly hours of play ($X$). The statistics department has obtained the following parameters:

$\bar{x} = 15$; $\bar{y} = 22$; $s_x^2 = 25$; $s_y^2 = 144$; $\sigma_{xy} = 48$

  1. a) Find the equation of the regression line of $Y$ on $X$.
  2. b) A player claims to spend $\$50$ a month. Use the regression line of $X$ on $Y$ to estimate how many weekly hours they play.
  3. c) Which of the two estimations (predicting the expenditure from the hours or predicting the hours from the expenditure) seems more logical to you in this context? Do they have the same mathematical reliability?
Solve

Back to the start: Coach Rivera's claim is a statement about association. With data, you would compute $r$ between practice hours and made free throws. A value near $1$ (say $0.9$ or more) supports "more practice goes with more makes," and the regression line gives estimates inside the range of hours you observed. But even a strong $r$ cannot prove that practice is the cause, and predicting for a player practicing $40$ hours would be extrapolation.

Summary

See all the exercises in this section