From sample data, calculate estimates of how two random variables covary and how they correlate.
The idea
The sample covariance of paired data is the sum of cross-products of deviations, divided by n − 1. Covariance = Σ(x − x̄)(y − ȳ) ÷ (n − 1). It is positive when the variables tend to be above or below their means together, and its size depends on the units. The sample correlation divides the covariance by the product of the two sample standard deviations. Corr = covariance ÷ (sx × sy). It is unit-free and lies between −1 and 1. If you use the divisor n in the covariance, use it in the variances too. The divisor then cancels in the correlation. From sums, the centred cross-sum has a shortcut. Cross-sum = Σxy − (Σx × Σy) ÷ n. Correlation measures only linear dependence, so a correlation of zero does not mean the variables are independent.
Formulas
Sample covariance
sXY = Σ(xᵢ − x̄) × (yᵢ − ȳ) ÷ (n − 1)
- xᵢ
- each observation of X
- yᵢ
- the paired observation of Y
- x̄
- the sample mean of X
- ȳ
- the sample mean of Y
- n
- the number of pairs
Its size depends on the units. Dividing by the two sample standard deviations gives the correlation, in which the divisor cancels if used consistently.
A practice question
Which expression is the sample covariance of paired observations (x_i, y_i), i = 1, ..., n, with the usual divisor?
- The sum of (x_i - x-bar)² (y_i - y-bar)², divided by n - 1.Why not: Squares the deviations, which gives a fourth-order cross moment instead of the covariance.
- The sum of x_i y_i, divided by n - 1.Why not: Omits the centring on the sample means.
- The sum of (x_i - x-bar)(y_i - y-bar), divided by n - 1. - correct
- The sum of (x_i - x-bar)(y_i - y-bar), divided by the product of the two sample standard deviations.Why not: This divides by the standard deviations, producing the correlation, not the covariance.
The sample covariance averages the product of deviations from the sample means. With the n - 1 divisor it is unbiased; dividing by the two standard deviations instead gives the sample correlation.
A harder one
Six paired observations of two risk factor moves are X = 2, 4, 5, 7, 9, 12 and Y = 1, 3, 6, 6, 10, 11. What is the sample covariance with the n - 1 divisor?
- 13.5 - correct
- 11.25Why not: Uses the divisor n instead of n - 1.
- 67.5Why not: Reports the sum of cross-products without dividing.
- 61.6Why not: Sums the raw products x_i y_i without subtracting the sample means.
x-bar = 6.5, y-bar = 6.167. Sum of cross-deviations = 67.5. Divide by n - 1 = 5: 13.5.
The hardest tier
From n = 10 paired observations a risk analyst records: sum of x = 20, sum of y = 30, sum of xy = 75, sum of x² = 60, sum of y² = 110. What is the sample correlation?
- 0.92Why not: Uses the raw sums without centring on the sample means, which overstates the correlation.
- 0.83Why not: Mixes divisors: the covariance uses n - 1 but the variances in the denominator use n.
- 0.75 - correct
- 0.67Why not: Mixes divisors the other way: the covariance uses n while the variances use n - 1.
Centred cross-sum = 75 - 20 x 30/10 = 15; centred sums of squares are 20 and 20. Correlation = 15/sqrt(20 x 20) = 0.75. The divisor cancels if used consistently.
In the app: 6 practice questions on this outcome, spaced review that brings it back before you forget it.
Start free →More in Sample Moments
- Use sample data to estimate a mean, a variance and a standard deviation.
- Describe how a sample moment differs from a population moment.
- Distinguish an estimator, which is a rule, from an estimate, which is a value it produces.
- Explain what the bias of an estimator is and what it indicates about the estimator.
- Interpret the claim that the estimator of the mean is BLUE.
- Define the consistency of an estimator and describe why the idea is useful.
- Apply the Central Limit Theorem (CLT) and the Law of Large Numbers (LLN) to a sample mean, saying what each result implies.
- Use data to estimate the skewness and kurtosis of a random variable and interpret the results.
- Use sample data to estimate quantiles, the median among them.
- Apply the CLT after estimating the means of two variables from sample data.
- Relate coskewness and cokurtosis back to the skewness and kurtosis of a single variable.