Close Ad
AdBlocker Detected
Calculatored depends on revenue from ads impressions to survive. If you find calculatored valuable, please consider disabling your ad blocker or pausing adblock for calculatored.

Covariance Tutorial

Formula:

$$Cov (X,Y) =\frac{\sum (X_i - \overline X)(Y_i - \overline Y)}{n-1}$$

Where :

  • xi = Data variable of x
  • yi = Data variable of y
  • x = Mean of x
  • y = Mean of y
  • n = Number of data variables

Example :

Suppose that the closing prices of two stocks daily basis is given below:

day abc return xyz return
1 2.8 1.5
2 2.5 3.3
3 1.1 3.6
4 1.4 3.1
5 0.4 2.2

Calculate the mean(average):

$$\text{Mean(abc)} =$$

$$\frac{2.8 + 2.5 + 1.1 + 1.4 + 0.4}{5}$$

$$\text{Mean(abc)} = 1.64 $$

$$\text{Mean(xyz)}\;=$$

$$\frac{1.5 + 3.3 + 3.6 + 3.1 + 2.2}{5} $$

$$\text{Mean(xyz)} = 2.74 $$

$$Cov (X,Y) =\frac{\sum (X_i - \overline X)(Y_i - \overline Y)}{n-1}$$

Put the values into the formula

Cov(x,y) =(((2.8 – 1.64) * (1.5 – 2.74)) + ((2.5 – 1.64)*
(3.3 – 2.74)) + ((1.1 – 1.64) * (3.6 – 2.74)) +
(1.4 – 1.64) * (3.1 –2.74) + ((0.4 – 1.64) *
(2.2 – 2.74))) / (5 – 1)

$$Cov(x,y)\;=$$

$$\frac{-1.44 + 0.48 - 0.46 - 0.08 + 0.67}{4}$$

$$Cov(x,y) = \frac{- 0.83}{4}$$

$$Cov(x,y) = -0.20$$