Chapter 1 Portfolio Theory with Matrix Algebra

Updated: November 9, 2011 When working with large portfolios, the algebra of representing portfolio expected returns and variances becomes cumbersome. The use of matrix (linear) algebra can greatly simplify many of the computations. Matrix algebra formulations are also very useful when it comes time to do actual computations on the computer. The matrix algebra formulas are easy to translate into matrix programming languages like R. Popular spreadsheet programs like Microsoft Excel, which are the workhorse programs of many ﬁnancial houses, can also handle basic matrix calculations. All of this makes it worthwhile to become familiar with matrix techniques for portfolio calculations.

1.1

Portfolios with Three Risky Assets

Consider a three asset portfolio problem with assets denoted A, B and C. Let Ri (i = A, B, C) denote the return on asset i and assume that the constant expected return (CER) model holds: Ri ∼ iid N(μi , σ 2 ) i cov(Ri , Rj ) = σ ij . Example 1 Three asset example data 1

2CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA Stock i μi A B C σi Pair (i,j) σ ij 0.0018 0.0011 0.0026

0.0427 0.1000 (A,B) 0.0015 0.1044 (A,C) 0.0285 0.1411 (B,C)

Table 1.1: Three asset example data. Table 1.1 gives example data on monthly means, variances and covariances for the continuously compounded returns on Microsoft, Nordstrom and Starbucks (assets A, B and C) based on sample statistics computed over the ﬁve-year period January, 1995 through January, 20001 . The values of μi and σ i (risk-return trade-oﬀs) are shown in Figure 1.1. Clearly, Microsoft provides the best risk-return trade-oﬀ and Nordstrom provides with worst. ¥ Let xi denote the share of wealth invested in asset i (i = A, B, C) , and assume that all wealth is invested in the three assets so that xA +xB +xC = 1. The portfolio return, Rp,x , is the random variable Rp,x = xA RA + xB RB + xC RC . (1.1)

The subscript “x” indicates that the portfolio is constructed using the xweights xA , xB and xC . The expected return on the portfolio is μp,x = E[Rp,x ] = xA μA + xB μB + xC μC , and the variance of the portfolio return is σ 2 = var(Rp,x ) p,x (1.3) (1.2)

= x2 σ 2 + x2 σ 2 + x2 σ 2 + 2xA xB σ AB + 2xA xC σ AC + 2xB xC σ BC . A A B B C C Notice that variance of the portfolio return depends on three variance terms and six covariance terms. Hence, with three assets there are twice as many covariance terms than variance terms contributing to portfolio variance. Even with three assets, the algebra representing the portfolio characteristics (1.1) - (1.3) is cumbersome. We can greatly simplify the portfolio algebra using matrix notation.
1

This example data is also analyized in the Excel spreadsheet 3ﬁrmExample.xls.

1.1 PORTFOLIOS WITH THREE RISKY ASSETS

3

0.05

0.06

0.03

μp

0.04

E1

MSFT

E2 GLOBAL MIN

SBUX

0.01

0.02

0.00

NORD

0.00

0.05

0.10 σp

0.15

0.20

Figure 1.1: Risk-return tradeoﬀs among three asset portfolios. The portfolio labeled “E1” is the eﬃcient portfolio with the same expected return as Microsoft; the portfolio labeled “E2” is the eﬃcient portfolio with the same expected return as Starbux. The portfolio labeled GLOBAL MIN is the minimum variance portfolio consisting of Microsoft, Nordstrom and Starbucks, respectively.

1.1.1

Portfolio Characteristics Using Matrix Notation

Deﬁne the following 3 × 1 column vectors containing the asset returns and portfolio weights ⎛ ⎛ ⎞ ⎞ xA RA ⎜ ⎜ ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ R = ⎜ RB ⎟ , x = ⎜ xB ⎟ . ⎝ ⎝ ⎠ ⎠ RC xC In matrix notation we can lump multiple returns in a single vector which we denote by R. Since each of the elements in R is a random variable we call R a random vector. The probability distribution of the random vector R is

RC ) = cov(RC . RC ) = cov(RC . RB ).0285 μC ⎞ ⎛ 0.0015 ⎟ . The 3 × 1 vector of portfolio expected values is ⎡⎛ ⎞⎤ ⎛ ⎞ ⎞ ⎛ RA E[RA ] μA ⎢⎜ ⎟⎥ ⎜ ⎟ ⎟ ⎜ ⎢⎜ ⎟⎥ ⎜ ⎟ ⎟ ⎜ E[R] = E ⎢⎜ RB ⎟⎥ = ⎜ E[RB ] ⎟ = ⎜ μB ⎟ = μ. variances and covariances of the returns. RB ) cov(RA .0011 0. Example 2 Example return data using matrix notation Using the example data in Table 1. RB ) = cov(RB . RA ) var(RB ) cov(RB . RC ) ⎜ ⎟ ⎜ ⎟ var(R) = ⎜ cov(RB . We can easily express these values using matrix notation as follows.0109 0.0427 μ ⎟ ⎜ A⎟ ⎜ ⎟ ⎟ ⎜ ⎜ μ = ⎜ μB ⎟ = ⎜ 0. ⎠ ⎝ 0. In the CER model all returns are jointly normally distributed and this joint distribution is completely characterized by the means.0026 ⎟ . RB ) var(RC ) ⎛ ⎞ 2 σ σ σ ⎜ A AB AC ⎟ ⎜ ⎟ = ⎜ σ AB σ 2 σ BC ⎟ = Σ.0100 0.1 we have ⎞ ⎞ ⎛ ⎛ 0.4CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA simply the joint distribution of the elements of R. B ⎝ ⎠ 2 σ AC σ BC σ C Notice that the covariance matrix is symmetric (elements oﬀ the diagonal are equal so that Σ = Σ0 . cov(RA .0018 0. ⎠ ⎠ ⎝ ⎝ 0. ⎣⎝ ⎠⎦ ⎝ ⎠ ⎠ ⎝ E[RC ] RC μC and the 3 × 3 covariance matrix of returns is ⎛ ⎞ var(RA ) cov(RA . RA ) cov(RC . RC ) ⎟ ⎝ ⎠ cov(RC . RA ).0026 0.0011 ⎟ ⎜ ⎟ ⎜ Σ = ⎜ 0.0199 . where Σ0 denotes the transpose of Σ) since cov(RA . RA ) and cov(RB .0018 0.

xB .0026 0.c("MSFT".0018. ⎝ ⎠ μC σ AB σ AC ⎜ ⎜ = var(x0 R) = x0 Σx = (xA . 0. these values are created using > > > > + + + > > asset.0199).1 PORTFOLIOS WITH THREE RISKY ASSETS In R.names.mat = matrix(c(0.0199 ¥ The return on the portfolio using matrix notation is ⎛ ⎞ R ⎜ A⎟ ⎜ ⎟ Rp.names sigma. the expected return on the portfolio is ⎛ μp.0015 0.0018 0. nrow=3.0427 0. "SBUX") mu.0011 NORD 0. 0. xC ) · ⎜ RB ⎟ = xA RA + xB RB + xC RC .0109 0.0427. 0.0011.0100. 0.mat) = list(asset. 0. ncol=3) dimnames(sigma.0018 0. "NORD".vec MSFT NORD SBUX 0.0015.0018. xC )·⎜ μB ⎟ = xA μA +xB μB +xC μC . 0. 0.x = x0 R = (xA . 0.0285 > sigma. 0.0011. asset.names <.vec = c(0.x The variance of the portfolio is μ ⎜ A⎟ ⎜ ⎟ = E[x0 R] = x0 E[R] = x0 μ = (xA . xB .x = x2 σ 2 + x2 σ 2 + x2 σ 2 + 2xA xB σ AB + 2xA xC σ AC + 2xB xC σ BC .mat MSFT NORD SBUX MSFT 0.names) mu.0285) names(mu. xB .0026. xC ) · ⎜ σ AB σ 2 σ BC B ⎝ σ AC σ BC σ 2 C ⎛ σ2 A ⎞⎛ x ⎟⎜ A ⎟ ⎟⎜ ⎟ ⎟ ⎜ xB ⎟ ⎠⎝ ⎠ xC ⎞ ⎞ σ2 p.0011 0. 0.0109. ⎝ ⎠ RC 5 Similarly. A A B B C C .vec) = asset.0026 SBUX 0.0100 0.0026.1.

xB . yB .x [. yC )0 .y = y0 R = yA RA + yB RB + yC RC .vec. Using matrix algebra.1] .vec sig.y ) = cov(x0 R. The return on this portfolio is Rp.x = crossprod(x.x . Consider another portfolio with weights y = (yA .vec)%*%sigma. 1/3)0 .p. 1/3.3)/3 names(x. ⎝ ⎠ 1 where 1 is a 3 × 1 vector with each element equal to 1. xB . Rp. cov(Rp. xC ) · ⎜ 1 ⎟ = xA + xB + xC = 1. Rp. the portfolio mean and variance are > > > > > > x.p.mat%*%x.names mu.p.x = x0 R where x = (1/3. this covariance can be computed as σ xy = cov(Rp.x = t(x.mu. Later on we will need to compute the covariance between the return on portfolio x and the return on portfolio y.vec = rep(1.p.y ). Using R. y0 R) ⎛ σ2 σ σ ⎜ A AB AC ⎜ = x0 Σy = (xA .x = sqrt(sig2. ⎟⎜ ⎟⎜ ⎟ ⎜ yB ⎠⎝ yC yA Example 3 Portfolio computations in R Consider an equally weighted portfolio with xA = xB = xC = 1/3. This portfolio has return Rp.6CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA The condition that the portfolio weights sum to one can be expressed as ⎛ ⎞ 1 ⎜ ⎟ ⎜ ⎟ x0 1 = (xA .x) mu. xC ) · ⎜ σ AB σ 2 σ BC B ⎝ σ AC σ BC σ 2 C ⎞⎛ ⎞ ⎟ ⎟ ⎟ ⎠ = xA yA σ 2 + xB yB σ 2 + xC yC σ 2 A B C +(xA yB + xB yA )σ AB + (xA yC + xC yA )σ AC + (xB yC + xC yB )σ AC .vec) sig2.p.x .vec) = asset.

1.m A A B B C C (1. ∂λ 0 = (1.y is 1. −0.mB .4) +2mA mB σ AB + 2mA mC σ AC + 2mB mC σ BC s.8. mC )0 for the three asset case solves the constrained minimization problem mA .4. The Lagrangian for this problem is L(mA .02423 > sig. mB . yC )0 = (0.1] [1. mA + mB + mC = 1. consider another portfolio with weight vector y = (yA .] 0.t.mC min σ 2 = m2 σ 2 + m2 σ 2 + m2 σ 2 p.1.] 0.2)0 and return Rp.x [. 0 = C ∂mA ∂L 0 = = mA + mB + mC − 1.vec) = asset.mat%*%y.xy [. The covariance between Rp.y = y0 R.vec)%*%sigma. mB .07587 7 > > > > y.vec sig. mC .4.1] [1.2 Finding the Global Minimum Variance Portfolio The global minimum variance portfolio m = (mA .xy = t(x. yB .] 0.p. -0.vec = c(0. 0.1 PORTFOLIOS WITH THREE RISKY ASSETS [1. A ∂mA ∂L 0 = = 2mB σ 2 + 2mA σ AB + 2mC σ BC + λ. and the ﬁrst order conditions (FOCs) for a minimum are ∂L = 2mA σ 2 + 2mB σ AB + 2mC σ AB + λ.2) names(x. λ) = m2 σ 2 + m2 σ 2 + m2 σ 2 A A B B C C +2mA mB σ AB + 2mA mC σ AC + 2mB mC σ BC +λ(mA + mB + mC − 1).8.5) .names sig. B ∂mA ∂L = 2mC σ 2 + 2mA σ AC + 2mB σ BC + λ.x and Rp. 0.003907 ¥ Next.

⎛ ⎝ 2Σ 1 1 0 0 the ﬁrst order conditions (1. Using matrix notation.7) ⎞⎛ ⎠⎝ The system (1.m = m0 μ and variance σ 2 = m0 Σm. the problem (1.t.5) has the ⎛ ⎞ m 0 1 ⎟⎜ A ⎟ ⎜ ⎟ ⎟⎜ ⎟ ⎜ ⎟ 1 ⎟ ⎜ mB ⎟ ⎜ 0 ⎟ ⎟⎜ ⎟ = ⎜ ⎟. mC )0 for the global minimum variance portfolio with expected return μp. zm = ⎝ ⎛ m λ ⎞ ⎠ and b = ⎝ ⎛ 0 1 ⎞ ⎠.6) The four linear equation describing matrix representation ⎛ 2σ 2 2σ AB 2σ AC A ⎜ ⎜ ⎜ 2σ AB 2σ 2 2σ BC B ⎜ ⎜ ⎜ 2σ AC 2σ BC 2σ 2 C ⎝ 1 1 1 or.m m (1.4) can be concisely expressed as min σ 2 = m0 Σm s. mB . (1. more concisely.8CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA The FOCs (1.8) as follows: . p.7) is of the form Am zm = b.8) zm = A−1 b. ⎟⎜ ⎟ ⎜ ⎟ 1 ⎟ ⎜ mC ⎟ ⎜ 0 ⎟ ⎠⎝ ⎠ ⎝ ⎠ 1 0 λ ⎞⎛ ⎞ m λ ⎞ ⎠=⎝ ⎛ 0 1 ⎞ ⎠. we can use R to compute the global minimum variance portfolio weights from (1. m The ﬁrst three elements of zm are the portfolio weights m = (mA .5) gives four linear equations in four unknowns which can be solved to ﬁnd the global minimum variance portfolio weights mA . mB and mC . where ⎛ 2Σ 1 1 0 0 The solution for zm is then Am = ⎝ ⎞ ⎠ . m0 1 = 1. p.m Example 4 Global minimum variance portfolio for example data Using the data in Table 1. (1.

0.m. the global minimum variance portfolio has portfolio weights mmsf t = 0.vec)%*%sigma.vec = c(rep(1.6) can be expressed in matrix notation as 0 0 ∂L(m.3656.vec) > sig. mu.5) from the optimization problem (1.gmin = sqrt(sig2. are p.vec)) > mu.4411 0. 3). The expected return on this portfolio.4411.mat = solve(Am.m = m0 μ.mat = rbind(top.10) (1.11) (1.gmin = as.m[1:3. σ 2 = m0 Σm.gmin = as. and is given by the vector m = (0.gmin [1] 0.m .mat.1933)0 .vec MSFT NORD SBUX 0. 0.4411.9) (3×1) (1×1) .02489 The portfolio variance. 1) z. bot) b.1.vec. 3)) bot.¥ Alternative derivation of global minimum variance portfolio The ﬁrst order conditions (1. 3).numeric(crossprod(m.vec m.1 PORTFOLIOS WITH THREE RISKY ASSETS > > > > > > > top. ∂λ = (1.gmin [1] 0. is > mu.gmin [1] 0. μp. λ) = 2 · Σm+λ · 1.gmin) > sig2.3656 0. λ) = = m0 1 − 1. 0) Am.3656 and msbux = 0. σ p.mat)%*%b.1933 9 Hence.07268 In Figure 1.vec = c(rep(0.numeric(t(m. mnord = 0. ∂m ∂L(m. and standard deviation.1933.005282 > sig.1] m. rep(1. this portfolio is labeled “global min”.1.mat%*%m.mat = cbind(2*sigma.vec = z.m > sig2.

the investment opportunity set in (μp . As in the two risky asset case.vec = rep(1. this set can be described in a graph with μp on the vertical axis and σ p on the horizontal axis.mat = top. With three or more assets.mat/bot.mat = solve(sigma.12) Example 5 Finding global minimum variance portfolio for example data Using the data in Table 1.vec bot.11) to solve for λ: 1 1 = 10 m = − · λ10 Σ−1 1 2 1 ⇒ λ = −2 · 0 −1 . σ p )− space lies on a curve (one side of a hyperbola). and portfolio standard deviation.val = as.inv. σ p )− space is described by set of values whose general shape . we can use R to compute the global minimum variance portfolio weights from (1.val m.1] MSFT NORD SBUX 0. substitute the value for λ back into (1. ﬁrst solve for m : 1 m = − · λΣ−1 1.inv. values for all possible portfolios whose weights sum to one.10). 2 1Σ 1 1Σ 1 (1. 3) sigma.10) to solve for m: 1 1 Σ−1 1 m = − (−2) 0 −1 Σ−1 1 = 0 −1 . multiply both sides by 10 and use (1. 1Σ 1 Finally.vec)%*%sigma.inv. the investment opportunity set in (μp . σ p . μp .10CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA Using (1.12) as follows: > > > > > > one.1.mat) top.mat = sigma.3 Finding Eﬃcient Portfolios The investment opportunity set is the set of portfolio expected return.mat%*%one. With two assets.4411 0.mat%*%one.1933 ¥ 1.mat[.numeric((t(one. 2 Next.3656 0.vec)) m.

Markowitz characterized these eﬃcient portfolios in two equivalent ways.14) μp = x0 μ = μp. The eﬃcient portfolio frontier is a graph of μp versus σ p values for the set of eﬃcient portfolios generated by solving (1.x x (1. we do not have to fully characterize the entire investment opportunity set. p. Following Markowitz. Just as in the two asset case.0 Markowitz showed that the investor’s problem of maximizing portfolio expected return subject to a target level of risk has an equivalent dual representation in which the investor minimizes the risk of the portfolio (as measured by portfolio variance) subject to a target expected return level. These portfolios lie on the boundary of the investment opportunity set above the global minimum variance portfolio. the dual problem (1.t. to minimize risk subject to a target expected return. the . To ﬁnd eﬃcient portfolios of risky assets in practice.0 . p p.13) σ 2 = x0 Σx = σ 2 and x0 1 = 1. Then the dual problem is the constrained minimization problem min σ 2 = x0 Σx s.14) for all possible target expected return levels μp. However. equivalently. Let μp.14) is most often solved. This is partially due to computational conveniences and partly due to investors being more willing to specify target expected returns rather than target risk levels. and x0 1 = 1. This is the framework originally developed by Harry Markowitz. Let σ 2 denote a target level p.1 PORTFOLIOS WITH THREE RISKY ASSETS 11 is complicated and depends crucially on the covariance terms σ ij . we assume that investors wish to ﬁnd portfolios that have the best expected return-risk trade-oﬀ. Then Harry Markowitz characterized the constrained maximization problem to ﬁnd an eﬃcient portfolio as max μp = x0 μ s. If we assume that investors choose portfolios to maximize expected return subject to a target level of risk.0 above the expected return on the global minimum variance portfolio. then we can simplify the asset allocation problem by only concentrating on the set of eﬃcient portfolios. In the ﬁrst way. the father of portfolio theory and winner of the Nobel Prize in economics. x (1.0 denote a target expected return level.1. investors seek to ﬁnd portfolios that maximize portfolio expected return for a given level of risk as measured by portfolio variance.0 of risk. or.t.

λ2 ). λ2 ) = x0 1 − 1 = 0. ∂λ1 ∂L(x. xB .0 ) + λ2 (x0 1 − 1).14). ⎝ ⎝ ⎠ ⎝ ⎠ ⎠ 0 1 0 0 λ2 1 zx = A−1 b0 . xC . λ1 . λ1 . zx = ⎜ λ1 ⎟ and b0 = ⎜ μp. ∂x ∂L(x. where ⎜ ⎜ ⎟ ⎜ ⎟ ⎟ ⎜ ⎜ ⎟ ⎜ ⎟ ⎟ Ax = ⎜ μ0 0 0 ⎟ . λ1 . . λ2 ) = x0 μ − μp. λ2 ) = 2Σx + λ1 μ + λ2 1 = 0.12CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA resulting eﬃcient frontier will resemble one side of an hyperbola and is often called the “Markowitz bullet”.16) (1. The FOCs for a minimum are the linear equations ∂L(x.0 ⎟ . λ1 .0 = 0. We can represent the system of linear equations using matrix algebra as ⎛ ⎞⎛ ⎞ ⎛ ⎞ 0 x 2Σ μ 1 ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ 0 ⎟⎜ ⎟ ⎜ ⎟ = ⎜ μp.0 and x0 1 = 1) there are two Lagrange multipliers λ1 and λ2 . To solve the constrained minimization problem (1. x (1.x = μp. ⎜ μ 0 0 ⎟ ⎜ λ1 ⎟ ⎝ ⎠⎝ ⎠ ⎝ ⎠ 0 1 0 0 λ2 1 or Ax zx = b0 .17) These FOCs consist of ﬁve linear equations in ﬁve unknowns (xA . ﬁrst form the Lagrangian function L(x.0 .0 ⎟ . λ1 . xB . λ2 ) = x0 Σx + λ1 (x0 μ−μp.15) (1. xC )0 for the eﬃcient portfolio with expected return μp. Because there are two constraints (x0 μ = μp. ∂λ2 (1.18) ⎛ 2Σ μ 1 ⎞ ⎛ x ⎞ ⎛ 0 ⎞ The solution for zx is then The ﬁrst three elements of zx are the portfolio weights x = (xA .

vec = c(rep(1.1 PORTFOLIOS WITH THREE RISKY ASSETS 13 Example 6 Eﬃcient portfolio with the same expected return as Microsoft Using the data in Table 1.mat = cbind(2*sigma.26329)0 . 3). 3). and standard deviation. the eﬃcient portfolio with the same expected return as Microsoft has portfolio weights xmsf t = 0.numeric(crossprod(x.px) > sig2. That is. mid.vec)%*%sigma.mat)%*%bmsft. 3)) mid.1. 0.x = x0 μ.px = as. μp.vec) > sig.0084 > sig.18). and is given by the vector x = (0.px [1] 0.mat = rbind(top. xnord = −0.09075. bot.vec)) > mu.0427 The portfolio variance. 0) Ax.vec x.82745.26329 Hence.0 = μmsf t = 0.mat%*%x. Next.vec = c(mu.82745. 0. 0.px [1] 0.82745 -0. are p.vec = c(rep(0.vec["MSFT"]. consider ﬁnding an eﬃcient portfolio with the same expected return as Microsoft.vec MSFT NORD SBUX 0. 0) bot.26329.vec = z.09166 and are smaller than the corresponding values for Microsoft (see Table 1).19) The expected return on this portfolio. mu.1. rep(1. consider solving (1.0427 using (1.x > sig2.px [1] 0.px = sqrt(sig2.mat = solve(Ax. σ p. This eﬃcient portfolio is labeled “E1” in Figure 1. consider ﬁnding an eﬃcient portfolio with the same expected return as Starbucks: .mat[1:3.mat.mat.vec.px = as.] x. is equal to the target return μmsf t : > mu. (1.14) with target expected return μp. σ 2 = x0 Σx.x .vec) bmsft. mu.vec. 1) z. −0.numeric(t(x.09075 and xsbux = 0. The R calculations are > > > > > > > > top. mu.09075 0.vec.vec.

vec["SBUX"].py [1] 0.2732.px*sig.vec) > sig.2732 and ysbux = 0. 2 2 (1.14).py = as.vec)%*%sigma.py) > sigma.xy = sigma.vec.21) (1.xy = as.xy [1] 0.mat%*%y.005914 > rho. use (1.py [1] 0.15) to solve for x: x= −1 −1 λ1 Σ−1 μ + λ1 Σ−1 1. 0.8772 ¥ Alternative derivation of eﬃcient portfolio Consider the ﬁrst order conditions (1.y = y0 R are given by > sigma.vec = z.1.2732 0. mu.vec) > rho. The portfolio expected return and standard deviation are: > mu.20) . 1) z.py = as. mu.numeric(t(y.py = sqrt(sig2.07355 This eﬃcient portfolio is labeled “E2” in Figure 1.xy/(sig.] y.2075 This eﬃcient portfolio has weights ymsf t = 0.5194.vec = c(rep(0.vec)) > sig2.14CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA > > > > bsbux.xy [1] 0.vec)%*%sigma.vec y.mat%*%y.numeric(crossprod(y.2075)0 .vec MSFT NORD SBUX 0. ynord = 0.5194 0.15)-(1.0285 > sig.mat = solve(Ax.numeric(t(x.py) > mu. First.2075 and is given by the vector y = (0. 3).5194. The covariance and correlation values between the portfolio returns Rp.mat[1:3. 0.mat)%*%bsbux.17) from the optimization problem (1.x = 0 x R and Rp.

2 2 Similarly.21) by 10 and use (1. The solution for (λ1 . 2 2 Now. 2 AC − B AC − B 2 Substituting these values back into (1. 2 AC − B −B A ⎛ ⎞ = we have −2 −2 (Cμ0 − B) .1.17) to give 1 = 10 x = −1 −1 λ1 10 Σ−1 μ + λ1 10 Σ−1 1. pre-multiply (1. λ2 )0 is ⎛ ⎞−1 ⎛ ⎞ ⎛ ⎞ A B μ λ ⎠ ⎝ 0 ⎠.21) by μ0 and use (1. pre-multiply (1.21) gives an explicit expression for the eﬃcient portfolio weight vector x: x= Cμ0 − B −1 A − Bμ0 −1 Σ μ+ Σ 1. 2 AC − B AC − B 2 .16) to give μ0 = μ0 x = −1 −1 λ1 μ0 Σ−1 μ + λ1 μ0 Σ−1 1. = 2 λ2 1 B C where A = μ0 Σ−1 μ. to ﬁnd the values for λ1 and λ2 . ⎝ 1 ⎠ = −2 ⎝ λ2 B C 1 Using ⎛ ⎝ λ1 = A B B C ⎞−1 ⎠ C −B 1 ⎝ ⎠. we have two linear equations involving λ1 and λ2 which we can write in matrix notation as ⎛ ⎞⎛ ⎞ ⎛ ⎞ −1 ⎝ A B ⎠ ⎝ λ1 ⎠ ⎝ μ0 ⎠ . λ1 = (A − Bμ0 ) .1 PORTFOLIOS WITH THREE RISKY ASSETS 15 Next. B = μ0 Σ−1 1 and C = 10 Σ−1 1.

24) μp. to compute the portfolio frontier in (μp .4 Computing the Eﬃcient Frontier The expression for an eﬃcient portfolio derived in the previous sub-section showed that any eﬃcient portfolio can be created as a convex combination of any two eﬃcient portfolios with diﬀerent target expected returns. Otherwise.1 . As a result.y . Proposition 7 Creating a frontier portfolio from two eﬃcient portfolios Let x = (xA . portfolio x solves min σ 2 = x0 Σx s.z p. yC )0 be any two eﬃcient portfolios with diﬀerent target expected returns x0 μ = μp. Then the portfolio z = α · x + (1 − α) · y ⎛ αx + (1 − α)yA ⎜ A ⎜ = ⎜ αxB + (1 − α)yB ⎝ αxC + (1 − α)yC ⎞ (1.16CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA 1.t.0 6= y0 μ = μp.x x and portfolio y solves min σ 2 = y0 Σy s.x p. p.t. xB . σ 2 = z0 Σz = α2 σ 2 + (1 − α)2 σ 2 + 2α(1 − α)σxy . The following proposition describes the process for the three risky asset case using matrix algebra. ⎠ (1. the portfolio is an ineﬃcient frontier portfolio. xC )0 and y = (yA .y0 μ = μp. p. p.22) is a frontier portfolio with ⎟ ⎟ ⎟. x0 μ = μp. That is. σ p ) space (Markowitz bullet) we only need to ﬁnd two eﬃcient portfolios.1.x + (1 − α) · μp.0 and x0 1 = 1.y y Let α be any constant. The remaining frontier portfolios can then be expressed as convex combinations of these two portfolios.1 andy0 1 = 1. yB . then the portfolio is an eﬃcient frontier portfolio. If the expected return on the resulting portfolio is greater than the expected on the global minimum variance portfolio.y .23) (1.z = z0 μ = α · μp.

vec MSFT NORD SBUX 0.5)(0.2732 ⎟ ⎠ ⎝ ⎠ ⎝ 0. p. the expected return. Otherwise.x p.5)(0.09075) ⎟ + ⎜ (0.m is the expected return on the global minimum variance portfolio.19) and (1. ⎝ ⎠ ⎝ ⎠ 0.vec + (1-a)*y.5194) ⎜ ⎟ ⎟ ⎜ ⎜ ⎟ ⎟ ⎜ = ⎜ (0. variance and standard p. z is an ineﬃcient frontier portfolio. From (1.5 > z.z deviation of this portfolio are .26329 ⎛ ⎞ ⎞ ⎛ (0.0912 ⎟ = ⎜ zB ⎟ . the new frontier portfolio is computed using > a = 0.vec > z.5)(−0.5)(0.5)(0.5 · ⎜ −0.09075 ⎟ + 0.6734 ⎜ ⎟ ⎜ A⎟ ⎜ ⎟ ⎜ ⎟ = ⎜ 0.1 PORTFOLIOS WITH THREE RISKY ASSETS where σ 2 = x0 Σx.m .1.2354 zC In R.vec = a*x. σ 2 = y0 Σy.5 · ⎜ 0.22).2075 0.82745) (0. Example 8 Creating an arbitrary frontier portfolio from two eﬃcient portfolios Consider the data in Table 1 and the previously computed eﬃcient portfolios (1.2075) (0.5194 0.26329) ⎛ ⎞ ⎛ ⎞ z 0.2354 Using μp.20) and let α = 0.z = z0 μ and σ 2 = z0 Σz.5)(0. where μp.y 17 If μp. σ xy = x0 Σy.5.0912 0.z ≥ μp.6734 0.82745 ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ = 0.2732) ⎟ ⎝ ⎠ ⎠ ⎝ (0. the frontier portfolio z is constructed using z = α · x + (1 − α) · y ⎞ ⎛ ⎞ ⎛ 0. then portfolio z is an eﬃcient portfolio.

vec)%*%sigma. The three eﬃcient portfolios x.mat%*%z.vec) > sig. y and z are illustrated in Figure 1. respectively.xy = as.0356 > sig2.pz = a*mu.02489 the frontier portfolio z is an eﬃcient portfolio.pz = sqrt(sig2.pz = as.19) and (1.vec)) > sig2.pz = sqrt(sig2.y 2α(1 − α)σxy the expected return.numeric(t(z. mu. Then μp.pz) > mu.08006 Equivalently.numeric(t(x. using μp.pz [1] 0.vec)%*%sigma.pz [1] 0.z = 0.vec) > sig2.y = μnord = 0.pz [1] 0. “E2” and “E3”.pz) > mu.mat%*%y.py > sig.0356 > sig2.numeric(crossprod(z.x p.py + 2*a*(1-a)*sig. variance and standard deviation of this portfolio are > mu.pz = as.px + (1-a)*mu.00641 > sig.px + (1-a)^2 * sig2.x + (1 − α)μp.08006 Because μp.vec.00641 > sig.2 and are labeled “E1”.z p.xy > sig. .z = αμp.0015.m = 0.pz [1] 0.18CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA > mu.y and σ 2 = α2 σ 2 +(1−α)2 σ 2 + p.pz = a^2 * sig2.x +(1−α)μp. respectively.pz [1] 0.20) with target expected returns equal to the expected returns on Microsoft and Starbucks.pz [1] 0. consider creating a frontier portfolio with target expected return equal to the expected return on Nordstrom.z = αμp.¥ Example 9 Creating a frontier portfolio with a given expected return from two eﬃcient portfolios Given the two eﬃcient portfolios (1.0356 > μp.

pz.nord*mu.mu.px + (1-a.vec + (1 .0427 − 0.nord^2 * sig2.nord*(1-a.nord)*y. Nordstrom and Starbucks.1.01 0.0285 = −1.02 0.xy .10 σp 0.10128 The expected return.901. = μp.a.vec > z.py > sig2.nord = a.py) > z.nord = a.0015 − 0.20 Figure 1.nord*x.05 0.00 0.nord = (mu.nord = a.px + (1-a.2: Three eﬃcient portfolios of Microsoft.05 0. and we can solve for α using α= μnord − μp.0285 Using R. variance and standard deviation on this portfolio are > mu.y 0.nord)*sigma.py)/(mu.nord)*mu.pz.96509 0. the weights in this frontier portfolio are > a.03 μp E2 GLOBAL MIN SBUX 0.vec["NORD"] .1 PORTFOLIOS WITH THREE RISKY ASSETS 19 0.00 IE4 NORD 0.nord MSFT NORD SBUX -0.15 0.x − μp.y 0.nord)^2 * sig2.px .06 0.mu.py + + 2*a.04 E1 E3 MSFT 0.06637 0.

14) with μ0 = max{μ1 .x = x0 μ and σ 2 = x0 Σx. −0.23) and (1. Compute cov(Rp.4).m = m0 μ and σ 2 = m0 Σm. 5.0015 > sig2. compute the frontier portfolios z using (1. p.pz.m 3.pz.pz. and compute their expected returns and variances using (1. solve (1. can be conveniently created using (1.9.m 2. That is. Example 10 Compute and plot the eﬃcient frontier of risky assets (Markowitz bullet) To compute and plot the eﬃcient frontier from the three risky assets in Table 1. .1033 Because μp. .2.01066 > sig. Compute the global minimum variance portfolio m by solving (1. The second eﬃcient portfolio is the eﬃcient portfolio whose target expected return is equal to the highest expected return among all of the assets under consideration.z = 0. i. μ2 .6). (1.0015 < μp. p. those frontier portfolios with expected return greater than the expected return on the global minimum variance portfolio.02489 the frontier portfolio z is an ineﬃcient frontier portfolio. .nord NORD 0.e.20CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA > sig.22). . −1}.pz. The steps for constructing the eﬃcient frontier are: 1.¥ The eﬃcient frontier of portfolios.nord NORD 0.nord) > mu. μ3 }.z against σ p.nord = sqrt(sig2.22).z and adjust the grid of α values to create a nice plot.m .nord NORD 0.. The ﬁrst eﬃcient portfolio is the global minimum variance portfolio (1. and compute μp. 0.m = 0. 4. respectively.pz. Plot μp.x ) = σ mx = m0 Σx.22) with two speciﬁc eﬃcient portfolios.9. and compute μp. Compute the eﬃcient portfolio x by with target expected return equal to the maximum expected return of the assets under consideration.24). Create an initial grid of α values {1. This portfolio is labeled “IE4” in Figure 1. Rp.1 in R use .

type="b".z.10 0.gmin + (1-a[i])*mu.gmin. ylim=c(0.a = length(a) z. n.05 σp 0.a. n.z).03 μp 0.17). labels="Global min".00 0.vec for (i in 1:n. n. ] = a[i]*m + (1-a[i])*x. > > > > > > > + + + + + > + + > a = seq(from=1.z = rep(0. to=-1. mu. pos=4) .00 NORD 0. by=-0.1) n.vec mu.02 0.3: Eﬃcient frontier of three risky assets.05 0.gmin.mat[i.z = rep(0. ylab=expression(mu[p]).1.px + 2*a[i]*(1-a[i])*sig. 0. 3) mu.1 PORTFOLIOS WITH THREE RISKY ASSETS 21 0.mat%*%x.15 Figure 1. mu.04 MSFT SBUX GLOBAL MIN 0.px sig2.01 0.06 0. pch=16.mx = t(m)%*%sigma. xlim=c(0.mat = matrix(0. 0.mx } plot(sqrt(sig2. col="blue".gmin + (1-a[i])^2 * sig2. xlab=expression(sigma[p])) text(sig.a) sig.z[i] = a[i]*mu.06).a) sig2.a) { z.z[i] = a[i]^2 * sig2.

5 Eﬃcient Portfolios of Three Risky Assets and a Risk-Free Asset In the previous chapter. t0 1 = 1. it can be shown that the solution for t has a nice simple expression: t= Σ−1 (μ − rf · 1) .z contain the weights. ¥ 1. tnord . Computing the Tangency Portfolio The tangency portfolio is the portfolio of risky assets that has the highest Sharpe’s ratio. expected returns and variances. The tangency portfolio. we showed that eﬃcient portfolios of two risky assets and a single risk-free (T-Bill) asset are portfolios consisting of the highest Sharpe ratio portfolio (tangency portfolio) and the T-Bill. The resulting eﬃcient frontier is illustrated in Figure 1. With three or more risky assets and a T-Bill the same result holds. mu.t where μp.vec. denoted t = (tmsf t .names. σ p. tsbux )0 .3. of the eﬃcient frontier portfolios for a grid of α values between 1 and −1. the ﬁrst order conditions are 1 ∂L(t.vec. respectively. pos=4) The variables z.t = (t0 Σt) 2 . solves the constrained maximization problem max t t0 μ − rf (t0 Σt) 1 2 = 1 μp.t.25) . λ) = (t0 μ − rf ) (t0 Σt)− 2 + λ(t0 1 − 1) Using the chain rule. labels=asset.mat.z and sig2. The Lagrangian for this problem is L(t. mu.t − rf s. λ) = t0 1 − 1 = 0 ∂λ 1 After much tedious algebra.t = t0 μ and σ p.1. λ) = μ(t0 Σt)− 2 − (t0 μ − rf ) (t0 Σt)−3/2 Σt + λ1 = 0 ∂t ∂L(t. 10 Σ−1 (μ − rf · 1) (1.22CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA > text(sd.

m < rf .inv. which could occur when stock prices are falling and the economy is in a recession. is sold short is the tangency portfolio.0268 -0.vec MSFT NORD SBUX 1.vec.2994.t = t0 μ.rf = mu.t .3263 and tsbux = 0. which has the lowest mean return. then the tangency portfolio with have a negative Sharpe slope.inv.m > rf . tnord = −0.minus.3263 0.2994 The tangency portfolio has weights tmsf t = 1. −0.mat%*%mu.25) in R for the three risky asses in Table use > > > > > > > > rf = 0. μp.rf bot.vec .t [1] 0. To compute the tangency portfolio (1. In this case.mat = solve(sigma. is > mu.mat = sigma.rf*one.vec top. (1.vec)%*%top.26) Notice that Nordstrom.mat[.1.val = as. If μp.vec = rep(1. 3) mu.t .1]/bot.mat) one. are p.minus.mat) t.05189 The portfolio variance.m . and is given by the vector t = (1. and the sign of the Sharpe ratio.2994)0 . 0.numeric(crossprod(t.val t. σ 2 = t0 Σt. The expected return on the tangency portfolio. and standard deviation.vec = top. If μp. which is the usual case.numeric(t(one.005 sigma. depends on the relationship between the risk-free rate rf and the expected return on the global minimum variance portfolio μp. mu. σ p.0268.005.3263.t = as.0268.vec)) > mu. then the tangency portfolio with have a positive Sharpe ratio.1 PORTFOLIOS WITH THREE RISKY ASSETS 23 The location of the tangency portfolio. Example 11 Computing the tangency portfolio Suppose rf = 0. eﬃcient portfolios involve shorting the tangency portfolio and investing the proceeds in T-Bills.

t = (t0 Σt)1/2 are the expected return and standard deviation on the tangency portfolio.28) where xt represents the fraction of wealth invested in the tangency portfolio (1 − xt represents the fraction of wealth invested in T-Bills).1116 Because rf = 0. The expected return and standard deviation values of any such eﬃcient portfolio are given by μe = rf + xt (μp.005 < μp. The tangency portfolio can be considered as a mutual fund of the risky assets. = σ p. where the shares of the assets in the mutual fund are determined by the tangency portfolio weights.005 = 0.numeric(t(t.02489 the tangency portfolio has a positive Sharpe’s ratio/slope given by SRt = ¥ Alternative Derivation of the Tangency Portfolio To be completed μp.vec) > sig.t = sqrt(sig2.6 Mutual Fund Separation Theorem Again When there is a risk-free asset (T-bill) available.27) (1.4202. respectively.24CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA > sig2.1. p (1.t [1] 0.05189 − 0.1116 1. .t) > sig2.t .t [1] 0. and the T-bill can be considered as a mutual fund of risk-free assets.mat%*%t.01245 > sig. the eﬃcient frontier of T-bills and risky assets consists of portfolios of T-bills and the tangency portfolio.t 0.m = 0. this result is known as the mutual fund separation theorem.t = as. Recall.vec)%*%sigma.t − rf ). and μp. p σ e = xt σ p. The expected return-risk trade-oﬀ of these portfolios is given by the line connecting the risk-free rate to the tangency point on the eﬃcient frontier of risky asset only portfolios.t − rf 0.t = t0 μ and σ p.

2994 The eﬃcient portfolios of T-Bills and the tangency portfolio is illustrated in Figure .02/sig.1 with rf = 0. suppose the volatility target is σ e = 0. For example.02 = 0.t. then she will prefer a portfolio with a high expected return regardless of volatility.t.005.1.1792 > 1-x. We want to compute an eﬃcient portfolio that would be preferred by a highly risk averse investor.3263 > mu.28) and solving for xt .t. If the investor can tolerate a large amount of volatility.t [1] 0. A highly risk averse investor might have a low volatility (risk) target for his eﬃcient portfolio.1116 SBUX 0.t > x. This portfolio may involve borrowing at the risk-free rate (leveraging) and investing the proceeds in the tangency portfolio to achieve a high expected return. This portfolio is > t. Using (1.0268 -0.t [1] 0.02 or 2%.1 PORTFOLIOS WITH THREE RISKY ASSETS 25 Which combination of the tangency portfolio and the T-bill an investor will choose depends on the investor’s risk preferences. the p weights in the tangency portfolio and the T-Bill are > x.vec MSFT NORD 1. then she will choose a combination with very little weight in the tangency portfolio and a lot of weight in the T-bill. If the investor is very risk averse and prefers portfolios with very low volatility.02 [1] 0. Example 12 Eﬃcient portfolios of three risky assets and T-bills chosen by risk averse and risk tolerant investors Consider the tangency portfolio computed from the example data in Table 1.8208 . and a portfolio that would be preferred by a highly risk tolerant investor.02 [1] 0. This will produce a portfolio with an expected return close to the risk-free rate and a variance that is close to zero.05189 > sig.

18405 -0.t + (1-x.t.02*sig.386 > 1-x.07*sig.t.02 [1] 0.27) and solving for the xt .07*mu.rf) > x.t > mu.t.07)*rf > sig.t .t.01340 > sig.07 = x.4234 -0.02)*rf > sig.t.vec MSFT NORD 0.02 These values are illustrated in Figure as the portfolio labeled “E1”.07 = (0.rf)/(mu. A highly risk tolerant investor might have a high expected return target for his eﬃcient portfolio.26CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA In this eﬃcient portfolio.07 [1] 1.02*t.02 [1] 0.07 or 7%.02 = x.t.t.05367 The expected return and volatility values of this portfolio are > mu.07*t. the weights in the risky assets are proportional to the weights in the tangency portfolio > x.t.02 = x.t.t + (1-x.t.05848 SBUX 0.t > mu.t. the weights in the risky assets are > x.t. Using (1. the weights in the p tangency portfolio and the T-Bill are > x.t.vec MSFT NORD 1.02*mu. In this eﬃcient portfolio.3862 Notice that this portfolio involves borrowing at the T-Bill rate (leveraging) and investing the proceeds in the tangency portfolio.07 = x.4523 SBUX 0.t.07 .t.4151 The expected return and volatility values of this portfolio are > mu.t.t.t.07 [1] -0. suppose the expected return target is μe = 0. For example.07 .

t.47% volatility.04 μp SBUX Global min 0. The portfolio labeled “E1” is chosen by a risk averse investor with a target volatility of 0.1.02 E1 0.07 [1] 0. the investor must tolerate a 15.10 0.2 PORTFOLIO ANALYSIS FUNCTIONS IN R 27 0.00 NORD 0.00 0.1547 In order to achieve the target expected return of 7%. [1] 0. ¥ 1.15 Figure 1.02.08 E2 0.05 σp 0.2 Portfolio Analysis Functions in R The script ﬁle portfolio.4: Eﬃcient portfolios of three risky assets.06 tangency MSFT 0. The portfolio “E2” is chosen by a risk tolerant investor with a target expected return of 0. These values are illustrated in Figure as the portfolio labeled “E2”.r contains a few R functions for computing Markowitz mean-variance eﬃcient portfolios allowing for short sales using matrix alge- .07.07 > sig.

0. asset.2: R functions for computing mean-variance eﬃcient portfolios bra computations2 .005 dimnames(covmat) <. For example.0018.3)/3 > equalWeight. and the eﬃcient frontier. 0. 0.c(0.0199).0018. Then the functions in the ﬁle will be available for your use.2.cov.portfolio compute minimum variance portfolio subject to target return tangency. 0.portfolio efficient.portfolio = getPortfolio(er=er.c("MSFT".asset.names. "NORD".portfolio compute global minimum variance portfolio efficient.r is located in C:\mydata run the command source(“C:/mydata/portfolio.r”) at the beginnin of your R session.0427. 0. nrow=3. 0.0011.names covmat <.28CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA Function getPortfolio Description create portfolio object globalMin. These functions are summarized in Table 1.names <. ncol=3) rk.weights=ew) To use the functions in this script ﬁle.1.0109.0015. To create an equally weighted portfolio use > ew = rep(1. 0.free <.mat=covmat.0026. "SBUX") er <. These functions allow for the easy computation of the global minimum variance portfolio. 0.frontier compute tangency portfolio compute eﬃcient frontier of risky assets Table 1.0026. We ﬁrst construct the input data: > > > > + + + > > asset.0100. 0.names) To specify a portfolio.0285) names(er) <.list(asset.0. you need an expected return vector and covariance matrix for the assets under consideration as well as a vector of portfolio weights. 0. load them into R with the source() function. the tangency portfolio. The following examples illustrate the use of the functions in Table 1. 2 . an eﬃcient portfolio with a given target expected return.2 using the example data in Table 1.0011. if portfolio.matrix(c(0.

2 PORTFOLIO ANALYSIS FUNCTIONS IN R > class(equalWeight.port) \$names [1] "call" "er" "sd" "weights" \$class [1] "portfolio" > gmin.1. covmat) > attributes(gmin.portfolio() > gmin.portfolio Call: getPortfolio(er = er.mat = covmat.3333 0.3333 0. The print() method gives > equalWeight.port Call: .port <.portfolio(er.3333 0.t. weights = ew) Portfolio expected return: Portfolio standard deviation: Portfolio weights: MSFT NORD SBUX 0.02423333 0.portfolio) The global minimum variance portfolio (allowing for short sales) m solves the optimization problem min m0 Σm s.07586538 The plot() method shows a bar chart of the portfolio weights > plot(equalWeight. cov. m To compute this portfolio use the function globalMin.globalMin. m0 1 = 1.portfolio) [1] "call" "er" "sd" "weights" 29 There are print().portfolio) [1] "portfolio" Portfolio objects have the following components > names(equalWeight. summary() and plot() methods for portfolio objects.

x0 1 = 1 and x0 μ = μ0 .5: globalMin. target.10 0.07267607 Portfolio weights: MSFT NORD SBUX 0.return <.return) > e.portfolio() function > target.4411 0.t.05 0.er[1] > e.port.msft <.25 0.mat = covmat) Portfolio expected return: 0. cov.portfolio(er = er.1933 A mean-variance eﬃcient portfolio x that achieves the target expected return μ0 solves the optimization problem min x0 Σx s.3656 0.msft .02489184 Portfolio standard deviation: 0.portfolio(er. covmat.30 MSFT NORD Assets SBUX Figure 1.20 0.efficient.00 0.04275 use the efficient.15 0. x To compute this portfolio for the target expected return μ0 = E[Rmsf t ] = 0.port.30CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA Portfolio Weights Weight 0.

respectively.2 PORTFOLIO ANALYSIS FUNCTIONS IN R Call: efficient.0907 0. rk.free) Portfolio expected return: Portfolio standard deviation: Portfolio weights: MSFT NORD SBUX 1.1. To compute this portfolio with rf = 0.mat = covmat.return = target.portfolio(er. to compute 20 eﬃcient portfolios for values of α between −2 and 1.port Call: tangency.port <.t.3263 0.2633 0.free) > tan.mat = covmat.05188967 0. cov. For any number α. another eﬃcient portfolio can be computed as z = αm + (1 − α)x The function efficient.1115816 The the set of eﬃcient portfolios of risky assets can be computed as a convex combination of any two eﬃcient portfolios.portfolio(er = er.portfolio() function > tan. For example. It is convenient to use the global minimum variance portfolio as one portfolio and an eﬃcient portfolio with target expected return equal to the maximum expected return of the assets under consideration as the other portfolio.0427 0.091656 31 The tangency portfolio t is the portfolio of risky assets with the highest Sharpe’s slope and solves the optimization problem max t t0 μ − rf s. risk. Call these portfolios m and x.portfolio(er = er.5 use .tangency. covmat.free = rk.frontier() constructs the set of eﬃcient portfolios using this method for a collection of α values.005 use the tangency. t0 1 = 1.0268 -0. (t0 Σt)1/2 where rf denotes the risk-free rate. cov.8275 -0.return) Portfolio expected return: Portfolio standard deviation: Portfolio weights: MSFT NORD SBUX 0. target.2994 0.

0750 0.free)/tan. plot.6.039 0.assets=T) points(gmin. col="red") sr.port\$er .0730 0.1732 0.0727 0.0225 0.0748 0. nport=20) > attributes(ef) \$names [1] "call" "er" "sd" "weights" \$class [1] "Markowitz" > ef Call: efficient.tan) The resulting plot is shown in Figure 1.rk.0291 0.port\$sd abline(a=rk.0739 0. tan.5.0488 0.port\$sd.0652 0.1826 0. cov. .0357 SD 0. covmat.1548 0.tan = (tan. To create a plot of the eﬃcient frontier showing the original assets and the tangency portfolio use > > > > > plot(ef.0685 0.0554 0.1200 0.32CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA > ef <.port\$sd.0783 0.0908 0. nport = 20.port\$er. col="blue") points(tan.085 0.0455 0.0521 0.0258 0.0973 0. alpha. alpha.7.5) Frontier portfolios’ expected returns and standard deviations port 1 port 2 port 3 port 4 port 5 port 6 port 7 ER 0.efficient.0422 0.1120 0.min = -2.0324 0.0193 0. b=sr.0779 Use the summary() method to show the weights of these portfolios.1640 0.frontier(er.free.mat = covmat.0718 0.max=1.0160 SD 0.1370 0.0764 0.min=-2.0802 port 15 port 16 port 17 port 18 port 19 port 20 ER 0.max = 1. gmin. + alpha.0619 0.1458 0.port\$er.frontier(er = er. alpha.0586 SD 0.1284 port 8 port 9 port 10 port 11 port 12 port 13 port 14 ER 0.1044 0. Use the plot() method to plot the eﬃcient frontier > plot(ef) The resulting plot is shown in Figure 1.

08 Portfolio ER 0.04 0.1.15 Figure 1.3 REFERENCES 33 Efficient Frontier 0. 1.6: Plot method for Markowitz object.00 0.05 0.3 References .00 0.06 0.02 0.10 Portfolio SD 0.

7: Eﬃcient frontier for three ﬁrm example. .10 Portfolio SD 0.34CHAPTER 1 PORTFOLIO THEORY WITH MATRIX ALGEBRA Efficient Frontier 0.05 0.15 Figure 1.08 Portfolio ER 0.02 0.04 MSFT SBUX 0.06 0.00 0.00 NORD 0.