By Yuriy Smirnov Ph.D.

In statistics, covariance is a metric used to measure how one random variable moves in relation to another random variable. In investment, covariance of returns measures how the rate of return on one asset varies in relation to the rate of return on other assets or a portfolio.

If there is a complete set of outcomes and the probability of each outcome can be estimated, the covariance of returns of two assets can be computed as shown below:

where r_{Xi} is the rate of return on security X achieved at *i*th outcome, ERR_{X} is the expected rate of return on security X, r_{Yi} is the rate of return on security Y achieved at *i*th outcome, ERR_{Y} is the expected rate of return on security Y, p_{i} is a probability of *i*th outcome, and N is the number of possible outcomes.

If the probability of each outcome cannot be estimated, the historical return is used to compute covariation. It is assumed that any rate of return achieved during a specific period (e.g., day, week, month, quarter, year) has equal probability.

If the entire population is used, the formula is as follows:

where r_{Xi} is the rate of return on security X for the *i*th period, r_{Yi} is the rate of return on security Y for the *i*th period, and N is the entire size of the population.

If a sample is used instead of the entire population, the equation above should be modified as follows:

where ERR_{XS} is the sample expected rate of return (sample mean) on security X, ERR_{YS} is the sample expected rate of return on security Y, and N is the size of the sample.

The interpretation of the covariance number can be quite confusing because its values can cover a wide range. That is why covariance is normalized into correlation coefficient to measure the strength of linear dependence between two random variables.

The value of the covariance of returns can have both a positive sign and a negative sign or equal zero.

- A positive value means that the rate of return of two investments moves in the same direction. In other words, they rise or decline simultaneously.
- A negative value indicates that the return on one investment moves in the opposite direction than the return on another investment. In simple terms, when the return on one investment increases, the return on another investment decreases and vice versa.
- A value equal or close to zero shows any linear dependence between two random variables. In other words, these variables are independent.

The senior analysist of a hedge fund considers five possible economic states to estimate the joint variability of returns on two securities in a portfolio.

The expected rate of return (ERR) for each security should be calculated by multiplying the rate of return at each economic state by its probability.

ERR of Security A = (-6%)×0.10 + 1%×0.20 + 8%×0.40 + 3%×0.20 + (-4%)×0.10 = 0.4%

ERR of Security B = 7%×0.10 + (-2%)×0.20 + 6%×0.40 + (-1%)×0.20 + 3%×0.10 = 2.6%

Then it is necessary to calculate the deviations of returns at each economic state.

Deviation at Economic State 1 = (-6%-0.4%)×(7%-2.6%) = -28.16

Deviation at Economic State 2 = (1%-0.4%)×(-2%-2.6%) = -2.76

Deviation at Economic State 3 = (8%-0.4%)×(6%-2.6%) = 25.84

Deviation at Economic State 4 = (3%-0.4%)×(-1%-2.6%) = -9.36

Deviation at Economic State 5 = (-4%-0.4%)×(3%-2.6%) = -1.76

Finally, the covariance of returns between Security A and Security B is computed as the weighted average of all deviations.

Cov (A,B) = -28.16×0.10 + (-2.76)×0.20 + 25.84×0.40 + (-9.36)×0.20 + (-1.76)×0.10 = 4.92

The positive value of covariance indicates that there is some linear dependence between returns of Security A and Security B, and they have positive correlation.

The asset manager of a mutual fund needs to determine the relationship between the rate of return of three securities. The historical returns for the last year are shown in the table below.

__Step 1__: Calculate the expected rate of return for each security.

ERR of Security A = (3.5%+2.3%+0.1%+4.3%+0.9%+2.1%-0.2%+2.9%-1.0%-1.7%+3.7+2.9%)÷12 = 1.65%

ERR of Security B = (4.9%-2.5%+5.7%+1.1%+6.0%-0.2%-1.3%-3.0%-1.4%+2.1%+7.3+4.7%)÷12 = 1.95%

ERR of Security C = (1.8%+0.6%+2.1%-0.5%+0.2%-0.1%-1.4%+1.9%+1.5%+1.7%-0.3%+2.0%)÷12 = 0.79%

__Step 2__: Multiply each deviation for one security by the deviation for another security.

Deviation in Jan (A,B) = (3.5%-1.65%)×(4.9%-1.95%) = 5.46

Deviation in Feb (A,B) = (2.3%-1.65%)×(-2.5%-1.95%) = -2.89

Deviation in Mar (A,B) = (0.1%-1.65%)×(5.7%-1.95%) = -5.81

Deviation in Apr (A,B) = (4.3%-1.65%)×(1.1%-1.95%) = -2.25

Deviation in May (A,B) = (0.9%-1.65%)×(6.0%-1.95%) = -3.04

Deviation in Jun (A,B) = (2.1%-1.65%)×(-0.2%-1.95%) = -0.97

Deviation in Jul (A,B) = (-0.2%-1.65%)×(-1.3%-1.95%) = 6.01

Deviation in Aug (A,B) = (2.9%-1.65%)×(-3.0%-1.95%) = -6.19

Deviation in Sep (A,B) = (-1.0%-1.65%)×(-1.4%-1.95%) = 8.88

Deviation in Oct (A,B) = (-1.7%-1.65%)×(2.1%-1.95%) = -0.50

Deviation in Nov (A,B) = (3.7%-1.65%)×(7.3%-1.95%) = 10.97

Deviation in Dec (A,B) = (2.9%-1.65%)×(4.7%-1.95%) = 3.44

The same calculations should be applied to compute joint deviations of returns of Security A and Security C, and Security B and Security C.

__Step 3__: Follow the formula of sample covariance because a sample of population is used.

Cov (A,B) = (5.46-2.89-5.81-2.25-3.04-0.97+6.01-6.19+8.88-0.50+10.97+3.44)÷(12-1) = 1.19

Microsoft Excel enables you to calculate covariance using two functions.

- COVARIANCE.P returns covariance of the entire population.
- COVARIANCE.S returns covariance of the sample.

Let’s calculate the sample covariance of returns between Security A and Security C, and between Security B and Security C using the data in Example 2.

As we can see, the sample covariation of returns between Security A and Security C equals -0.35 and is 0.57 between Security B and Security C.

Covariances are often displayed as a covariance matrix as in the figure below (a matrix is created by using data in Example 2).

The diagonal elements are variances, and the off-diagonal elements are covariances between all possible pairs of securities. As far as the covariance matrix is symmetric, it can also be displayed as follows:

The reason for the simplification is that the covariance of returns between Security A and Security B is the same as the covariance of returns between Security B and Security A.

© 2018 FinancialManagementPro.com. All rights reserved.