Covariance

Learn about covariance, a statistical term used in security and portfolio evaluation

Author: Marc Raphael Matta
Marc Raphael Matta
Marc Raphael Matta
I am a Computer and Communication Engineering student at the Lebanese University with a profound passion for finance and investment banking. Proficient in coding languages such as Java, JavaScript, and AI, I honed my skills while working at Khatib & Alami, a prominent engineering company in Lebanon. Additionally, my experience as a trader at Bank of Beirut provided me with valuable insights into the financial industry. Currently, I am furthering my expertise through a writing internship at Wall Street Oasis, where I am excited to contribute my technical and financial knowledge to the field.
Reviewed By: Parul Gupta
Parul Gupta
Parul Gupta
Working as a Chief Editor, customer support, and content moderator at Wall Street Oasis.
Last Updated:June 5, 2024

What is Covariance?

Covariance is a statistical term used in security and portfolio evaluation that measures the degree to which two assets move together. A positive covariance means the assets move in the same direction, and the larger the value, the greater one asset moves in relation to the other.

An example of covariance is as follows:

  • Stock A has a covariance to Stock B of +1.4
  • For every $1 increase of Stock B, Stock A will increase by $1.4

Holding assets with negative or low covariance is preferable for a well-diversified portfolio because it reduces the risk that all assets will move in the same direction at the same time.

Covariance is a statistical measure that shows how two variables move together.

Key Takeaways

  • Covariance is a statistical method for determining the relationship between the movements of two random variables.
  • Covariance is a tool that investors use to understand the historical relationship between the returns of two equities.
  • Investors can use covariance to help choose equities that react to the market in complementary ways, potentially reducing portfolio risk.
  • Knowing the differences between covariance, variance, and correlation is crucial in finance and statistics. Covariance and variance measure data fluctuations, while correlation gives a standardized measure of the relationship's strength and direction.

Examples of positive and negative covariance 

The following table illustrates the relationships between various economic variables and their impacts:

Examples of positive and negative covariance

Variables Description Relationship
Temperature and Ice Cream Sales As temperature increases, ice cream sales also increase. People tend to buy more ice cream on hot days. Positive
Advertising Spend and Product Sales When a company spends more on advertising, product sales typically increase due to higher awareness and demand. Positive
Unemployment Rate and Consumer Spending As the unemployment rate rises, consumer spending tends to fall because fewer people have income to spend. Negative
Price of Goods and Quantity Demanded As the price of a product increases, the quantity demanded typically decreases, assuming other factors are constant (law of demand). Negative

Formula for Covariance

The covariance formula can be used to determine the direction of the relationship between two variables or stocks:

For a sample data:

cov(X, Y) = Σ((x – x̄) * (y – ȳ)) / (n-1)

For population data, the formula is:

cov(X, Y) = Σ((x – x̄) * (y – ȳ)) / n

Where:

  • cov(X, Y) represents the covariance between variables X and Y
  • Σ denotes the summation symbol, which indicates that you need to sum up all the values calculated within the brackets
  • x and y represent the values of variables X and Y, respectively
  • x̄ and ȳ represent the means of variables X and Y, respectively
  • n represents the number of observation

Types of Covariance

There are three types of Covariance:

1. Positive Covariance

When two variables tend to move in the same direction, they are said to have positive covariance. In other words, one variable goes up; the other one usually follows suit. Vice versa. Therefore, in this instance, the value of covariance will be positive.

Example

Step 1: List the Data Points

The data points for X and Y are:

X=[1,2,3,4,5] 

Y=[2,4,6,8,10]

Step 2: Calculate the Means of X and Y

x̄=(1+2+3+4+5)/5=3

ȳ=(2+4+6+8+10)/5=6

Step 3: Calculate the Deviations from the Mean

Σ(x – x̄)=[1−3,2−3,3−3,4−3,5−3]=[−2,−1,0,1,2]

Σ(y – ȳ)=[2−6,4−6,6−6,8−6,10−6]=[−4,−2,0,2,4]

Step 4: Multiply the Deviations and Sum Them

Multiply each deviation of X by the corresponding deviation of Y: 

(−2)×(−4)=8

(−1)×(−2)=2

0×0=0

1×2=2

2×4=8

Sum these products: 20

Step 5: Calculate the Covariance

cov(X, Y) = Σ((x – x̄) * (y – ȳ)) / n

=20/5=4

2. Negative Covariance

Negative covariance is a term we use when two variables tend to move in opposite directions. This implies that if one variable increases, the other will decrease. When this happens, the covariance value will be negative.

Example

X: [1, 2, 3, 4, 5]

Y: [10, 8, 6, 4, 2]

Cov(X,Y)=4−8−2+0−2−8​=4−20​=−4

3. Zero Covariance

When the two variables don't have a straight-line relationship, their covariance is zero. This means the variables might be related in some way. But it's hard to predict how they'll move together. In this case, the covariance value will be very close to zero.

Example

X: [1, 2, 3, 4, 5]

Y: [7, 1, 9, 3, 5]

Cov(X,Y)=4−4+4+0−2+0​=4−2​=−0.5≈0

Covariance Vs. Variance Vs. Correlation

Knowing dissimilarities among covariance variance and correlation is essential in finance and statistics.

Covariance and variance are both used to measure the extent to which data points fluctuate from each other. However, they differ in their uses—for instance, variance measures spread along a single axis.

Covariance checks out whether there is any relationship between two variables. When you have different investments in your portfolio, it is important to know how they perform relative to one another.

On the other hand, the correlation coefficient measures how strong or weak a linear relationship exists between two variables, hence, giving more standardized indicators as compared to covariance.

The table below provides a detailed comparison of covariance, variance, and correlation, outlining their definitions, ranges, indications, interpretations, normalization, usage, and examples:

Covariance Vs. Variance Vs. Correlation

Feature Covariance Variance Correlation
Definition Measures the directional relationship between two variables. Measures the spread of data points along a single axis. Measures the strength and direction of the relationship between two variables.
Range Can be any value (positive or negative) Always non-negative Ranges from -1 to +1
Indicates Direction of the linear relationship Degree of spread around the mean Strength and direction of the linear relationship
Interpretation Positive covariance: variables move in the same direction; negative covariance: variables move in opposite directions. Higher variance indicates greater spread. +1: perfect positive correlation; -1: perfect negative correlation; 0: no correlation
Normalization Not normalized Not normalized Normalized by standard deviations of the variables
Usage Financial asset analysis, portfolio diversification Risk assessment, data dispersion analysis Statistical analysis, financial market prediction
Example Covariance of stock returns to assess portfolio risk. Variance of test scores to evaluate consistency of performance. Correlation between height and weight to study relationship strength.

Free Resources

To continue learning and advancing your career, check out these additional helpful WSO resources: