Covariance vs Correlation: When to Use Which?

⚡ TL;DR: Covariance shows the direction of a linear relationship; correlation shows both direction and strength on a scale of –1 to +1. Use correlation to compare relationships across different datasets; use covariance for portfolio risk or as input to algorithms like PCA.

Covariance vs. Correlation is one of the most common questions in statistics and data science. Both measure the relationship between two variables, but they do so in very different ways. If you’re building a machine learning model, choosing the wrong one can ruin your feature selection. In finance, confusing them leads to incorrect portfolio risk assessments. This guide breaks down the mathematical difference, explains why correlation is just normalized covariance, and gives you a clear checklist for when to use which.

Table of Contents

🔑 Key Takeaways

  • Covariance is unbounded and unit-dependent; correlation is bounded between –1 and +1 and unitless.
  • Correlation = covariance divided by the product of the standard deviations.
  • Use correlation to compare the strength of relationships across different datasets.
  • Use covariance when you need raw co-movement measures (e.g., portfolio variance) or as input for PCA.
  • Covariance vs correlation both assume linearity; for non-linear or ordinal data, use Spearman’s rank correlation.
✅ Quick answer: Covariance tells you whether two variables move together (positive or negative direction) but not how strongly. Correlation standardises that measure so you can say “a correlation of 0.8 is always strong” regardless of units. Use covariance for math involving variance; use correlation for communicating and comparing.

The Core Difference (Covariance vs Correlation)

Before we dive into the math, here’s the high-level summary of covariance vs correlation:

FeatureCovarianceCorrelation
DefinitionDirection of linear relationshipStrength and direction of linear relationship
Range$-\infty$ to $+\infty$ (unbounded)$-1$ to $+1$ (bounded)
UnitsProduct of the units (e.g., $kg \cdot m$)Unitless (pure number)
Scale sensitivityChanges with scale (e.g., cm vs m)Not affected by scale
Best forVariance calculations, algorithms, proofsComparing relationships, reporting

What is Covariance?

Covariance measures how two variables move together. It answers: “Do these variables tend to increase or decrease together?”

  • Positive covariance ($>0$): As $X$ increases, $Y$ also tends to increase.
  • Negative covariance ($<0$): As $X$ increases, $Y$ tends to decrease.
  • Zero covariance ($\approx 0$): No linear relationship.

The Formula

For a population: $$Cov(X,Y) = \frac{\sum (x_i – \bar{x})(y_i – \bar{y})}{N}$$

For a sample, we use the Bessel’s correction n-1: $$Cov_{\text{sample}}(X,Y) = \frac{\sum (x_i – \bar{x})(y_i – \bar{y})}{n-1}$$

🎯 From experience: A mistake I often see is forgetting to divide by $n-1$ for sample data. That small difference can change your portfolio variance estimate by a non-trivial amount, especially with small datasets.

The Problem with Covariance

The main issue with covariance is that it is not normalised. If you measure height in meters, the covariance might be 0.5. Change to centimetres and the same data gives 5,000. That makes it impossible to judge if a covariance value is “strong” or “weak”. This is exactly why we need correlation.

What is Correlation?

Correlation (specifically the Pearson correlation coefficient $r$) is simply the scaled version of covariance. It divides covariance by the product of the two standard deviations, forcing the result between –1 and +1.

The Formula

$$\rho_{X,Y} = \frac{Cov(X,Y)}{\sigma_X \sigma_Y}$$

Where $\sigma_X$ and $\sigma_Y$ are the standard deviations of $X$ and $Y$.

ℹ️ Note: The Pearson correlation coefficient formula can also be written in the “computational” form: $$r = \frac{n\sum xy – (\sum x)(\sum y)}{\sqrt{[n\sum x^2 – (\sum x)^2][n\sum y^2 – (\sum y)^2]}}$$ which avoids calculating deviations separately.

Interpreting Correlation

  • +1: Perfect positive linear relationship.
  • –1: Perfect negative linear relationship.
  • 0: No linear relationship (the data could still be related non-linearly!).
  • 0.7: Strong positive relationship.
  • 0.3: Weak positive relationship.

Because it is unitless, a correlation of 0.8 in a biology experiment is exactly as strong as a correlation of 0.8 in finance. That’s the beauty of the covariance vs correlation transformation.

Let’s walk through the algebra step by step. Start with the definition of Pearson’s $r$:

$$r = \frac{\sum (x_i – \bar{x})(y_i – \bar{y})}{n \cdot \sigma_X \sigma_Y}$$

Now replace the numerator with $n \cdot Cov(X,Y)$ (population covariance):

$$r = \frac{n \cdot Cov(X,Y)}{n \cdot \sigma_X \sigma_Y} = \frac{Cov(X,Y)}{\sigma_X \sigma_Y}$$

That’s it. Correlation is covariance divided by the product of standard deviations. Because $\sigma_X$ and $\sigma_Y$ have the same units as $X$ and $Y$, the division removes all units. That’s why correlation is a pure, scale-free number. It is the normalised version of covariance — the real difference in the covariance vs correlation debate.

💡 Pro tip: When explaining to non-technical stakeholders, I say: “Correlation is covariance after removing the effect of scale. It lets us compare apples to oranges — literally, if you measured apple and orange weights.”

Interpreting Correlation Strength: Rules of Thumb

Once you have a correlation value, how strong is it? The following thresholds are widely used (Statistics By Jim covers these well):

|r| < 0.3
Weak relationship
0.3–0.7
Moderate relationship
|r| > 0.7
Strong relationship

Important caveats: These are rough guidelines. An $r$ of 0.4 might be “weak” in physics but “strong” in social sciences. Always consider the context. Also, correlation only captures linear relationships — a perfect U-shaped curve can have $r \approx 0$. Always plot your data. And outliers can inflate or deflate $r$ dramatically. Always check a scatterplot before trusting the number.

Spearman’s Rank Correlation: When to Use It

Pearson correlation assumes the data is continuous and normally distributed. But real-world data is often ordinal, skewed, or has outliers. That’s where Spearman’s rank correlation ($\rho$ or $r_s$) comes in — it’s a non-parametric alternative.

How it works

Instead of using raw values, Spearman’s correlation converts each variable to ranks, then applies the Pearson formula on those ranks. The formula is:

$$r_s = 1 – \frac{6\sum d_i^2}{n(n^2-1)}$$

where $d_i$ is the difference between the ranks of the two variables for observation $i$, and $n$ is the number of observations.

⚠️ Avoid this: Do not use Pearson correlation on ordinal survey data (e.g., Likert scales). Spearman is the correct choice. I once saw a study report a “Pearson r = 0.12, not significant” when Spearman gave 0.45 (strong) — the researcher had lost a real pattern.

Spearman can detect monotonic relationships (not just linear ones). If $Y$ consistently increases as $X$ increases, even if the increase is curved, Spearman will give a high value. It is also less sensitive to outliers.

Real-World Applications: Finance and Portfolio Theory

The covariance vs correlation distinction is critical in finance, especially in the Markowitz portfolio model. Let’s see a concrete example.

Portfolio Variance (Covariance)

The variance of a two-asset portfolio is:

$$\sigma_p^2 = w_A^2 \sigma_A^2 + w_B^2 \sigma_B^2 + 2 w_A w_B Cov(A,B)$$

Covariance is used directly here because it captures the co-movement in the same units as returns. You need the covariance matrix to compute portfolio risk.

If you want to know whether diversification is working, correlation is better.

Diversification and Beta (Correlation)

The correlation between a stock and the market tells you how much of its risk is systematic. Beta is derived from covariance and variance:

$$\beta_A = \frac{Cov(A, Market)}{\sigma_{Market}^2}$$

But beta can also be written as:

$$\beta_A = \rho_{A, Market} \cdot \frac{\sigma_A}{\sigma_{Market}}$$

Here, $\rho$ is the correlation. A low correlation (e.g., 0.2) reduces beta and thus systemic risk.

🧪 Worked Example

Two stocks: Apple (AAPL) and Microsoft (MSFT)

Suppose monthly returns: Cov(AAPL, MSFT) = 0.0024, $\sigma_{AAPL}=0.06$, $\sigma_{MSFT}=0.05$.

Correlation = $\frac{0.0024}{0.06 \times 0.05} = \frac{0.0024}{0.003} = 0.8$. A strong positive linear relationship means they tend to move together, limiting diversification.

If you calculate a two-asset portfolio variance using the covariance matrix (as explained in The Ultimate Guide to the Covariance Matrix), you get a clearer picture of total risk.

When to Use Which? (Decision Checklist)

Use Covariance When:

  1. Calculating Portfolio Risk: Modern Portfolio Theory uses the covariance matrix.
  2. Deriving Mathematical Proofs: Covariance has linearity properties that simplify algebra.
  3. Input for Algorithms: PCA and other dimensionality reduction methods use the covariance matrix. For a hands-on example, see Step-by-Step PCA with NumPy.

Use Correlation When:

  1. Comparing Relationships: “Is income more related to education than age?” — you must use correlation.
  2. Feature Selection: In a correlation heatmap, drop one of any pair with $|r| > 0.95$ to avoid multicollinearity.
  3. Reporting to Stakeholders: “The correlation is 0.85” is instantly interpretable; “covariance is 1,200” is not.

✔️ Quick checklist

  • ☑️ Need to compare across different scales? → Correlation
  • ☑️ Building a mathematical model of variance? → Covariance
  • ☑️ Reporting strength to a non-technical audience? → Correlation
  • ☑️ Data is ordinal or non-normal? → Spearman’s rank correlation

Common Misconception: Correlation Does Not Imply Causation

Both covariance and correlation only measure linear association — they do not prove that one variable causes the other. The classic example: ice cream sales and crime rates both increase in summer, giving a strong positive correlation. But eating ice cream does not cause crime; both rise because of a third factor (hot weather).

“Correlation is a necessary condition for causation, but not a sufficient one.”

Always be cautious. If you find a high correlation, consider lurking variables, reverse causation, or simple coincidence. The covariance vs correlation distinction doesn’t change this fundamental limitation — both are about association, not causation.

Worked Example: Covariance and Correlation Step-by-Step

Let’s see the math in action with a simple dataset.

$X = [1, 2, 3]$, $Y = [2, 4, 6]$

Step 1: Means: $\bar{x} = 2$, $\bar{y} = 4$.

Step 2: Deviations:

$(x_i – \bar{x}) = [-1, 0, 1]$; $(y_i – \bar{y}) = [-2, 0, 2]$

Step 3: Covariance (population):

$$Cov = \frac{(-1)(-2) + (0)(0) + (1)(2)}{3} = \frac{2+0+2}{3} = \frac{4}{3} \approx 1.33$$

Positive covariance — as $X$ increases, $Y$ tends to increase.

Step 4: Standard deviations: $\sigma_X = \sqrt{\frac{(-1)^2+0^2+1^2}{3}} = \sqrt{\frac{2}{3}} \approx 0.816$, $\sigma_Y = \sqrt{\frac{(-2)^2+0^2+2^2}{3}} = \sqrt{\frac{8}{3}} \approx 1.633$.

Step 5: Correlation:

$$\rho = \frac{1.33}{0.816 \times 1.633} = \frac{1.33}{1.333} \approx 1.0$$

Perfect positive linear relationship — all points lie exactly on a line.

This example illustrates the covariance vs correlation transformation: the raw covariance depends on the units and magnitude, but the correlation always gives a standardised measure of strength.

Frequently Asked Questions

What is the main difference between covariance and correlation?+

Covariance indicates the direction of a linear relationship (positive or negative) but its value depends on the units. Correlation standardises covariance to a scale of –1 to +1, showing both direction and strength, independent of units.

When should I use Spearman’s rank instead of Pearson correlation?+

Use Spearman when your data is ordinal, not normally distributed, or has outliers. Spearman captures monotonic relationships (not just linear), making it more robust for real-world data.

Can covariance be used for portfolio risk calculation?+

Yes, the covariance matrix is essential in Modern Portfolio Theory to compute portfolio variance. Correlation can then be derived from covariance and used to assess diversification.

Does correlation imply causation?+

No. Both covariance and correlation only measure linear association, not causation. Confounding variables, reverse causality, or coincidence can produce high correlations without any causal link.

Why is correlation always between –1 and +1?+

Because correlation = covariance divided by the product of the standard deviations. The denominator is always at least as large as the absolute value of covariance, forcing the ratio into the [–1, +1] interval. This is proven by the Cauchy–Schwarz inequality.

Ready to go further?

Master the full covariance matrix and its application in finance and machine learning.

Explore the Covariance Matrix →
Scroll to Top