Professional Documents
Culture Documents
Topic 05 - Markowitz
Topic 05 - Markowitz
Paul Geertsema
1
Contents
1 Readings 4
3 Introduction 7
4 Mean-variance analysis 10
5 Matrix algebra 15
5.1 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . 20
2 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Contents (cont.)
8 Tikhonov regularisation 31
3 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
1 Readings
4 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
2 What are we doing today
5 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
What are we doing today (cont.)
• Tools
– Vectors, matrices and their implementation in Excel and Python
– Markowitz mean variance analysis
◦ Portfolio return and variance
◦ Investor indifference curves
◦ The optimal portfolio
– Some extensions
◦ Minimum-variance portfolio
◦ Portfolio optimisation with OLS regressions
◦ Tikhonov regularisation
6 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
3 Introduction
7 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Introduction (cont.)
“The basic principles of portfolio theory came to me one day while I was
reading John Burr Williams, The Theory of Investment Value. Williams
proposed that the value of a stock should equal the present value of
its future dividend stream. But clearly dividends are uncertain, so I
took Williams’ recommendation to be to value a stock as the expected
value of its discounted future dividend stream. But if the investor
is concerned only with the expected values of securities, the investor
must also be only interested in the expected value of the portfolio. To
maximize the expected value of a portfolio, one need only invest in one
security - the security with maximum expected return (or one such,
if several tie for maximum). Thus action based on expected return
only (like action based on certainty of the future) must be rejected
as descriptive of actual or rational investment behavior. It seemed
obvious that investors are concerned with risk and return, and that
these should be measured for the portfolio as a whole. Variance (or,
8 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Introduction (cont.)
9 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
4 Mean-variance analysis
• Some implications
– Effect of introducing a risk free asset
– The two fund separation theorem
– Effect of short sale constraints
– Effect of differential borrowing and lending rates
11 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Mean-variance analysis (cont.)
• Key Assumptions
– Investors have
◦ Mean-variance preferences
◦ or (equivalently) quadratic utility U (W ) = W − 2b W 2 with b >
0
– Investors “know”
◦ Expected returns
◦ Covariance of every asset with every other asset
• As it turns out these assumptions are problematic in practice, the
second perhaps more than the first
12 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Mean-variance analysis (cont.)
• Important consequence 1
– Portfolio returns are just the weighted sum of asset returns
◦ rp = Pni=1 wiri
– Not true for risk!
◦ Portfolio return variance is not just the weighted sum of asset
return variances
◦ σp2 = Pni=1 Pnj=1 wiwj COV [ri, rj ]
◦ It depends on covariance between assets
◦ Anything less that perfect correlation provides diversification
benefits
– The risk in a portfolio will be less than the sum of risk of the
individual assets (given less than perfect correlation)
– And that is a mathematical fact
◦ Just remember that in crisis correlations tends to 1 for risky
assets
◦ Why?
13 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Mean-variance analysis (cont.)
• Important consequence 2
– In a large, well diversified portfolio, idiosyncratic stock-specific
risk is diversified away
– Only systematic or market risk remains
– Hence, only market risk should earn a risk premium
14 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
5 Matrix algebra
15 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
5.1 Vectors
• r = 2
3
16 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
1
• Let r = 2 and w = w = 10 11 12
′
T
3
1
10 + 22 + 36 = 68
r1
r3
r1
• Then w·r = wT r = w′r = w1 w2 w
r2 = w1r1 +w2r2 +w3r3
3
r3
17 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
• Clearly, this only makes sense if both vectors are of the same length
• Let ri indicate the i-th element of r, and similarly define wi as the
i-th element of w
• w′r = P3i=1 wiri (convince yourself!)
• Application: Given a vector r of n expected returns and a vector
w of n portfolio weights
– a) What is the expected return of the portfolio?
– b) What constraints should be placed on the portfolio weights?
• Answer:
– a) rp = w′r = Pni=1 wiri
– b) w′1 = 1 where 1 is a column vector filled with n elements,
each equal to 1
• So vectors allow us to dispense with all the fiddly summations...
18 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
19 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
5.2 Matrices
5 6
20 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
1 2 3
• So let Σ = 2 1 4
3 4 1
1 4 2
– 1 2 3 2 5 3
3 6 1
– = (1 ∗ 1 + 2 ∗ 2 + 3 ∗ 3) (1 ∗ 4 + 2 ∗ 5 + 3 ∗ 6) (1 ∗ 2 + 2 ∗ 3 + 3 ∗ 1)
21 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
– = 14 32 11
• Now, it turns out that the portfolio variance is given by σp2 = w′Σw
– Note, the order of the matrices are important, but the order of
multiplication is not
– So (w′Σ)w = w′(Σw) ̸= w′wΣ
22 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
• An example - assume:
– portfolio weights w = 0.2 0.3 0.5
′
1.8 1.2 1.0
0.2
– 1.22 1.95 1.32 0.3 = 1.489
0.5
23 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
√
– So the portfolio standard deviation is simply σp2
r
= 1.489 ≈
1.22 = 122%
• Now, let’s do it in Excel
– w′ =transpose(<range of w>)
– w′Σ =mmult(<range of w′>,<range of Σ>)
– Important!
◦ to save an array function
◦ highlight the area to be filled in (get the dimensions
right)
◦ type in the correct formula but do not type ENTER
◦ then press CONTROL-SHIFT-ENTER instead of ENTER
• Now you can calculate the portfolio variance for a 5000 stock port-
folio with a handful of excel formulas
• Go give it a try yourself ...
24 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
import numpy as np
w = [0.2 , 0.3 , 0.5] # weights
r = [0.03 , 0.04 , 0.05] # returns
VCV = [[1.8 , 1.2 , 1.0] , # VCV matrix
[1.2 , 4.2 , 0.9] ,
[1.0 , 0.9 , 1.7]]
print ( " Weights = " , w )
print ( " VCV = " , VCV )
er = np . dot (w , r )
print ( " Expected return = " , er ) # around 0.043
var = np . matmul ( np . matmul ( np . transpose ( w ) , VCV ) , w )
print ( " Variance = " , var ) # around 1.4889
sd = np . sqrt ( var )
print ( " Standard deviation = " , sd ) # around 1.22
25 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)
27 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Markowitz portfolio optimisation (cont.)
28 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Markowitz portfolio optimisation (cont.)
29 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
7 The link to least squares regression
30 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
8 Tikhonov regularisation
31 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Tikhonov regularisation (cont.)
32 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema