Variances and covariances Michael Wood Printed March 6, 2016 This handout explains some of the mathematical properties of variances and covariances. This may be helpful for your understanding of some theories in finance, but you will not be expected to be familiar with this material in the Decision and Risk Analysis exam (although it might enhance your answers to some questions). Read this in conjunction with the example on the spreadsheet VarianceCovariance.xls . The variance is the square of the standard deviation. In symbols this is written VAR(X) =(1/n) Σ (X−XBar)2 (Equation 1) Where n is the sample size, and XBar is the mean of all the X’s. (Σ means “the sum of the bit to the right worked out for each individual X”. Sometimes—if there is a possibility of ambiguity—these individual X’s are called Xi.) The covariance is a bit like the variance except that it involves another variable, Y: COVAR(X,Y)=(1/n) Σ (Xi−XBar)(Yi−YBar) (Equation 2) To see how the covariance works imagine first that there is a strong positive correlation between X and Y. This means that if Xi is above the mean of the X’s (Xbar), then Yi is also likely to be above the mean of the Y’s (Ybar). On the other hand if Xi is below the mean of the X’s (Xbar), then Yi is also likely to be below the mean of the Y’s (Ybar). In either case multiplying them together will give a positive result, so the covariance will be positive. Now imagine X and Y are negatively correlated. This means if one is above the mean, the other is likely to be below, so the signs are likely to be different and result is negative. Adding up lots of negative terms, of course, is likely to give a negative covariance. Obviously, of the correlation is around zero, some terms will be positive, others negative, and the result is likely to be a covariance that is around zero. This means the covariance is a bit like a correlation coefficient. The only problem is that its magnitude will depend on size of X’s and Y’s. For this reason we divide by the standard deviation of the X’s and of the Y’s (as it’s the deviations from the mean that feed into the covariance, not the absolute size of the X’s and Y’s) if we want a correlation coefficient. This gives Pearson’s correlation coefficient, r: r = COVAR(X,Y)/(sx sy) (Equation 3) There is also a formula for the slope of a regression line in terms of the covariance and variances. If you are using a single variable, X, to predict Y, the slope of the least squares prediction line is Slope = COVAR(X,Y)/VAR(X) (Equation 4) This is easy to prove if you know a bit of calculus (see a book on mathematical statistics, or ask me if you are interested). The variance and covariance are particularly useful because they enable us to analyse sums and averages of a series of variables. The following formula is always true for any two variables X and Y: VAR(X+Y) = VAR(X) + VAR(Y) + 2COVAR(X,Y) (Equation 5) This is proved below—but don’t worry about this unless you are interested. This formula is particularly useful when X and Y are uncorrelated, because then COVAR(X,Y)=0 and the formula becomes VAR(X+Y) = VAR(X) + VAR(Y) (Equation 6) With any particular set of data, this will only be exactly true if the correlation (and covariance) is exactly zero. However, it is a useful approximation for two variables whose correlation is approximately zero. Equations 5 and 6 can be extended to cover more than two variables. Equation 5 is a bit complicated to extend, but Equation 6 is easier: VAR(X+Y+Z+…) = VAR(X) + VAR(Y) + VAR(Z) + … (Equation 7) provided that the variables are not correlated (i.e. the correlations between each pair of variables is zero). In ordinary language, Equation 7 says that if variables are uncorrelated, the variance of the sum is the same as the sum of the variances. Equation 7 can be used to work out the predicted standard deviation of the mean of a random sample. If the sample is X1, X2, … Xn we can write the mean as (1/n)X1+ (1/n)X2, + … (1/n)Xn . The individual members of the sample are obviously uncorrelated, so the variance of this sum is just the sum of the variances. It should be obvious from Equation 1 that VAR{(1/n)X} = (1/n)2 VAR(X) so if all the X’s are from the same population VAR(sample mean) = (1/n)2 VAR(X) + … + (1/n)2 VAR(X) or (remembering the sample size is n) VAR(sample mean) = (1/n) VAR(X) So Standard deviation of the sample mean = (standard deviation of X)/√n (Equation 8) This is often called the standard error of the mean. Proof of Equation 5 VAR(X+Y) = (1/n)∑{(X+Y) – (XBar-YBar)}2 = (1/n)∑{(X-XBar) – (Y-YBar)}2 = (1/n)∑{(X-XBar)2 + (Y-YBar)2 + 2(X-XBar)(Y-YBar)} = VAR(X) + VAR(Y) + 2COVAR(X,Y) which is Equation 4.