Econ 424/CFRM 462 Portfolio Theory With Matrix Algebra: Eric Zivot
Econ 424/CFRM 462 Portfolio Theory With Matrix Algebra: Eric Zivot
Econ 424/CFRM 462 Portfolio Theory With Matrix Algebra: Eric Zivot
Eric Zivot
Aug 7, 2014
Portfolio Math with Matrix Algebra
⎛ ⎞ ⎛ ⎞ ⎛ ⎞
1
R=⎜ ⎟ ⎜ ⎟ ⎜ ⎟
⎝ ⎠ = ⎝ ⎠ 1 = ⎝ 1 ⎠
1
⎛ ⎞ ⎛ ⎞
2
⎜ ⎟ ⎜ 2 ⎟
x = ⎝ ⎠ Σ = ⎝ ⎠
2
t(x.vec)%*%mu.vec
crossprod(x.vec, mu.vec)
Excel formula
MMULT(transpose(xvec),muvec)
ctrl-shift-enter
Portfolio variance
2 = x0Σx
⎛ ⎞⎛ ⎞
2
⎜ 2 ⎟ ⎜ ⎟
= ( ) ⎝ ⎠ ⎝ ⎠
2
= 2
2 + 2 2 + 2 2
+ 2 + 2 + 2
Portfolio distribution
2 )
∼ (
R formulas
t(x.vec)%*%sigma.mat%*%x.vec
Excel formulas
MMULT(TRANSPOSE(xvec),MMULT(sigma,xvec))
MMULT(MMULT(TRANSPOSE(xvec),sigma),xvec)
ctrl-shift-enter
Covariance Between 2 Portfolio Returns
2 portfolios
⎛ ⎞ ⎛ ⎞
⎜ ⎟ ⎜ ⎟
x = ⎝ ⎠ y = ⎝ ⎠
x01 = 1 y0 1 = 1
Portfolio returns
= x0R
= y0R
Covariance
cov( ) = x0Σy
= y0Σx
R formula
t(x.vec)%*%sigma.mat%*%y.vec
Excel formula
MMULT(TRANSPOSE(xvec),MMULT(sigma,yvec))
MMULT(TRANSPOSE(yvec),MMULT(sigma,xvec))
ctrl-shift-enter
Derivatives of Simple Matrix Functions
min 2
= m0Σm s.t. m01 = 1
The Lagrangian is
(m ) = m0Σm+(m01 − 1)
First order conditions (use matrix derivative results)
(m ) m0Σm
0 = = + (m01 − 1) = 2 · Σm+1
(3×1) m m m
(m ) m0Σm
0 = = + (m01 − 1) = m01 − 1
(1×1)
Write FOCs in matrix form
à !à ! à !
2Σ 1 m 0 3×1
=
10 0 1 1×1
The FOCs are the linear system
Az = b
where
à ! à ! à !
2Σ 1 m 0
A = z = and b =
10 0 1
The solution for z is
z = A−1
b
The first three elements of z are the portfolio weights m = ( )0
for the global minimum variance portfolio with expected return = m0
2
and variance = m0Σm
Alternative Derivation of Global Minimum Variance Portfolio
The first order conditions from the optimization problem can be expressed in
matrix notation as
(m )
0 = = 2 · Σm+ · 1
(3×1) m
(m )
0 = = m01 − 1
(1×1)
Using first equation, solve for m :
1
m = − · Σ−11
2
Next, multiply both sides by 10 and use second equation to solve for :
1
1 = 10m = − · 10Σ−11
2
1
⇒ = −2 · 0 −1
1Σ 1
Finally, substitute the value for in the equation for m:
1 1
m = − (−2) 0 −1 Σ−11
2 1Σ 1
Σ−11
= 0 −1
1Σ 1
Efficient Portfolios of Risky Assets: Markowitz Algorithm
Problem 1: find portfolio x that has the highest expected return for a given
level of risk as measured by portfolio variance
max = x0 s.t
2 = x0Σx = 0 = target risk
x01 = 1
Problem 2: find portfolio x that has the smallest risk, measured by portfolio
variance, that achieves a target expected return.
min 2 = x0Σx s.t.
= x0 = 0 = target return
x01 = 1
Remark: Problem 2 is usually solved in practice by varying the target return
between a given range.
Solving for Efficient Portfolios:
Using the matrix algebra formulas (see R code in Powerpoint slides) we get
⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞
08275 05194
⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟
x = ⎝ ⎠ = ⎝ −00908 ⎠ y = ⎝ ⎠ = ⎝ 02732 ⎠
02633 02075
Also,
z = · x + (1 − ) · y
is a frontier portfolio. Furthermore
z = · x + (1 − ) · y
⎛ ⎞ ⎛ ⎞
⎜ ⎟ ⎜ ⎟
= · ⎝ ⎠ + (1 − ) ⎝ ⎠
⎛ ⎞ ⎛ ⎞
+ (1 − )
⎜ ⎟ ⎜ ⎟
= ⎝ + (1 − ) ⎠ = ⎝ ⎠
+ (1 − )
Example: Compute efficient portfolio as convex combination of efficient port-
folio with same mean as MSFT and efficient portfolio with same mean as
SBUX.
Let x denote the efficient portfolio with the same mean as MSFT, y denote
the efficient portfolio with the same mean as SBUX, and let = 05 Then
z = · x + (1 − ) · y
⎛ ⎞ ⎛ ⎞
082745 05194
⎜ ⎟ ⎜ ⎟
= 05 · ⎝ −009075 ⎠ + 05 · ⎝ 02732 ⎠
026329 02075
⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞
(05)(082745) (05)(05194) 06734
⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟
= ⎝ (05)(−009075) ⎠ + ⎝ (05)(02732) ⎠ = ⎝ 00912 ⎠ = ⎝ ⎠
(05)(026329) (05)(02075) 02354
Example continued
Use
005 = = · + (1 − )
to solve for :
005 − 005 − 00285
= = = 1514
− 00427 − 00285
Then, solve for portfolio weights using
z = · x + (1 − ) · y
⎛ ⎞ ⎛ ⎞ ⎛ ⎞
08275 05194 09858
⎜ ⎟ ⎜ ⎟ ⎜ ⎟
= 1514 ⎝ −00908 ⎠ − 0514 ⎝ 02732 ⎠ = ⎝ −02778 ⎠
02633 02075 02920
Strategy for Plotting Portfolio Frontier
2. Find asset that has highest expected return. Set target return to 0 =
max() and solve
2 = x0Σx s.t.
min
x
= x0 = 0 = max()
x01 = 1
3. Create grid of values, initially between 1 and −1 and compute
z = · m + (1 − ) · x
= · + (1 − )
2 = 2 2 + (1 − )2 2 + 2(1 − )
= m0Σx
4. Plot against Expand or contract the grid of values if necessary
to improve the plot
Finding the Tangency Portfolio
The tangency portfolio t is the portfolio of risky assets that maximizes Sharpe’s
slope:
−
max Sharpe’s ratio =
t
subject to
t01 = 1
In matrix notation,
t0 −
Sharpe’s ratio =
(t0Σt)12
Solving for Efficient Portfolios:
• If the risk free rate, is less than the expected return on the global
minimum variance portfolio, min then the tangency portfolio has a
positive Sharpe slope
• If the risk free rate, is equal to the expected return on the global
minimum variance portfolio, min then the tangency portfolio is not
defined
• If the risk free rate, is greater than the expected return on the global
minimum variance portfolio, min then the tangency portfolio has a
negative Sharpe slope.
Mutual Fund Separation Theorem Again
Efficient Portfolios of T-bills and Risky assets are combinations of two portfolios
(mutual funds)
• T-bills
• Tangency portfolio
Efficient Portfolios
• If Sharpe’s slope for the tangency portfolio is negative then the efficient
portfolio involve shorting the tangency portfolio
Example: Find efficient portfolio with target risk (SD) equal to 0.02
Solve
Solve
Also,
= = (1386)(01116) = 01547
Portfolio Value-at-Risk
Let x = (1 )0 denote a vector of asset share for a portfolio. Portfolio
risk is measured by var() = x0Σx Alternatively, portfolio risk can be
measured using Value-at-Risk:
VaR = 0
0 = initial investment
= 100 · % Simple return quantile
= loss probability
If returns are normally distributed then
= +
= x0
³ ´12
0
= x Σx
= 100 · % quantile from (0 1)
Example: Using VaR to evaluate an efficient portfolio
VaR SBUX
= $100 000 · 05
05
= $100 000 · (−0203) = −$20 300
VaR05 = $100 000 · 05