Covariance Formula – What is the Covariance Formula? Examples

In statistics, the covariance formula is used to assess the relationship between two variables. It is essentially a measure of the variance between two variables. Covariance is measured in units and is calculated by multiplying the units of the two variables. The variance can be any positive or negative values. Following are the interpreted values:

    • When two variables move in the same direction, it results in a positive covariance
    • Contrary to the above point is two variables in opposite directions, it results in a negative covariance

Note: The covariance formula is similar to the correlation formula and deals with the calculation of data points from the average value in a dataset.

What Is Covariance Formula?

Covariance is a measure of the relationship between two random variables, in statistics. The covariance indicates the relation between the two variables and helps to know if the two variables vary together. In the covariance formula, the covariance between two random variables X and Y can be denoted as Cov(X, Y).

Covariance Formula

Covariance formula

    • Covariance formula for population:

(Cov( {X,Y} ) = frac{{sum {( {X_i  – overline X })( {Y_i  – overline Y } )} }}{n})

(Cov( {X,Y} ) = frac{{sum {( {X_i  – overline X })( {Y_i  – overline Y } )} }}{n-1})

Where,

    • (X_i) is the values of the X-variable
    • (Y_i) is the values of the Y-variable
    • ( overline X) is the mean of the X-variable
    • ( overline Y) is the mean of the Y-variable
    • (n) is the number of data points
See also  What is Quadrant? - Definition, Coordinate Graphs, Examples, Practice Questions

Relation Between Correlation Coefficient and Covariance Formulas

The correlation coefficient formula can be expressed as (Correlation = frac{Cov(x,y)}{sigma_x times sigma_y})

Where,

Cov (x,y) is the covariance between x and y

σand σy are the standard deviations of x and y.

Using the above formula which gives the correlation coefficient formula can be derived using the covariance and even vice versa is possible. Covariance is measured in units which can be computed by multiplying the units of the two given variables. The values of the variance are interpreted as follows:

Positive covariance: The two given variables tend to move in the same direction.

Negative covariance: The two given variables tend to move in inverse directions.

But this not so in the case of correlation.

Applications of Covariance Formula

The covariance formula has applications in finance, majorly in portfolio theory. Thus, the assets can be chosen that do not exhibit a high positive covariance with each other and partially eliminating the unsystematic risk.

Break down tough concepts through simple visuals.

Math will no longer be a tough subject, especially when you understand the concepts through visualizations with Cuemath.

Book a Free Trial Class

Examples Using Covariance Formula

Example 1: Find covariance for following data set x = {2,5,6,8,9}, y = {4,3,7,5,6}

Solution:

Given data sets x = {2,5,6,8,9}, y = {4,3,7,5,6} and N = 5

Mean(x) = (2 + 5 + 6 + 8 + 9) / 5

= 30 / 5

= 6

Mean(y) = (4 + 3 +7 + 5 + 6) / 5

= 25 / 5

= 5

Sample covariance Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N – 1)

= [(2 – 6)(4 – 5) + (5 – 6)(3 – 5) + (6 – 6)(7 – 5) + (8 – 6)(5 – 5) + (9 – 6)(6 – 5)] / 5 – 1

= 4 + 2 + 0 + 0 + 3 / 4

= 9 / 4

= 2.25

Population covariance Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N)

See also  What are the differential equations? Types of Differential Equations

= [(2 – 6)(4 – 5) + (5 – 6)(3 – 5) + (6 – 6)(7 – 5) + (8 – 6)(5 – 5) + (9 – 6)(6 – 5)] / 5

= 4 + 2 + 0 + 0 + 3 /

= 9 / 5

= 1.8

Answer: The sample covariance is 2.25 and the population covariance is 1.8.

Example 2: Using the covariance formula, find covariance for following data set x = {5,6,8,11,4,6}, y = {1,4,3,7,9,12}.

Given data sets x = {5,6,8,11,4,6}, y = {1,4,3,7,9,12} and N = 6

Mean(x) = (5 + 6 + 8 + 11 + 4 + 6) / 6

= 40 / 6

= 6.67

Mean(y) = (1 + 4 + 3 + 7 + 9 + 12) / 6

= 36 / 6

= 6

Using sample covariance formula Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N – 1)

= – 0.4

Population covariance Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N)

= – 0.33

Answer: The sample covariance is -0.4 and the population covariance is -0.33.

Example 3: Find covariance for following data set x = {13,15,17,18,19}, y = {10,11, 12,14,16} using the covariance formula.

Solution:

Given data sets x = {13,15,17,18,19}, y = {10,11,12,14,16} and N = 5

Mean(x) = (13 + 15 + 17 + 18 + 19) / 5

= 82 / 5

= 16.4

Mean(y) = (10 + 11 +12 + 14 + 16) / 5

= 63 / 5

= 12.6

Sample covariance Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N – 1)

= [(16.4 – 13)(12.6 – 10) + (16.4 – 15)(12.6 – 11) + (16.4 – 17)(12.6 – 12) + (16.4 – 18)(12.6 – 14) + (16.4 – 19)(12.6 – 16)] / 5 – 1

= (8.84 + 2.24 – 0.36 + 2.24 + 8.84) / 4

= 21.8 / 4

= 5.45

Population covariance Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N)

= [(16.4 – 13)(12.6 – 10) + (16.4 – 15)(12.6 – 11) + (16.4 – 17)(12.6 – 12) + (16.4 – 18)(12.6 – 14) + (16.4 – 19)(12.6 – 16)] / 5

= (8.84 + 2.24 – 0.36 + 2.24 + 8.84) / 5

= 21.8 / 5

= 4.36

Answer: The sample covariance is 5.45 and the population covariance is 4.36.

FAQs on Covariance Formula

What Is Covariance Formula in Statistics?

In statistics, the covariance formula helps to assess the relationship between two variables. It is essentially a measure of the variance between two variables. The covariance formula is expressed as,

    • Covariance formula for population: (Cov( {X,Y} ) = frac{{sum {( {X_i  – overline X })( {Y_i  – overline Y } )} }}{n})
    • Covariance Formula for a sample: (Cov( {X,Y} ) = frac{{sum {( {X_i  – overline X })( {Y_i  – overline Y } )} }}{n-1})
See also  A Cube Minus B Cube Formula - Examples | a^3

Where, (X_i) is the values of the X-variable, (Y_i) is the values of the Y-variable, ( overline X) is the mean of the X-variable, ( overline Y) is the mean of the Y-variable and (n) is the number of data points.

How To Use Covariance Formula?

For the given data sets

    • Step 1: Obtain the data sets.
    • Step 2: Calculate the mean for each data set.
    • Step 3: For each outcome, find ((x_i)- x) and ((y_i) – y)
    • Step 4: Multiply the results obtained.
    • Step 5:  Find the covariance: Covariance formula for population: (Cov( {X,Y} ) = frac{{sum {( {X_i  – overline X })( {Y_i  – overline Y } )} }}{n}) and Covariance Formula for a sample: (Cov( {X,Y} ) = frac{{sum {( {X_i  – overline X })( {Y_i  – overline Y } )} }}{n-1})

What Are the Components of the Covariance Formula?

The Covariance formula for population is (Cov( {X,Y} ) = frac{{sum {( {X_i  – overline X })( {Y_i  – overline Y } )} }}{n}) and the Covariance Formula for a sample is (Cov( {X,Y} ) = frac{{sum {( {X_i  – overline X })( {Y_i  – overline Y } )} }}{n-1}). Thus, the components of the covariance formula are

    • (X_i) is the values of the X-variable
    • (Y_i) is the values of the Y-variable
    • ( overline X) is the mean of the X-variable
    • ( overline Y) is the mean of the Y-variable
    • (n) is the number of data points

What Is the Relation Between the Covariance and Correlation Coefficient Formulas?

The correlation coefficient represented as r equals the covariance between the variables divided by the product of the standard deviations of each variable.

Leave a Comment

Your email address will not be published. Required fields are marked *