Covariance of Returns Calculator
Calculate the covariance between two financial assets using their historical returns in Excel format
Covariance Results
Comprehensive Guide: How to Calculate Covariance of Returns in Excel
Covariance is a fundamental statistical measure in finance that quantifies how much two random variables (in this case, asset returns) vary together. Understanding covariance helps investors assess the diversification benefits of combining different assets in a portfolio.
Positive covariance indicates assets move in the same direction, while negative covariance suggests they move in opposite directions. Zero covariance means no linear relationship exists between the returns.
Step-by-Step Process to Calculate Covariance in Excel
- Prepare Your Data: Organize your return data in two columns (one for each asset) with periods as rows.
- Calculate Means: Use =AVERAGE() to find the mean return for each asset.
- Compute Deviations: For each period, subtract the mean from the actual return for both assets.
- Multiply Deviations: Multiply the paired deviations for each period.
- Average Products: Sum all products and divide by (n-1) for sample covariance or n for population covariance.
Excel Functions for Covariance Calculation
Excel provides built-in functions that simplify covariance calculation:
- =COVARIANCE.P(): Calculates population covariance (divides by n)
- =COVARIANCE.S(): Calculates sample covariance (divides by n-1)
- =PEARSON(): Returns the Pearson correlation coefficient (covariance normalized by standard deviations)
| Function | Formula | When to Use | Example |
|---|---|---|---|
| COVARIANCE.P | Σ[(xᵢ – x̄)(yᵢ – ȳ)] / n | Complete population data | =COVARIANCE.P(A2:A10, B2:B10) |
| COVARIANCE.S | Σ[(xᵢ – x̄)(yᵢ – ȳ)] / (n-1) | Sample data (more common) | =COVARIANCE.S(A2:A10, B2:B10) |
| PEARSON | Cov(x,y) / (σₓ * σᵧ) | Standardized measure (-1 to 1) | =PEARSON(A2:A10, B2:B10) |
Practical Example: Calculating Covariance Between Stocks
Let’s walk through a concrete example using monthly returns for Apple (AAPL) and Microsoft (MSFT):
| Month | AAPL Returns (%) | MSFT Returns (%) | AAPL Deviation | MSFT Deviation | Product of Deviations |
|---|---|---|---|---|---|
| Jan | 5.2 | 3.8 | 1.4 | 0.7 | 0.98 |
| Feb | -1.3 | -2.1 | -5.1 | -5.2 | 26.52 |
| Mar | 8.7 | 7.2 | 4.9 | 4.1 | 20.09 |
| Apr | 3.1 | 4.5 | -0.7 | 1.4 | -0.98 |
| May | -0.5 | 1.2 | -4.3 | -1.9 | 8.17 |
| Mean | 3.84 | 3.12 | Sum: 54.78 |
Sample covariance = 54.78 / (5-1) = 13.695
Population covariance = 54.78 / 5 = 10.956
Interpreting Covariance Values
The magnitude of covariance isn’t standardized, making interpretation context-dependent:
- Positive covariance: Assets tend to move together (good for momentum strategies, bad for diversification)
- Negative covariance: Assets move in opposite directions (excellent for diversification)
- Zero covariance: No linear relationship (may still have non-linear relationships)
For better interpretability, investors often convert covariance to correlation using:
Correlation = Covariance(X,Y) / (σₓ * σᵧ)
Common Mistakes to Avoid
- Using wrong divisor: Confusing population (n) vs sample (n-1) covariance
- Mismatched periods: Comparing returns over different time periods
- Ignoring units: Covariance is in “return units squared” (e.g., %²)
- Overlooking outliers: Extreme values can disproportionately affect covariance
- Assuming causality: Covariance measures association, not causation
Advanced Applications in Portfolio Management
Covariance forms the foundation of Modern Portfolio Theory (MPT):
- Portfolio variance: σₚ² = ΣΣ wᵢwⱼσᵢⱼ (where σᵢⱼ is covariance between assets i and j)
- Diversification benefit: Adding assets with negative covariance reduces portfolio risk
- Minimum variance portfolio: Found by optimizing covariance matrix
- Capital Asset Pricing Model: Uses covariance with market returns
For large portfolios, use Excel’s matrix functions or the Analysis ToolPak to handle covariance matrices efficiently. The =MMULT() function is particularly useful for matrix multiplication required in portfolio variance calculations.
Alternative Methods for Covariance Calculation
Beyond Excel’s built-in functions, consider these approaches:
- Data Analysis ToolPak:
- Go to Data → Data Analysis → Covariance
- Select your input ranges
- Choose output location
- Generates full covariance matrix
- Array Formulas:
=SUM((A2:A10-AVERAGE(A2:A10))*(B2:B10-AVERAGE(B2:B10)))/(COUNT(A2:A10)-1)
(Enter with Ctrl+Shift+Enter in older Excel versions)
- Power Query:
- Import data from various sources
- Transform and clean return data
- Calculate covariance in Power Pivot
Real-World Considerations
When applying covariance analysis to actual investing:
- Time period selection: Use at least 3-5 years of monthly data for meaningful results
- Return calculation: Decide between arithmetic vs logarithmic returns
- Stationarity: Ensure returns don’t have trends that could bias covariance
- Regime changes: Covariance can change during different market conditions
- Transaction costs: High-frequency strategies may erode covariance benefits
Frequently Asked Questions
- Q: Can covariance be negative?
A: Yes, negative covariance indicates an inverse relationship where one asset tends to rise when the other falls.
- Q: How is covariance different from correlation?
A: Correlation is covariance standardized by the standard deviations of both variables, resulting in a value between -1 and 1.
- Q: What’s a good covariance value for diversification?
A: Negative covariance is ideal for diversification, but even low positive covariance can help if combined with proper weighting.
- Q: How often should I recalculate covariance?
A: For active strategies, monthly or quarterly. Long-term investors may recalculate annually or when market regimes change.
- Q: Can I calculate covariance for more than two assets?
A: Yes, you can create a covariance matrix showing pairwise covariances between all assets in your portfolio.