📈

Understanding Covariance Between Variables

Apr 4, 2025

Lecture Notes: Calculating Covariance Between Two Variables

Introduction

  • Topic: Calculating covariance between two variables X and Y.
  • Purpose: Understand how to use a formula to calculate covariance and interpret its result.

Covariance Formula

  • Formula: Covariance between X and Y is the sum of the products of the differences in X values and their mean (XÌ„) times differences of Y values and their mean (YÌ„), divided by (n-1) for sample covariance or n for population covariance.
    • Sample Covariance: ( \frac{\sum{(X - \bar{X})(Y - \bar{Y})}}{n-1} )
    • Calculation Focus: Sample covariance

Steps to Calculate Covariance Using a Table

  1. Columns Needed:

    • X values
    • Y values
    • Differences (X - XÌ„)
    • Differences (Y - YÌ„)
    • Product of differences (X - XÌ„) * (Y - YÌ„)
  2. Example 1:

    • X Values: 2, 4, 6, 8, 10
    • Y Values: 3, 7, 10, 14, 17
    • Calculate XÌ„ and YÌ„:
      • XÌ„ = 6
      • YÌ„ = 10.2
    • Differences:
      • X - XÌ„: -4, -2, 0, 2, 4
      • Y - YÌ„: -7.2, -3.2, -0.2, 3.8, 6.8
    • Products:
      • 28.8, 6.4, 0, 7.6, 27.2
    • Sum of Products: 70
    • Covariance Calculation:
      • Covariance = 70 / 4 = 17.5
  3. Example 2:

    • X Values: 3, 6, 9, 12, 15
    • Y Values: 20, 17, 13, 9, 4
    • Calculate XÌ„ and YÌ„:
      • XÌ„ = 9
      • YÌ„ = 12.6
    • Differences:
      • X - XÌ„: -6, -3, 0, 3, 6
      • Y - YÌ„: 7.4, 4.4, 0.4, -3.6, -8.6
    • Products:
      • 44.4, 13.2, 0, -10.8, 51.6
    • Sum of Products: -20
    • Covariance Calculation:
      • Covariance = -20 / 4 = -5*

Interpretation of Covariance

  • Positive Covariance:

    • Indicates a positive relationship between X and Y.
    • Example 1: As X increases, Y tends to increase.
  • Negative Covariance:

    • Indicates a negative relationship between X and Y.
    • Example 2: As X increases, Y tends to decrease.
  • Covariance of Zero:

    • No relationship between X and Y.

Graphical Representation

  • Graph 1:

    • Positive correlation; points trend upwards.
    • X: 2, 4, 6, 8, 10; Y: 3, 7, 10, 14, 17
  • Graph 2:

    • Negative correlation; points trend downwards.
    • X: 3, 6, 9, 12, 15; Y: 20, 17, 13, 9, 4

Conclusion

  • Covariance helps determine the type of relationship (positive, negative, none) between two variables.
  • Positive covariance indicates both variables increase together, negative covariance indicates one increases while the other decreases.