Combinations aX + bY: how weights enter variance and covariance

30 min · 4 drills

In the textbook: Ch. 9.2 Die Kovarianz von Zufallsgrößen

In the exam two random variables are rarely just added. More often they come with factors: the takings 2X−Y, an investment 0.8X+0.2Y, a deal “sell two units, buy three”. The spread of such an expression depends on the spread of each quantity and on how the two move together. The factors enter it differently from what one first expects.

An investor puts 80 % of the money into one share and 20 % into another. The investor knows how strongly the price of each share swings, and also that the two tend to move in opposite directions: when one falls, the other usually rises.

How strongly does the whole investment swing?

The first idea: take 80 % of the first share's spread and 20 % of the second's. But the spread is the average of the squared distance, so the percentages enter it squared. And the fact that the two shares move in opposite directions damps part of the swings, which has to be computed too.

Say the variance of the first stock's return is 0.04, of the second 0.09, and the covariance is −0.01 (negative, because the stocks move in opposite directions).

  • The first thought gives 0.8⋅0.04+0.2⋅0.09=0.05.
  • With the shares squared it is 0.64⋅0.04+0.04⋅0.09=0.0292.
  • The opposite movement takes off another 2⋅0.8⋅0.2⋅0.01=0.0032.

The variance of the whole investment is 0.026, half of the first thought. The same calculation with the general formula is in the section “The variance of a linear combination” below, in the example “portfolio shares as weights”.

Check yourself. A task at exam level: σx2=5, σy2=7 and V(2X+Y)=35. What is the covariance σxy?

The basics: covariance, variance of a sum and correlation

Combinations are built from the ideas of the article “Covariance: how two quantities move together”. Here they are on the beach kiosk from there: X is the crates of water per day, Y the crates of ice cream.

  • Variance V(X)=σx2 is the spread of one quantity: at the kiosk σx2=2.16 and σy2=0.96. Its square root is the standard deviation, σx≈1.47 and σy≈0.98.
  • Covariance σxy=Cov⁡(X,Y) shows how strongly the quantities move together: at the kiosk σxy=0.24. For independent quantities it is 0. The covariance of a quantity with itself is its variance, Cov⁡(X,X)=σx2, and the order does not matter: Cov⁡(X,Y)=Cov⁡(Y,X).
  • The variance of a sum holds twice the covariance: V(X+Y)=σx2+σy2+2σxy=2.16+0.96+2⋅0.24=3.6.
  • Correlation ρ=σxyσx⋅σy lies between −1 and 1, at the kiosk ρ≈0.17. The other way round, σxy=ρ⋅σx⋅σy.

Weights: the variance of aX + bY

The crates from the article on covariance now carry a price: a crate of water earns 2 €, a crate of ice cream costs us 1 € to buy. The profit is then 2X−Y. The quantities come with factors, called weights: a=2 and b=−1. If dx=X−μx and dy=Y−μy are the deviations of the quantities from their means, then the deviation of the combination is a⋅dx+b⋅dy, and the square multiplies out the same way:

(a⋅dx+b⋅dy)2=a2⋅dx2+2a⋅b⋅dx⋅dy+b2⋅dy2

A handy picture is a grid of four cells: put a⋅X and b⋅Y on both edges, and each cell is the product of its row and its column. The cell “a⋅X times a⋅X” gives a2⋅σx2, the cell “b⋅Y times b⋅Y” gives b2⋅σy2, and the two mixed cells give a⋅b⋅σxy each:

V(a⋅X+b⋅Y)=a2⋅σx2+b2⋅σy2+2a⋅b⋅σxy

With a=b=1 this is the variance of a sum from the previous section. The numbers for the grid are round and belong to another pair of quantities, not the kiosk: σx2=4, σy2=9, σxy=1, and we need V(2X−Y). The figure shows the grid: top left 4⋅4=16, bottom right 1⋅9=9, in each mixed cell 2⋅(−1)⋅1=−2.

Grid for V(2X − Y): the corners hold the variances times the squared weights, the two mixed cells the covariance with the weights; add up all four cells2X−Y2X−Y16−2−29

In total V(2X−Y)=16+9−4=21. The weight −1 squared gives +1, but in the mixed cell the minus stays.

Your turn1 of 4

σx2=5, σy2=3 and σxy=1. What is V(X−Y)?

Covariance from the variance of a combination

In the grid above every cell was known, and the variance was their sum. In the first exam task the sum is already given, and only one cell is empty:

Exam-style task

Ein Netzbetreiber untersucht den Energiebedarf (X) und die Außentemperatur (Y) an Wintertagen. Es gilt σx2=14, σy2=19 und V(3X+7Y)=1015. Berechnen Sie die Kovarianz σxy.

  1. a)−1
  2. b)−4
  3. c)−3
  4. d)1
  5. e)20

The task gives itself away by two signs: the variance of a combination V(a⋅X+b⋅Y) is given as a number, and the question is “Compute the covariance”. The formula for the variance of a combination is read backwards here: one quantity in it is unknown, and you solve for it as in an ordinary linear equation.

Given: σx2=14, σy2=19 and V(3X+7Y)=1015. Find σxy.

Weights 3 and 7 on both edges

Grid for V(3X + 7Y): the corners get numbers from the task, while the two mixed cells keep the unknown covariance3X7Y3X7Y9 σx²21 σxy21 σxy49 σy²
Step 1 of 4Expand the brackets

In 3X+7Y the weights are a=3 and b=7. They go on both edges of the grid.

After expanding, the corners are 3⋅3=9 times σx2 and 7⋅7=49 times σy2. Mixed cells: 3⋅7=21 times σxy, and there are two of them.

Ask yourself: why are there two mixed cells and not one?

The bound from the last step follows from the correlation ρ lying between −1 and 1: ∣σxy∣=∣ρ∣ σx⋅σy≤σx⋅σy. If the absolute value of the answer is above the bound, the arithmetic has a slip.

Now a weight with a minus sign. The task gives σx2=7, σy2=3 and V(3X−2Y)=51. What is σxy?

The minus belongs to the weight: 3 and −2 on the edges

Grid for V(3X − 2Y): the minus of the weight stays in the mixed cells and vanishes in the corners3X−2Y3X−2Y9 σx²−6 σxy−6 σxy4 σy²
Step 1 of 4Expand the brackets

Weights a=3 and b=−2: the minus belongs to the weight. After expanding, the corners are 9σx2 and 4σy2, mixed cells 3⋅(−2)=−6 times σxy each.

One variance is unknown. Given: σx2=4, σxy=1.5 and V(X+2Y)=30. Find σy2.

Weights a=1 and b=2. After expanding, the corners are 1⋅σx2 and 4σy2. Mixed cells 1⋅2=2 times σxy each.

Corner 1⋅4=4. The second corner 4σy2 keeps the unknown. The mixed cells together 2⋅2⋅1.5=6.

The sum of the cells equals 30. Write down this equation and solve for σy2.

Your turn2 of 4

σx2=8, σy2=5 and V(2X+3Y)=89. What is σxy?

If the task asks for the correlation, first find the covariance the same way, then divide by both standard deviations. For example, with V(X)=36, V(Y)=16, V(X+Y)=40, the equation 36+16+2σxy=40 gives σxy=−6, and ρ=−66⋅4=−0.25.

Traps. Each wrong option of this task comes from a single mistake:

  • Sign flipped when moving terms over, option (d), 1: computed 1057−1015=42 instead of 1015−1057. Check: put the answer back in, 1057+42⋅1=1099, not 1015.
  • Weights not squared, option (e), 20: the corners taken as 3⋅14=42 and 7⋅19=133, and (1015−175)/42=20. The bound check catches it at once: 20>16.3, no covariance can be that big.
  • The 2 of the mixed cells lost. If you got −2, you divided −42 by 21 instead of 42: there are two mixed cells, and the equation contains 42σxy.

On the formula sheet: V(a⋅X+b⋅Y)=a2⋅V(X)+2a⋅b⋅Cov⁡(X,Y)+b2⋅V(Y), where V(X) is σx2 and Cov⁡(X,Y) is σxy. Solving it for the covariance is up to you.

The variance of a linear combination

The second task goes forwards again, like the example with V(2X−Y): the covariance is given and the variance is asked. The difficulty lies elsewhere: the weights are hidden in the wording. This is how the task looks in the exam:

Exam-style task

Ein Händler verkauft 2 Einheiten einer Ware zum Preis X und kauft 3 Einheiten einer anderen zum Preis Y ein, sein Ergebnis ist 2X−3Y. Die Preise haben die Varianzen 15 und 6 und die Kovarianz −1. Berechnen Sie die Varianz des Ergebnisses.

  1. a)60
  2. b)120
  3. c)130
  4. d)126
  5. e)95

The task gives itself away by given variances and a covariance and a question about the variance of a combination. The weights come from the wording: “sells 2 units” gives +2X, “buys 3 units” gives −3Y, because buying lowers the result. This is the formula from the section on weights, used forwards.

Weights 2 and −3 on both edges

Grid for V(2X − 3Y): the corners hold the variances with the squared weights, the mixed cells the covariance with the product of the weights; watch two minuses make a plus2X−3Y2X−3Y4 σx²−6 σxy−6 σxy9 σy²
Step 1 of 4Read the weights

2X−3Y: a=2, b=−3. Corners a2=4 times σx2 and b2=9 times σy2, mixed cells a⋅b=−6 times σxy each.

Ask yourself: why has 9σy2 no minus, although the weight is negative?

An investor puts 80 % of the money into a share with return X and 20 % into a share with return Y. A share bought for 50 € and worth 53 € a year later brings 53−5050=0.06 per euro invested: that is its return (“Rendite”) for the year. Nobody knows it in advance, so X and Y are random variables. Given: σx2=0.04, σy2=0.09, covariance σxy=−0.01. What is the variance of the return 0.8X+0.2Y?

Shares 0.8 and 0.2 on both edges

Grid for the portfolio 0.8X + 0.2Y: the shares of the money stand on the edges as weights0.8X0.2Y0.8X0.2Y0.64 σx²0.16 σxy0.16 σxy0.04 σy²
Step 1 of 3Read the weights

a=0.8, b=0.2: corners 0.64σx2 and 0.04σy2, mixed cells 0.16σxy each.

If a correlation is given instead of the covariance, first σxy=ρ⋅σx⋅σy. For example, 70 % in a fund with σ1=0.15 and 30 % in a fund with σ2=0.10 at ρ=0.2: covariance 0.2⋅0.15⋅0.10=0.003, and V=0.49⋅0.0225+0.09⋅0.01+2⋅0.21⋅0.003=0.013185. If the standard deviations are given in percent, compute in percent too: the answer comes out in %2.

Now you: the variance of 3X−Y. The task gives σx2=2, σy2=5 and σxy=0.5. Find V(3X−Y).

a=3, b=−1.

9⋅2=18 and 1⋅5=5.

Work out one mixed cell a⋅b⋅σxy, double it and add everything up.

Your turn3 of 4

σx2=1, σy2=0.96 and σxy=−0.4. What is V(2X+Y)?

Traps. Three mistakes and the numbers they lead to:

  • Weights not squared, option (a), 60: 2⋅15+3⋅6+12=60. The weight enters the corner twice, hence the square.
  • The 2 lost, option (b), 120: only one mixed cell taken, 60+54+6. The grid has two mixed cells.
  • Minus of the covariance lost. If you got 102, you took the covariance as +1: the mixed cells gave −12 instead of +12, and 60+54−12=102. Check: the sign of a mixed cell is the sign of a⋅b times the sign of σxy.

On the formula sheet: V(a⋅X+b⋅Y)=a2⋅V(X)+2a⋅b⋅Cov⁡(X,Y)+b2⋅V(Y). If the standard deviation is asked for, take the root at the end.

The covariance of two combinations

In both tasks above the same combination stood on both edges of the grid, and out came its variance. In the third task two different combinations stand on the edges. Their covariance is already given, and what is wanted is a quantity hidden inside it:

Exam-style task

Ein Versorger kauft Energie ein; X ist der Strompreis, Y der Gaspreis jeweils im Tagesmittel. Es gilt σx2=17, σxy=1 und Cov(2X−Y,2X+2Y)=50. Berechnen Sie die Varianz σy2.

  1. a)5
  2. b)7
  3. c)10
  4. d)9
  5. e)3

The task gives itself away by the expression Cov⁡(…,…) with two different combinations inside. The covariance multiplies out like a product of two brackets: each term on the left with each term on the right. The grid stays the same, only the first combination sits on the left edge and the second on top, and the mixed cells come out different. Here a and b are the weights of the first combination, c and d those of the second:

Cov⁡(a⋅X+b⋅Y,c⋅X+d⋅Y)=a⋅c⋅σx2+(a⋅d+b⋅c) σxy+b⋅d⋅σy2

This works because Cov⁡(X,X)=σx2, Cov⁡(Y,Y)=σy2, and Cov⁡(X,Y) and Cov⁡(Y,X) both equal σxy. If both combinations are the same (c=a, d=b), you get the formula from the section “The variance of a linear combination”.

In the task above the calculation runs backwards. The covariance of the two combinations is given as 50, and the variance σy2 sits unknown in one of the cells. You fill every cell you know, set the sum of all cells equal to 50 and solve for the missing one.

Left 2X and −Y, top 2X and 2Y

Grid for Cov(2X − Y, 2X + 2Y): the first combination on the left, the second on top; the sum of all cells is the given covariance 502X2Y2X−Y4 σx²4 σxy−2 σxy−2 σy²
Step 1 of 4Expand the brackets

First combination 2X−Y: a=2, b=−1. Second 2X+2Y: c=2, d=2.

After expanding, the cells hold: a⋅c=4 times σx2, a⋅d=4 and b⋅c=−2 times σxy, b⋅d=−2 times σy2. The minus of b enters both products that contain b.

We know σx2=4, σy2=9 and Cov⁡(3X+Y,X−2Y)=−10. What is σxy?

Left 3X and Y, top X and −2Y: a=3, b=1, c=1, d=−2.

After expanding, with the values put in: a⋅c⋅σx2=3⋅4=12, b⋅d⋅σy2=−2⋅9=−18, mixed (a⋅d+b⋅c) σxy=(−6+1) σxy=−5σxy.

12−18−5σxy=−10, so −6−5σxy=−10.

−5σxy=−4, σxy=0.8. Check: 12−18−5⋅0.8=−10.

The question is σx2. We know σy2=3, σxy=2 and Cov⁡(2X+Y,X−Y)=4. Find σx2.

Left 2X and Y, top X and −Y: a=2, b=1, c=1, d=−1.

After expanding: a⋅c=2 times σx2, mixed a⋅d+b⋅c=−2+1=−1 times σxy, corner b⋅d=−1 times σy2.

Put in σxy=2 and σy2=3, set it equal to 4 and solve for σx2.

Your turn4 of 4

σx2=6, σy2=3 and Cov⁡(X+2Y,3X−Y)=10. What is σxy?

Traps. What the typical mistakes give:

  • Forgetting the mixed cells, option (d), 9: 68−2σy2=50 gives σy2=9. The cells a⋅d and b⋅c contribute 2σxy=2 together, and that belongs on the known side before you divide by −2.
  • Only one mixed cell: with only a⋅d=4 the equation becomes 72−2σy2=50 and gives 11; with only b⋅c=−2 it becomes 66−2σy2=50 and gives 8. Check: the grid has four cells, and each one contributes.
  • Losing the minus of b⋅d: 70+2σy2=50 would give σy2=−10. A variance is never negative; if you get a negative one, check the signs.
  • Wrong pairs: next to σxy goes a⋅d+b⋅c, the cells where the X of one combination meets the Y of the other. In this task the mistake a⋅c+b⋅d=4−2=2 happens to give the same number; in the quiz above it no longer does.

On the formula sheet: the covariance is linear in each argument, Cov⁡(a⋅X1+b⋅X2,Y)=a⋅Cov⁡(X1,Y)+b⋅Cov⁡(X2,Y), and likewise in the second. Multiplying out both brackets gives a⋅c⋅σx2+(a⋅d+b⋅c) σxy+b⋅d⋅σy2.

At a glance: combinations aX + bY

The topic in a minute

  • Weights are squared, and the sign of a weight shows only in 2a⋅b:
V(a⋅X+b⋅Y)=a2⋅σx2+b2⋅σy2+2a⋅b⋅σxy
  • The other way round: if V(a⋅X+b⋅Y) is given, the same formula is a linear equation for σxy or for one of the variances. Check: the covariance is at most σx⋅σy in absolute value.
  • Two combinations: next to σxy stands the sum a⋅d+b⋅c:
Cov⁡(a⋅X+b⋅Y,c⋅X+d⋅Y)=a⋅c⋅σx2+(a⋅d+b⋅c) σxy+b⋅d⋅σy2
  • Covariance from the variance of a combination

    Given σx2, σy2 and V(a⋅X+b⋅Y), the question asks for σxy (or the covariance is given and one variance is unknown).
    σxy=V(aX+bY)−a2σx2−b2σy22ab

    Trap: flipping the sign when moving terms over or forgetting to square the weights; an answer above σx⋅σy means a mistake.

  • The variance of a linear combination

    Given σx2, σy2 and a covariance or correlation, V(a⋅X+b⋅Y) is wanted; the weights come from units or shares.
    V(aX+bY)=a2σx2+b2σy2+2ab σxy

    Trap: not squaring the weights or taking one mixed cell instead of two.

  • The covariance of two combinations

    Cov⁡(a⋅X+b⋅Y,c⋅X+d⋅Y) with two different combinations is given or asked for.
    ac σx2+(ad+bc) σxy+bd σy2

    Trap: counting one mixed cell; next to σxy stands the sum a⋅d+b⋅c.

A portfolio of several securities is the same weighted combination, only the weights are shares of the money. How the covariance decides its risk is shown in “Portfolio: return and risk”.

Now practise it

Combinations aX + bY: how weights enter variance and covariance

Trainer · Covariance and portfolios

Practise
Next: Portfolio: return and risk
0/4

Was this article helpful?