Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Econ 424/CFRM 462 Portfolio Theory With Matrix Algebra: Eric Zivot

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

Econ 424/CFRM 462

Portfolio Theory with Matrix Algebra

Eric Zivot

Aug 7, 2014
Portfolio Math with Matrix Algebra

Three Risky Asset Example

Let  ( =   ) denote the return on asset  and assume that  follows


CER model:
 ∼  ( 2)
cov(  ) = 
Portfolio “x”
 = share of wealth in asset 
 +  +  = 1
Portfolio return
 =  +   +   
Stock    Pair (i,j) 
A (Microsoft) 0.0427 0.1000 (A,B) 0.0018
B (Nordstrom) 0.0015 0.1044 (A,C) 0.0011
C (Starbucks) 0.0285 0.1411 (B,C) 0.0026
Table 1: Three asset example data.

In matrix algebra, we have


⎛ ⎞ ⎛ ⎞
 00427
⎜ ⎟ ⎜ ⎟
 = ⎝  ⎠ = ⎝ 00015 ⎠
 00285
⎛ ⎞ ⎛ ⎞
2
   ⎜
(01000)2 00018 00011 ⎟
Σ=⎜ ⎝  2


 ⎠ = ⎜
⎝ 00018 (01044)2 00026 ⎟⎠
  2 2
00011 00026 (01411)
Matrix Algebra Representation

⎛ ⎞ ⎛ ⎞ ⎛ ⎞
  1
R=⎜ ⎟ ⎜ ⎟ ⎜ ⎟
⎝  ⎠   = ⎝  ⎠  1 = ⎝ 1 ⎠
  1
⎛ ⎞ ⎛ ⎞
 2
  
⎜ ⎟ ⎜ 2 ⎟
x = ⎝  ⎠  Σ = ⎝    ⎠
   2

Portfolio weights sum to 1


⎛ ⎞
1
⎜ ⎟
x01 = (    ) ⎝ 1 ⎠
1
= 1 + 2 + 3 = 1
Portfolio return
⎛ ⎞

⎜ ⎟
 = x0R = (    ) ⎝  ⎠

=  +   +  
Portfolio expected return
⎛ ⎞

⎜ ⎟
 = x0 = (    ) ⎝  ⎠

=  +   +  
R formula

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

Let A be an  ×  symmetric matrix, and let x and y be an  × 1 vectors.


Then
⎛ ⎞
 x0y
 0 ⎜ 1. ⎟
xy ⎜
=⎝ . ⎟ = y (1)

x  x0y
×1
⎛  ⎞
 x0Ax
 0 ⎜ 1 . ⎟
x Ax ⎜
=⎝ . ⎟ = 2Ax (2)

x  x0Ax
×1 
Computing Global Minimum Variance Portfolio

Problem: Find the portfolio m = (    )0 that solves

min 2
 = m0Σm s.t. m01 = 1
 

1. Analytic solution using matrix algebra

2. Numerical Solution in Excel Using the Solver (see 3firmExample.xls)


Analytic solution using matrix algebra

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

Az = 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:

1. Analytic solution using matrix algebra

2. Numerical solution in Excel using the solver


Analytic solution using matrix algebra

The Lagrangian function associated with Problem 2 is

( 1 2) = x0Σx + 1(x0−0) + 2(x01 − 1)


The FOCs are
(x 1 2)
0 = = 2Σx + 1 + 21
(3×1) x
(x 1 2)
0 = = x0 − 0
(1×1) 1
(x 1 2)
0 = = x01 − 1
(1×1) 2
These FOCs consist of five linear equations in five unknowns

(     1 2)


We can represent the FOCs in matrix notation as
⎛ ⎞⎛ ⎞ ⎛ ⎞
2Σ  1 x 0
⎜ 0 ⎟⎜ ⎟ ⎜ ⎟
⎝  0 0 ⎠ ⎝ 1 ⎠ = ⎝ 0 ⎠
10 0 0 2 1
or
Az= b0
where
⎛ ⎞ ⎛ ⎞ ⎛ ⎞
2Σ  1 x 0
A = ⎜ ⎟ ⎜ ⎟ ⎜ ⎟
⎝ 0 0 0 ⎠  z = ⎝ 1 ⎠ and b0 = ⎝ 0 ⎠
10 0 0 2 1
The solution for z is then
z = A−1
 b0
The first three elements of z are the portfolio weights x = (    )0 for
the efficient portfolio with expected return  = 0.
Example: Find efficient portfolios with the same expected return as MSFT and
SBUX

For MSFT, we solve

min 2 = x0Σx s.t.



 
 = x0 =   = 0.0427
x01 = 1
For SBUX, we solve

min 2 = y0Σy s.t.



 
 = y0 =   = 0.0285
y0 1 = 1
Example continued

Using the matrix algebra formulas (see R code in Powerpoint slides) we get
⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞
  08275   05194
⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟
x = ⎝  ⎠ = ⎝ −00908 ⎠  y = ⎝  ⎠ = ⎝ 02732 ⎠
 02633  02075
Also,

 = x0 = 00427  = y0 = 00285


 = (x0Σx)12 = 009166  = (y0Σy)12 = 007355
 = x0Σy = 0005914  =  ( ) = 08772
Computing the Portfolio Frontier

Result: The portfolio frontier can be represented as convex combinations of


any two frontier portfolios. Let x be a frontier portfolio that solves
2 = x0Σx s.t.
min 
x
 = x0 = 0
x01 = 1
Let y 6= x be another frontier portfolio that solves
2 = y0Σy s.t.
min 
y
 = y0 = 1 6= 0
y0 1 = 1
Let  be any constant. Then the portfolio

z =  · x + (1 − ) · y
is a frontier portfolio. Furthermore

 = z0 =  ·  + (1 − )


2 = z0Σz

= 2
2 + (1 − )2 2 + 2(1 − )
 
 = cov(  ) = x0Σy
Example: 3 asset case

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  = 05 Then

z =  · x + (1 − ) · y
⎛ ⎞ ⎛ ⎞
082745 05194
⎜ ⎟ ⎜ ⎟
= 05 · ⎝ −009075 ⎠ + 05 · ⎝ 02732 ⎠
026329 02075
⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞
(05)(082745) (05)(05194) 06734 
⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟
= ⎝ (05)(−009075) ⎠ + ⎝ (05)(02732) ⎠ = ⎝ 00912 ⎠ = ⎝  ⎠ 
(05)(026329) (05)(02075) 02354 
Example continued

The mean of this portfolio can be computed using:


⎛ ⎞
00427
⎜ ⎟
 = z0 = (06734 00912 02354)0 ⎝ 00015 ⎠ = 00356
00285
 =  ·  + (1 − ) = 05(00427) + (05)(00285) = 00356
The variance can be computed using
2 = z0Σz = 000641

2 = 2 2 + (1 − )2 2 + 2(1 − )
   
= (05)2(009166)2 + (05)2(007355)2 + 2(05)(05)(0005914) = 000641
Example: Find efficient portfolio with expected return 0.05 from two efficient
portfolios

Use
005 =  =  ·  + (1 − )
to solve for  :
005 −  005 − 00285
= = = 1514
 −  00427 − 00285
Then, solve for portfolio weights using

z =  · x + (1 − ) · y
⎛ ⎞ ⎛ ⎞ ⎛ ⎞
08275 05194 09858
⎜ ⎟ ⎜ ⎟ ⎜ ⎟
= 1514 ⎝ −00908 ⎠ − 0514 ⎝ 02732 ⎠ = ⎝ −02778 ⎠
02633 02075 02920
Strategy for Plotting Portfolio Frontier

1. Set global minimum variance portfolio = first frontier portfolio


2
min  = m0Σm s.t. m01 = 1
m
and compute  = m0

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)12
Solving for Efficient Portfolios:

1. Analytic solution using matrix algebra

2. Numerical solution in Excel using the solver


Analytic solution using matrix algebra

The Lagrangian for this problem is


³ ´
− 12
(t ) = t  −  (t Σt) + (t01 − 1)
0 0

Using the chain rule, the first order conditions are


(t ) ³ ´
− 12
0 = = (t Σt) − t  −  (t0Σt)−32Σt + 1
0 0
(3×1) t
(t )
0 = = t01 − 1 = 0
(1×1) 
After much tedious algebra, it can be shown that the solution for t is
Σ−1( −  · 1)
t = 0 −1
1 Σ ( −  · 1)
Remarks:

• 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

 = share of wealth in tangency portfolio t


 = share of wealth in T-bills
 +  = 1 ⇒  = 1 − 
 =  + ( −  )  = t0
³ ´12
 =   = 0
t Σt
Remark: The weights  and  are determined by an investor’s risk prefer-
ences

• Risk averse investors hold mostly T-Bills ( ≈ 0)

• Risk tolerant investors hold mostly tangency portfolio ( ≈ 1)

• 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

002 =  =  = (01116)


002
⇒  = = 01792
01116
 = 1 −  = 08208
Also,

 =  + ( −  ) = 0005 + (01116) (005189 − 0005) = 00134


 =  = (01792)(01116) = 002
Example: Find efficient portfolio with target ER equal to 0.07

Solve

007 =  =  + ( −  )


007 −  007 − 0005
⇒  = = = 1386
 −  005189 − 0005

Also,
 =  = (1386)(01116) = 01547
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
³ ´12
0
 = x Σx
 = 100 · % quantile from (0 1)

Example: Using VaR to evaluate an efficient portfolio

Invest in 3 risky assets (Microsoft, Starbucks, Nordstrom) and T-bills. Assume


 = 0005

1. Determine efficient portfolio that has same expected return as Starbucks

2. Compare VaR05 for Starbucks and efficient portfolio based on $100,000


investment
Solution for 1.
SBUX = 00285
 =  + ( −  )
 = 0005
 = t0 = 05186  = 0111
Solve
00285 = 0005 + (005186 − 0005)
00285 − 005
 = = 0501
005186 − 005
 = 1 − 0501 = 0499
Note:
 = 0005 + 0501 · (005186 − 0005) = 00285
 =  = (0501)(0111) = 0057
Solution for 2.
SBUX = 
05 SBUX + SBUX · (−1645)
= 00285 + (0141) · (−1645)
= −0203
 =  +   · (−1645)
05  
= 0285 + (057) · (−1645)
− 0063
Then

VaR SBUX
= $100 000 · 05
05
= $100 000 · (−0203) = −$20 300
VaR05 = $100 000 · 05

= $100 000 · (−0063) = −$6 300

You might also like