# BASIC Covariance Question

An analyst observes the following return behavior between stocks X and Y. Time Period X’s Return Y’s Return 1 7 5 2 9 8 3 10 11 4 10 8 What is the covariance of returns between stocks X and Y? A) +3.0. B) -3.0. C) -1.5. D) +1.5. The correct answer was A. Covariance = {Σ[(ReturnX − MeanX)(ReturnY − MeanY)]} / (n − 1) MeanX = (7 + 9 + 10 + 10) / 4 = 9; MeanY = (5 + 8 + 11 + 8) / 4 = 8 CovX,Y = [(7 − 9)(5 − 8) + (9 − 9)(8 − 8) + (10 − 9)(11 − 8) + (10 − 9)(8 − 8)] / (4 − 1) = 3.0 MY QUESTION IS: WHY DO WE DIVIDE BY (n - 1) IN THE DENOMINATOR? FOR COVARIANCE QUESTIONS, DO WE ALWAYS DIVIDE BY (n-1) in the denominator? Thanks in advance for any responses.

It has to do with the concept of degrees of freedom. If you have n terms in the sample, there are n-1 terms that have the freedom to vary. You will always do so when finding the covariance of a sample, but will not when finding the covariance of two random variables.

yea, it’s because it’s a sample.

A follow up question, why two variables don’t require n - 1 ?

wyantjs Wrote: ------------------------------------------------------- > It has to do with the concept of degrees of > freedom. If you have n terms in the sample, there > are n-1 terms that have the freedom to vary. You > will always do so when finding the covariance of a > sample, but will not when finding the covariance > of two random variables. man, all through uni, i never really grasp the concept of degrees of freedom until now after you said it that way. I always just took it as truth and never understood why. Thanks Wyantjs!

xck2000 Wrote: ------------------------------------------------------- > wyantjs Wrote: > -------------------------------------------------- > ----- > > It has to do with the concept of degrees of > > freedom. If you have n terms in the sample, > there > > are n-1 terms that have the freedom to vary. > You > > will always do so when finding the covariance of > a > > sample, but will not when finding the > covariance > > of two random variables. > > man, all through uni, i never really grasp the > concept of degrees of freedom until now after you > said it that way. I always just took it as truth > and never understood why. > > Thanks Wyantjs! My exact sentiments many thanks Wyantjs!

Thanks for responding. Now I know. For a sample, use (n-1), and for two random variables, use n thanks again.

richarge Wrote: ------------------------------------------------------- > A follow up question, > > why two variables don’t require n - 1 ? Because finding covariance of two random variables involves expected values from a probability law, and not an observed arithmetic average. I guess that you can view it as dividing by n-1, because with two random variables n = 2 afterall, so dividing by 1 really seems a bit trivial. Look at it like this: 1) Covariance of sample: Given the data…5, 10, 15, 20, 25 for sample #1 and 6, 9, 13, 21, 21 for sample # 2 Sample # 1 mean = 15 Sample # 2 mean = 14 When finding variance, we find the the squared deviations from the mean. Imagine in sample #1 we did not square the differences. Then the sum of those differences would always add to zero. Therefore, all 5 cannot vary because they will always sum to zero. Only 4 can vary to ensure that the sum != 0. This idea is extended to covariance as well which would include the second sample. 2) Covariance of two random variables: The expected value of a random variable is used here, which may or may not be a possible outcome. It is determined by a probability law, and not by the average of the observed outcomes. The key word is possible. The event has not occured yet, but we are inferring how the two variables interact based upon their joint probability laws.

I guess I don’t think it’s so basic given all the odd explanations. Principle #1: n vs (n-1) vs [anything similar] just doesn’t matter. It’s a tiny little part of a formula for a technical reason and there are much bigger fish to fry. Anyway, the big picture is that you have random variables that you observe in pairs, say (X, Y). That means that you should be thinking of measures of association between the variables. It turns out that the covariance between the X and Y is the right measure of the variables are normal because it completely specifies the joint distribution (along with some mu’s and sigma’s). Now we observe a bunch of (X, Y) pairs - sampling from this distribution. We want to estimate this covariance, maybe because we think that they are normal, but maybe also because we can’t think of anything better to do. So we calculate this sum (x[i] - X-bar)(y[i] - Y-bar) thing and divide by something like n and call that an estimator of the covariance. It turns out that if you divide by n (which is really natural for lots of reasons) the estimator you get is biased in the sense that it is systematically too small. The reason for that is kinda in the math but it’s also down the road of wyantjs #1, the (x[i] - x-bar) is systematically smaller than (x[i] - mu) because the x[i]'s are used to calculate the X-bar. In the greater scheme of things, this is wildly unimportant. Things that are important: 1) The sample covariance is an estimator of the population covariance 2) The covariance is the right measure of association between normal variables, but may not be for non-normal variables. 3) The covariance has units and can be standardized by dividing by some std. dev’s to get the correlation which is usually more useful. Note #2, however, which also applies to correlations. 4) All the stuff about correlations.