Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

FINANCE 361 – Topic 5 – Markowitz

Paul Geertsema

1
Contents

1 Readings 4

2 What are we doing today 5

3 Introduction 7

4 Mean-variance analysis 10

5 Matrix algebra 15
5.1 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . 20

6 Markowitz portfolio optimisation 27

7 The link to least squares regression 30

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

• Read BKM Ch 7 (including Appendix B)

4 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
2 What are we doing today

• Review of mean-variance analysis (Markowitz)


• A cornerstone of what is now known as Modern Portfolio Theory
• This lecture, I will introduce the tools you need to do “industrial
strength” portfolio optimisation

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

• Basic insight is due to Markowitz (1952)


• It was already accepted that, in considering a security, an investor
should consider both the risk and expected return
• The first insight of Markowitz was that this should also be true at
the portfolio level
• The second insight was that portfolio risk can be measured by
variance or standard deviation of returns (aka volatility)
• Combined, this means an investor should trade off portfolio expec-
ted return against portfolio variance
– Mean-variance analysis

7 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Introduction (cont.)

• Below from “Foundations of portfolio theory”, Markowitz’s Nobel


Lecture, 7 December 1990

“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.)

equivalently, standard deviation), came to mind as a measure of risk


of the portfolio. The fact that the variance of the portfolio, that is the
variance of a weighted sum, involved all covariance terms added to the
plausibility of the approach. Since there were two criteria - expected
return and risk - the natural approach for an economics student was to
imagine the investor selecting a point from the set of Pareto optimal
expected return, variance of return combinations, now known as the
efficient frontier. These were the basic elements of portfolio theory
which appeared one day while reading Williams.”
• Pareto optimal
– Improving one desirable aspect without decreasing any other
desirable aspect
– ie improving returns without increasing risk

9 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
4 Mean-variance analysis

• Decision making in mean-variance space

• Source: Wikipedia (http://en.wikipedia.org/wiki/Modern_portfolio_theory)


10 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Mean-variance analysis (cont.)

• 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

• Normal algebra is fine for considering two assets


– rp = w1r1 + w2r2
– σp2 = w12σ12 + w22σ22 + 2w1w2COV [r1, r2]
• However, if we want to look at many assets (5, 40 or 2,000) then
it becomes unwieldy
• Solution: matrix algebra
• May look daunting, but it is really just a way to treat a block of
numbers as a single mathematical variable
• The usefulness of this approach will become obvious when we use
Excel to construct optimal portfolios
• Let’s have a look

15 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)

5.1 Vectors

• A vector (or a column vector to be precise) is a list of numbers


presented in a column
 
1

• r = 2






3

• We can turn it into a row-vector using a transpose


T ′
 
–r =r = 1 2 3
– Transpose just means switching rows and columns
– Excel =transpose(<range>)
• We can multiply a row-vector with a column vector to obtain a
single number (called a scalar in matrix-land)
• This particular way of multiplying is called the dot product (there
are others, don’t worry about them)

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 

• Then w·r = wT r = w′r = 10 11 12 2 = 1∗10+2∗11+3∗12 =


 
 



3
 

10 + 22 + 36 = 68
 
r1 

• More generally let r =  2 and w = w = w1 w2 w3



 
T
 
r 
 

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.)

• More importantly, we can calculate the expected portfolio return


for any number of stocks with a single Excel formula *
– Assume r is contained in range A1:A1000 and w is contained
in range B1:B1000) (yes, a thousand stocks)
– E[rp] = w′r = w · r =sumproduct(A1:A1000,B1:B1000)
– Yes, that simple
– (* as long as it all fits, obviously)

19 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Matrix algebra (cont.)

5.2 Matrices

• A matrix is a rectangular block of numbers


• A matrix with M rows and N columns is called a M × N matrix
 
1 2

• For instance x =   is a 3 × 2 matrix


 
3 4
 

5 6
 

– A column vector of size n is just a matrix of dimension n × 1


• We will use a matrix to represent the block of pairwise covariances
between different assets, aka the variance-covariance matrix aka
the covariance matrix aka the VCV
• To keep it simple let’s stick with the earlier example with three
assets
• By convention, the variance-covariance matrix is denoted by Σ
(“Sigma”)

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
 

– What is the covariance of stock 2 with stock 3? (It is 4)


– Note: a VCV is always square
• Note it is symmetrical around the diagonal; this makes sense since
covariance is symmetric (COV [x, y] = COV [y, x])
• You will need to know how to multiply a row-vector with a matrix
– Basically, do a dot-product between the row-vector and each
column vector in the matrix, and put each answer in a row-
vector  

 
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

 

– portfolio expected returns r = 3% 4% 5%



 

 
1.8 1.2 1.0

– portfolio asset covariances (the VCV) Σ = 


 
1.2 4.2 0.9
 


1.0 0.9 1.7
 

• Let me break that down...


– First calculate k = w′Σ 
1.8 1.2 1.0
    
– k = 0.2 0.3 0.5 1.2 4.2 0.9 = 1.22 1.95 1.32
 
 

1.0 0.9 1.7


 

– Then calculate σp2 = (w′Σ)w = kw


 


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.)

• If you’d like to do this in Python


– www.programiz.com/python-programming/online-compiler/

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.)

• You should also know what is meant by the inverse of a matrix


– What is the inverse of 5?
◦ 1/5 or 0.2 – Because a number multiplied by its inverse = 1
– The equivalent of 1 in the matrix world is the identity matrix, I
– It is a square block of zeros, except for the diagonal, which is
filled with 1’s

1 0 0
 
– I = 0 1 0
 


0 0 1
 

– It is the case that AI = IA = A, just like 5 ∗ 1 = 1 ∗ 5 = 5


– The matrix inverse of some (square) matrix A is denoted by
A−1 and must satisfy A−1A = I
– Multiplying a matrix by its inverse should yield the identity mat-
rix (the equivalent of 1 in matrix land)
– Excel =minverse(<square range here>)
– Python (numpy) np.linalg.inv(matrix)
26 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
6 Markowitz portfolio optimisation

• The Markowitz optimal portfolio (or tangency portfolio) maximises


the Sharpe ratio of a portfolio of risky assets
• Sharpe ratio = expected portfolio excess return / standard deviation
of portfolio returns
E[r]−rf w′ r−rf
• SR = SD[r] = √
w′ Σw
• where w is a column vector of portfolio weights that add to 1 and
r is a column vector of expected asset returns, both of length N .
rf is the risk free rate and Σ is the variance-covariance matrix.
• Thus the optimisation problem to solve is:
w′ r−rf
– choose w to maximise √
w′ Σw
– subject to w′1 = 1 (1 is a column vector of N ones)

27 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Markowitz portfolio optimisation (cont.)

• Denote by µ the vector of excess expected returns of the assets:


µ = r − rf
• The Markowitz optimal portfolio of risky assets (the tangency port-
folio) is given by
⋆ Σ−1µ Σ−1µ
• w = ′ −1 =
1Σ µ SUM(Σ−1µ)
• Excel: =MMULT(MINVERSE(VCV),G)/SUM(MMULT(MINVERSE(VCV),G))
• The minimum variance portfolio is the combination of risky assets
that minimises portfolio return variance (eg risk), without consid-
ering returns
⋆ Σ −11 Σ −11
• wminvariance = ′ −1 =
1Σ 1 SUM(Σ−11)

28 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Markowitz portfolio optimisation (cont.)

• How do we estimate the variance-covariance (VCV) matrix Σ?


– Estimating the VCV matrix from historical data
◦ Step 1: Obtain historical returns for N stocks over T months
(stocks across, returns going down)
◦ Step 2: Demean the returns (subtract the average return of
each stock from all of that stock’s returns); call this R. NB:
demeaning is NOT the same as calculating excess returns.
◦ Step 3: Calculate (R′R)/T -> this is the VCV Σ
◦ Step 4: Convert to annual frequency if needed (if you used
monthly data, multiply by 12)
– EXCEL: =(MMULT(TRANSPOSE(R),R)/T)*12

29 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
7 The link to least squares regression

• Britten-Jones (1999, Journal of Finance) showed that Markow-


itz portfolio optimisation can be implemented using ordinary least
squares (OLS) regression. (We will cover OLS regressions in a later
topic).
• To do this, simply regress the excess asset returns against a variable
that always contains the constant 1. The regression should omit
the usual intercept term.
• Rescaling the coefficients estimated for each asset so they sum to
one produces the Markowitz optimal portfolio.

30 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
8 Tikhonov regularisation

• Recently it has been proposed that classical Markowitz portfolio op-


timisation might be made more robust by penalising “large” weights
directly as part of the optimisation process.
• This is known as "Tikhonov regularisation" and is related to "ridge
regression" in the same way Markowitz optimisation is related to
OLS regression.
• To implement this approach, minimise portfolio variance σp2 =
w′Σw + λw′w subject to w′µ = p (target return) and w′1N = 1
(weights add to 1).
• Note that w′w is simply the sum of the squares of the portfolio
weights
• The extra term λw′w in the objective is the penalty term, with
the scalar parameter λ (“lambda”) acting to regulate the relative
strength of the penalty

31 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema
Tikhonov regularisation (cont.)

• To calculate the Tikhonov optimal portfolio weights:


– The historical data is contained in X (the “data” matrix con-
taining excess returns; assets in columns, different months in
rows)
– Calculate θ = (X ′X + λI)−1(X ′y)
◦ I is the identity matrix – it is zero everywhere except along
the diagonal which is filled with ones.
– Calculate wT ikhonov = 1θ′θ (that is, θ is re-scaled to add to 1).
wT ikhonov contains the Tikhonov optimal portfolio weights for
the assets.

32 FINANCE 361 Class Notes – University of Auckland – Copyright (C) Dr Paul Geertsema

You might also like