Successfully reported this slideshow.
Upcoming SlideShare
×

# Slides portfolio-2017-2

10,450 views

Published on

Optimal Portfolio, Crash Couse, #1

Published in: Economy & Finance
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### Slides portfolio-2017-2

1. 1. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Portfolio Optimization # 1 A. Charpentier (Université de Rennes 1) Université de Rennes 1, 2017/2018 @freakonometrics freakonometrics freakonometrics.hypotheses.org 1
2. 2. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Markowitz (1952) & Theoretical Approach Following Markowitz (1952), consider n assets, inﬁnitely divisible. Their returns are random variables, denoted X, (jointly) normaly distributed, N(µ, Σ), i.e. E[X] = µ and var(X) = Σ. Let ω denotes weights of a given portfolio. Portfolio risk is measured by its variance var(αT X) = σ2 α = αT Σα For minimal variance portfolios, with a given portfolio return, ¯r, the optimization problem can be stated as α = argmin αT Σα s.t.    E(αT X) = αT µ = ¯r αT 1 = 1 Allocation α is said to be eﬃcient if it is not possible to ﬁnd another one, with the same expected return, and a strictly lower variance, or dually, to ﬁnd another one with the same variance, and a strictly higher expected return. @freakonometrics freakonometrics freakonometrics.hypotheses.org 2
3. 3. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Markowitz (1952) & Theoretical Approach Recall that to solve a program α∗ = argmin f(α) s.t. g1(α), · · · , gp(α) ≥ 0, where g1, · · · , gp are p continuously diﬀerentiable functions, a necessary and suﬃcient condition for α∗ to be a solution is that (α∗ , λ) is solution of the n + p ﬁrst order conditions ∂ ∂αi (f(α) + λ1g1(α) + · · · + λpgp(α)) = 0 for i = 1, 2, ..., n, ∂ ∂λj (f(α) + λ1g1(α) + · · · + λpgp(α)) = 0 for j = 1, 2, ..., p. Constants λ = (λ1, · · · , λp) are Lagrange multipliers, and function α → f(α) + λ1g1(α) + · · · + λpgp(α) is the Lagrangien associated with the optimization program. @freakonometrics freakonometrics freakonometrics.hypotheses.org 3
4. 4. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Markowitz (1952) & Theoretical Approach Here we want to minimize var(αX), i.e. αT Σα (a quadratic function) with two (linear) constraints. We want to solve ∂ ∂αi α Σα + λ1(αT I − 1) + λ2(αT µ − ¯r) = 0 for i = 1, 2, · · · , n, ∂ ∂λj α Σα + λ1(αT I − 1) + λ2(αT µ − ¯r) = 0 for j = 1, 2. Observe that ∂ ∂α αT Σα = 2Σα and ∂ ∂α µT α = µ, so that α∗ has to be α∗ = λ1Σ−1 I + λ2Σ−1 µ, where Lagrange multipliers are given by    λ1IT Σ−1 µ + λ2IT Σ−1 I = 1 λ1µT Σ−1 µ + λ2µT Σ−1 I = ¯r , @freakonometrics freakonometrics freakonometrics.hypotheses.org 4
5. 5. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Markowitz (1952) & Theoretical Approach Set a = IT Σ−1 µ, b = µT Σ−1 µ and c = IT Σ−1 I, we can write the last system    λ1a + λ2c = 1 λ1c + λ2a = ε , Set d = bc − a2 , so that λ1 = cε − a d and λ2 = b − aε d . From that expression of Lagrange multipliers, use the ﬁrst order conditions to express Σα = λ1R + λ2I and the optimal variance of the portfolio is σ2 ∗ = αT Σα = λ1ε + λ2, @freakonometrics freakonometrics freakonometrics.hypotheses.org 5
6. 6. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Markowitz (1952) & Theoretical Approach Hence, without any risk-free asset, the eﬃcient frontier in the mean-variance problem is a parabolic function σ2 ∗ = cε2 − 2aε + b d where ε is the expected return of the portfolio. Further, we have optimal weights α∗ = Σ−1 (λ1X + λ2I) , which is a linear expression. @freakonometrics freakonometrics freakonometrics.hypotheses.org 6
7. 7. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects Consider the following three assets, as in Zivot (2013) 1 > asset.names <- c("MSFT", "NORD", "SBUX") 2 > mu.vec = c(0.0427 , 0.0015 , 0.0285) 3 > names(mu.vec) = asset.names 4 > sigma.mat = matrix(c(0.0100 , 0.0018 , 0.0011 ,0.0018 , 0.0109 , 0.0026 ,0.0011 , 0.0026 , 0.0199) ,nrow=3, ncol =3) 5 > dimnames(sigma.mat) = list(asset.names , asset.names) 6 > mu.vec 7 MSFT NORD SBUX 8 0.0427 0.0015 0.0285 9 > sigma.mat 10 MSFT NORD SBUX 11 MSFT 0.0100 0.0018 0.0011 12 NORD 0.0018 0.0109 0.0026 13 SBUX 0.0011 0.0026 0.0199 @freakonometrics freakonometrics freakonometrics.hypotheses.org 7
8. 8. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects Here are the three assets in the (σ, µ)-plane (with possibly much more) @freakonometrics freakonometrics freakonometrics.hypotheses.org 8
9. 9. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects Return and variance of a given portfolio are given by 1 > x.vec = rep (1 ,3)/3 2 > names(x.vec) = asset.names 3 > mu.p.x = crossprod(x.vec ,mu.vec) 4 > sig2.p.x = t(x.vec)%*%sigma.mat%*%x.vec 5 > sig.p.x = sqrt(sig2.p.x) 6 > mu.p.x 7 [,1] 8 [1,] 0.02423 9 > sig.p.x 10 [,1] 11 [1,] 0.07587 Global minimum variance portfolio is given by solving min{αT Σα} s.t. αT 1 = 1 @freakonometrics freakonometrics freakonometrics.hypotheses.org 9
10. 10. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 First order conditions on the Lagrangian yield   2Σ 1 1T 0   A   α λ   =   0 1   b @freakonometrics freakonometrics freakonometrics.hypotheses.org 10
11. 11. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects Here we have 1 > top.mat = cbind (2*sigma.mat , rep(1, 3)) 2 > bot.vec = c(rep(1, 3), 0) 3 > Am.mat = rbind(top.mat , bot.vec) 4 > b.vec = c(rep(0, 3), 1) 5 > z.m.mat = solve(Am.mat)%*%b.vec 6 > m.vec = z.m.mat [1:3 ,1] 7 > m.vec 8 MSFT NORD SBUX 9 0.4411 0.3656 0.1933 the portfolio return and standard deviation are 1 > mu.gmin = as.numeric(crossprod(m.vec , mu.vec)) 2 > mu.gmin 3 [1] 0.02489 4 > sig2.gmin = as.numeric(t(m.vec)%*%sigma.mat%*%m.vec) 5 > sig.gmin = sqrt(sig2.gmin) @freakonometrics freakonometrics freakonometrics.hypotheses.org 11
12. 12. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 6 > sig.gmin 7 [1] 0.07268 Another way to compute it is to go further on the analytical expression, and to derive α = Σ−1 1 1T Σ−1 1 1 > one.vec = rep(1, 3) 2 > sigma.inv.mat = solve(sigma.mat) 3 > top.mat = sigma.inv.mat%*%one.vec 4 > bot.val = as.numeric ((t(one.vec)%*%sigma.inv.mat%*%one.vec)) 5 > m.mat = top.mat/bot.val 6 > m.mat [,1] 7 MSFT NORD SBUX 8 0.4411 0.3656 0.1933 @freakonometrics freakonometrics freakonometrics.hypotheses.org 12
13. 13. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 @freakonometrics freakonometrics freakonometrics.hypotheses.org 13
14. 14. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Eﬃcient portfolios are obtained by solving min{αT Σα} s.t. αT µ = r0 and αT 1 = 1 First order conditions on the Lagrangian yield     2Σ µ 1 µT 0 0 1T 0 0     A     α λ1 λ2     =     0 r0 1     b If our target is to get the same return as Microsoft, say (MSFT), 1 > top.mat = cbind (2*sigma.mat , mu.vec , rep(1, 3)) 2 > mid.vec = c(mu.vec , 0, 0) 3 > bot.vec = c(rep(1, 3), 0, 0) 4 > A.mat = rbind(top.mat , mid.vec , bot.vec) 5 > bmsft.vec = c(rep(0, 3), mu.vec["MSFT"], 1) @freakonometrics freakonometrics freakonometrics.hypotheses.org 14
15. 15. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 6 > z.mat = solve(A.mat)%*%bmsft.vec 7 > x.vec = z.mat [1:3 ,] 8 > x.vec 9 MSFT NORD SBUX 10 0.82745 -0.09075 0.26329 the portfolio return and standard deviation are 1 > mu.px = as.numeric(crossprod(x.vec , mu.vec)) 2 > mu.px 3 [1] 0.0427 4 > sig2.px = as.numeric(t(x.vec)%*%sigma.mat%*%x.vec) 5 > sig.px = sqrt(sig2.px) 6 > sig.px 7 [1] 0.09166 If our target is to get the same return as Starbucks (SBUX), 1 > bsbux.vec = c(rep(0, 3), mu.vec["SBUX"], 1) 2 > z.mat = solve(Ax.mat)%*%bsbux.vec @freakonometrics freakonometrics freakonometrics.hypotheses.org 15
16. 16. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 3 > y.vec = z.mat [1:3 ,] 4 > y.vec 5 MSFT NORD SBUX 6 0.5194 0.2732 0.2075 with expected return and standard deviation 1 > mu.py = as.numeric(crossprod(y.vec , mu.vec)) 2 > sig2.py = as.numeric(t(y.vec)%*%sigma.mat%*%y.vec) 3 > sig.py = sqrt(sig2.py) 4 > mu.py 5 [1] 0.0285 6 > sig.py 7 [1] 0.07355 Observe that actually, those two portfolios are extremely correled 1 > sigma.xy = as.numeric(t(x.vec)%*%sigma.mat%*%y.vec) 2 > rho.xy = sigma.xy/(sig.px*sig.py) 3 > rho.xy @freakonometrics freakonometrics freakonometrics.hypotheses.org 16
17. 17. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 4 [1] 0.8772 Here again, one can go further on analytical expressions, α = − 1 2 λ1Σ−1 µ − 1 2 λ2Σ−1 1 = 1 2 Σ−1 Mλ where M = [µ, 1]. One can easily prove that λ = (λ1, λ2) is solution of − 1 2   µT Σ−1 µ µT Σ−1 1 1T Σ−1 µ 1T Σ−1 1   B λ =   r0 1   r0 thus, λ = −2B−1 r0, 1 > M.mat = cbind(mu.vec , one.vec) 2 > B.mat = t(M.mat)%*%solve(sigma.mat)%*%M.mat 3 > mu.tilde.msft = c(mu.vec["MSFT"], 1) @freakonometrics freakonometrics freakonometrics.hypotheses.org 17
18. 18. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 4 > x.vec .2 = solve(sigma.mat)%*%M.mat%*%solve(B.mat)%*%mu.tilde.msft 5 > x.vec .2 6 [,1] 7 MSFT 0.82745 8 NORD -0.09075 9 SBUX 0.26329 We can now compute the eﬃcient frontier. We have seen that any minimum variance portfolio can be created as a convex combination of any two minimum variance portfolios with diﬀerent target expected returns. Consider our two previous portfolio, x and y. Let α be a portfolio, expressed from x and y, α = αx + (1 − α)y 1 > a = 0.5 2 > z.vec = a*x.vec + (1-a)*y.vec 3 > z.vec 4 MSFT NORD SBUX @freakonometrics freakonometrics freakonometrics.hypotheses.org 18
19. 19. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 5 0.6734 0.0912 0.2354 with expected return and standard deviation 1 > mu.pz = as.numeric(crossprod(z.vec , mu.vec)) 2 > sig2.pz = as.numeric(t(z.vec)%*%sigma.mat%*%z.vec) 3 > sig.pz = sqrt(sig2.pz) 4 > mu.pz 5 [1] 0.0356 6 > sig.pz 7 [1] 0.08006 or equivalently 1 > mu.pz = a*mu.px + (1-a)*mu.py 2 > sig.xy = as.numeric(t(x.vec)%*%sigma.mat%*%y.vec) 3 > sig2.pz = a^2 * sig2.px + (1-a)^2 * sig2.py + 2*a*(1-a)*sig.xy 4 > sig.pz = sqrt(sig2.pz) 5 > mu.pz 6 [1] 0.0356 @freakonometrics freakonometrics freakonometrics.hypotheses.org 19
20. 20. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 7 > sig.pz 8 [1] 0.08006 If we have a given target expected return, we have to ﬁnd ﬁrst our appropriate weight α. For instance, if we want the same return as Nordstrom (NORD) 1 > a.nord = (mu.vec["NORD"] - mu.py)/(mu.px - mu.py) 2 > z.nord = a.nord*x.vec + (1 - a.nord)*y.vec 3 > z.nord 4 MSFT NORD SBUX 5 -0.06637 0.96509 0.10128 @freakonometrics freakonometrics freakonometrics.hypotheses.org 20
21. 21. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects Expected return and standard deviation are then 1 > mu.pz.nord = a.nord*mu.px + (1-a.nord)*mu.py 2 > sig2.pz.nord = a.nord ^2 * sig2.px + (1-a.nord)^2 * sig2.py + 2*a. nord*(1-a.nord)*sigma.xy 3 > sig.pz.nord = sqrt(sig2.pz.nord) 4 > mu.pz.nord 5 NORD 6 0.0015 7 > sig.pz.nord 8 NORD 9 0.1033 @freakonometrics freakonometrics freakonometrics.hypotheses.org 21
22. 22. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects @freakonometrics freakonometrics freakonometrics.hypotheses.org 22
23. 23. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects Now, to compute the eﬃcient frontier, consider a sequence of α’s 1 a = seq(from=1, to=-1, by = -0.1) 2 n.a = length(a) 3 z.mat = matrix (0, n.a, 3) 4 mu.z = rep(0, n.a) 5 sig2.z = rep(0, n.a) 6 sig.mx = t(m)%*%sigma.mat%*%x.vec 7 for (i in 1:n.a) { 8 z.mat[i, ] = a[i]*m + (1-a[i])*x.vec 9 mu.z[i] = a[i]*mu.gmin + (1-a[i])*mu.px 10 sig2.z[i] = a[i]^2 * sig2.gmin + (1-a[i])^2 * sig2.px + 2*a[i]*(1-a[i ])*sig.mx } 11 plot(sqrt(sig2.z), mu.z, type="b", ylim=c(0, 0.06) , xlim=c(0, 0.17) , pch =16, col="blue", ylab=expression (mu[p]), xlab=expression(sigma[ p])) 12 text(sig.gmin , mu.gmin , labels="Global min", pos =4) 13 text(sd.vec , mu.vec , labels=asset.names , pos =4) @freakonometrics freakonometrics freakonometrics.hypotheses.org 23
24. 24. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects @freakonometrics freakonometrics freakonometrics.hypotheses.org 24
25. 25. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects The weights, as a function of volatility, are the following 1 library( PerformanceAnalytics ) 2 chart.StackedBar(z.mat , xaxis.labels=sqrt(sig2.z)) @freakonometrics freakonometrics freakonometrics.hypotheses.org 25
26. 26. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Alternative Formulations The problem we did solve was, for a given target return ¯r α = argmin αT Σα s.t.    E(αT X) = αT µ = ¯r αT 1 = 1 Alternatively, for a given target variance ¯σ2 , solve α = argmax E(αT X) = αT µ s.t.    αT Σα = ¯σ2 αT 1 = 1 Or if λ > 0 denotes the Arrow-Pratt risk aversion coeﬃcient, solve α = argmax E[u(X)] = αT µ − λ 2 αT µ s.t. αT 1 = 1 Those three problems are equivalent. @freakonometrics freakonometrics freakonometrics.hypotheses.org 26
27. 27. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Interpretation of Markowitz optimal allocation Optimal portfolios can be expressed as linear combinations of expected returns, i.e. α∗ = p + εq, where p and q depend only on the variance-covariance matrix of returns p = 1 d (bΣ−1 1 − aΣ−1 µ) and q = 1 d (cΣ−1 µ − aΣ−1 1) p is actually a portfolio allocation since p I = 1, while q and be interpreted as changes with respect to allocation p (qT 1 = 0 and [p + q]T 1 = 1), see Merton (1972). We can also write α = (1 − ε)p + ε(p + q). Tobin (1958) and Sharpe (1964) extended Markowitz’s theory by introducting a risk-free asset. @freakonometrics freakonometrics freakonometrics.hypotheses.org 27
28. 28. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Allocation when there is a Risk-Free Asset With a risk-free asset, parabolic functions are degenerated. Let 0 be the index of that asset, so that X0 = r0, with E(X0) = r0 and var(X0) = 0. The investor can invest a share αT 1 in risky assets, and 1 − αT 1 in the risk-free asset. The return of the porfolio is random variable Rα = αT X + [1 − αT 1]r0. First moments are µα = αT µ + [1 − αT 1]r0 and σ2 α = αT Σα. Risk minimization yields the following optimization problem α = argmin αT Σα s.t. αT µ + [1 − αT 1]r0 = ¯r Here again, apply Lagrange multipliers method to this convex optimization problem L(α, λ1) = αT Σα + λ1[(¯r − r0)αT (µ − r01)] @freakonometrics freakonometrics freakonometrics.hypotheses.org 28
29. 29. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Allocation when there is a Risk-Free Asset Hence α = λ1Σ−1 (µ − r01) where λ1 = ¯r − r0 (µ − r01)TΣ−1 (µ − r01) Deﬁne the so-called Market Portfolio as follows: consider the fully-invested optimal portfolio αM with αT M 1 = 1 i.e. αM = λ1Σ−1 (µ − r01) where λ1 = 1 1T Σ−1 (µ − r01) @freakonometrics freakonometrics freakonometrics.hypotheses.org 29
30. 30. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Allocation when there is a Risk-Free Asset with expected return r0 + (µ − r01)T Σ−1 (µ − r01) 1T Σ−1 (µ − r01) and variance (µ − r01)T Σ−1 (µ − r01) (1T Σ−1 (µ − r01))2 Tobins Separation Theorem: Every optimal portfolio invests in a combination of the risk-free asset and the Market Portfolio, from Tobin (1958). Thus α invests in the same risky assets as the Market Portfolio and in the same proportions, the only diﬀerence is the total weight. The eﬃcient frontier of optimal portfolios as represented on the (σα, µα)-plane of return expectation (µα) vs standard-deviation (σα) for all portfolios. The portfolio expected return increases linearly with standard deviation, the so-called Capital Market Line. @freakonometrics freakonometrics freakonometrics.hypotheses.org 30
31. 31. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects Eﬃcient portfolios of risky assets and a single risk-free asset (Treasury Bill) are portfolios consisting of the highest Sharpe ratio portfolio (tangency portfolio) and the Treasury Bill. Thus, the ﬁrst step is to compute the tangency portfolio argmax αT µ − rf √ αTΣα s.t. αT 1 = 1 i.e. αt = Σ−1 (µ − rf 1) 1T Σ−1 (µ − rf 1) 1 > rf = 0.005 2 > sigma.inv.mat = solve(sigma.mat) 3 > one.vec = rep(1, 3) 4 > mu.minus.rf = mu.vec - rf*one.vec 5 > top.mat = sigma.inv.mat%*%mu.minus.rf @freakonometrics freakonometrics freakonometrics.hypotheses.org 31
32. 32. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 6 > bot.val = as.numeric(t(one.vec)%*%top.mat) 7 > t.vec = top.mat[,1]/bot.val 8 > t.vec 9 MSFT NORD SBUX 10 1.0268 -0.3263 0.2994 Expected return and standard deviation are here 1 > mu.t = as.numeric(crossprod(t.vec , mu.vec)) 2 > mu.t 3 [1] 0.05189 4 > sig2.t = as.numeric(t(t.vec)%*%sigma.mat%*%t.vec) 5 > sig.t = sqrt(sig2.t) 6 > sig.t 7 [1] 0.1116 @freakonometrics freakonometrics freakonometrics.hypotheses.org 32
33. 33. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects @freakonometrics freakonometrics freakonometrics.hypotheses.org 33
34. 34. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects An alternative representation is given from a standard minimum variance computation. Let µ = µ − rf 1 and consider some target excess return r0 = r0 − rf . Our problem is to solve min{αT Σα} s.t. αT µ = r0 One can prove that α = −λΣ−1 µ where λ = − r0 µT Σ−1 µ or α = r0Σ−1 µ µT Σ−1 µ and 1 − α T 1 is invested in the risk-free asset. We have seen that the tangency portfolio is @freakonometrics freakonometrics freakonometrics.hypotheses.org 34
35. 35. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 1 > t.vec 2 MSFT NORD SBUX 3 1.0268 -0.3263 0.2994 4 > mu.t 5 [1] 0.05189 6 > sig.t 7 [1] 0.1116 If our target is a portfolio with standard deviation 20%, use 1 > x.t.02 = 0.02/sig.t 2 > x.t.02 3 [1] 0.1792 4 > 1-x.t.02 5 [1] 0.8208 i.e. 82% on the risk-free asset, and 18% on the tangency portfolio. Expected return and standard deviation are here 1 > mu.t.02 = x.t.02*mu.t + (1-x.t.02)*rf @freakonometrics freakonometrics freakonometrics.hypotheses.org 35
36. 36. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 2 > sig.t.02 = x.t.02*sig.t 3 > mu.t.02 4 [1] 0.01340 5 > sig.t.02 6 [1] 0.02 If we want a 7% expected return 1 > x.t.07 = (0.07 - rf)/(mu.t - rf) 2 > x.t.07 3 [1] 1.386 4 > 1-x.t.07 5 [1] -0.3862 which involves borrowing at the Treasury Bill (leveraging) @freakonometrics freakonometrics freakonometrics.hypotheses.org 36
37. 37. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects Again, we can get weights in diﬀerents assets, @freakonometrics freakonometrics freakonometrics.hypotheses.org 37
38. 38. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects @freakonometrics freakonometrics freakonometrics.hypotheses.org 38
39. 39. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 CAPM and APT In this model (corresponding to the CAPM - Capital Asset Pricing Model), at equilibrium, only the systematic risk of the asset is valued by the market, and E(Xi) − r0 = [E(XM ) − r0] · βi, where XM = αT M X, where E(XM ) − r0 is the risk price, and [E(XM ) − r0] · βi is the risk premium of asset i, with βi = cov(XM , Xi) var(XM ) . This β measures sensitivity of asset i to market ﬂuctuations. This model, introduced in Markowitz (1952), was presented in Sharpe (1963) as a regression model Xi = αi + βiXM + εi. The risk of asset i is var(Xi) = (β2 i var(XM )) · var(εi), where (β2 i var(XM )) can be interpreted as the systematic risk of asset i, and var(εi) as the speciﬁc risk of asset i. @freakonometrics freakonometrics freakonometrics.hypotheses.org 39
40. 40. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 CAPM and APT In the CAPM, only one risk factor is considered, a so-called market factor. Ross (1976) sugested to extend the approach of Sharpe (1963) by introducing several risk factors, in the APT (Arbitrage Pricing Theory) model, where Xi = αi + b1,iF1 + · · · + bk,iFk + εi. Those risk factors can be determined endogeneously, using some principal component analysis, or exogeneously using some (economic) covariates. @freakonometrics freakonometrics freakonometrics.hypotheses.org 40
41. 41. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Describing Diversiﬁcation Choueifaty & Coignard (2008) and Choueifaty et al. (2011) introduced a diversiﬁcation ratio (DR) is deﬁned for a given weight vector ω in the allowed set of portfolio solutions Ω as DR(ω) = ωT diag(Σ) √ ωTΣω the higher the DR, the more the portfolio is diversiﬁed DR has a lower bound of one (obtained with single-asset portfolios) @freakonometrics freakonometrics freakonometrics.hypotheses.org 41
42. 42. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Describing Diversiﬁcation An alternative formulation is the following : let CR denote the volatility-weighted concentration ratio (see Herﬁndahl–Hirschmann index) CR(ω) = i(ωiσi)2 i ωiσi 2 (the later is bounded in the interval [n−1 , 1]) and the volatility-weighted average correlation ρ(ω) = i=j ωiωjσiσjρi,j i=j ωiωjσiσj then DR(ω) = 1 (DR(ω) + ρ(ω)) − DR(ω) ∗ ρ(ω) The most diversiﬁed portfolio is then solution of argmax{DR(ω)} @freakonometrics freakonometrics freakonometrics.hypotheses.org 42
43. 43. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization The use of sample estimators for the expected returns and the covariance matrix can result in sub-optimal portfolio results due to estimation error, see Maronna et al. (2006) and Todorov and Filzmoser (2009) The most popular estimators are the ML estimators (maximum likelihood). Consider i.i.d. data, with density f(·; θ) θ = argmax {L(θ; x)} = argmax n i=1 f(xi; θ) = argmin − n i=1 log f(xi; θ) First order condition : n i=1 1 log f(xi; θ) ∂f(xi; θ) ∂θ θ=θ = n i=1 Ψ(x, θ) = 0 were Ψ(x, θ) is the score function. @freakonometrics freakonometrics freakonometrics.hypotheses.org 43
44. 44. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization For the Gaussian distribution, f(x, θ) ∝ exp − (x − θ)2 2σ2 so that Ψ(x, θ) = x − θ 2σ2 , and θ = x = 1 n n i=1 xi For the Laplace distribution, f(x, θ) ∝ exp − |x − θ| σ so that Ψ(x, θ) = sign(x − θ) σ , and θ = median(x). Most MLE estimators θ are consistent (converge in probability) estimators of the true parameter θ, and has an asymptotic normal distribution, √ n θ − θ L → N(0, V [θ]) where the asymptotic variance is actually the smallest possivle variance (for unbiased estimators), V [θ] = I[θ]−1 where I[θ] denotes Fisher information, E[Ψ2 (x, θ)] @freakonometrics freakonometrics freakonometrics.hypotheses.org 44
45. 45. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization Hence, for the Gaussian and the Laplace distribution, V [θ] = σ2 See Casella and Berger (1990) for more details. One can deﬁne the eﬃciency of any (univariate) estimator θ as eﬀ(θ, F) = V [θmle, F] V [θ, F] ∈ [0, 1] For instance, eﬀ(x, Laplace) = 50% and eﬀ(median(x), Gaussian) = 63.7% Since we don’t know the (true) distribution, how could we know ? The MLE estimator of the correlation is ρj,k = Σj,k Σj,jΣk,k where Σj,k = 1 n n i=1 (xi,j − xj)(xi,k − xk) @freakonometrics freakonometrics freakonometrics.hypotheses.org 45
46. 46. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization How robust is that estimator ? See Martin (2014) Consider the following two ﬁnancial series @freakonometrics freakonometrics freakonometrics.hypotheses.org 46
47. 47. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization How robust is that correlation estimator ? See Martin (2014) MLE (or classical) correlation estimator θ ∼ 30% while a more robust estimator yields θ ∼ 65% (here fast minimum covariance determinant - MCD) @freakonometrics freakonometrics freakonometrics.hypotheses.org 47
48. 48. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization One can also consider a regression problem (EDS returns vs. Market returns) MLE (or classical) slope estimator β ∼ 1.41 while a more robust estimator yields β ∼ 2.03 The main reason for such a diﬀerence is outliers. @freakonometrics freakonometrics freakonometrics.hypotheses.org 48
49. 49. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization How to detect outliers ? Use Mahalanobis distance (Euclidean distance with spherized coordinates), induced by the norm xi 2 = (xi − µ)T Σ−1 (xi − µ) = zT i zi where zi = Σ−1/2 (xi − µ). @freakonometrics freakonometrics freakonometrics.hypotheses.org 49
50. 50. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization How robust is that approach ? See Martin (2014) MLE (or classical) correlation estimator on the left and a more robust estimator estimator for Σ on the right See Tukey (1979) “[· · · ]just which robust methods you use is not important – what is important is that you use some. It is perfectly proper to use both classical and robust methods routinely, and only worry when they diﬀer enough to mat- ter. But when they diﬀer, you should think hard.” @freakonometrics freakonometrics freakonometrics.hypotheses.org 50
51. 51. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization Use of trimmed mean (or truncated mean) instead of standard sample mean µ = x = 1 n n i=1 xi:n against µα = 1 n(1 − 2α) n−[αn] i=1+[αn] xi:n where classically α ∼ 5% in Tukey (1960) while it is suggested to use 24% for Libor Rate Fixing (BBA, see wikipedia). Observe that on the same dataset, banks can have very diﬀerent estimates, see Tuckman & Serrat (2011) On can consider so-called location M-estimates, θ = argmin n i=1 ρ(xi; θ) for some function ρ, @freakonometrics freakonometrics freakonometrics.hypotheses.org 51
52. 52. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization θ = argmin n i=1 ρ(xi; θ) If ρ(x; θ) = − log f(x; θ) we get the MLE If ρ(x; θ) = (x − θ)2 we get the OLS In the case of the mean, µ = argmin n i=1 ρ xi − µ σ which yields a ﬁrst order condition n i=1 Ψ xi − µ σ = 0 @freakonometrics freakonometrics freakonometrics.hypotheses.org 52
53. 53. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization Huber (1964) suggested ρ(x) =    x2 /2 if |x| ≤ δ δ |x| − δ/2 otherwise which is (asymptotically) equivalent to a trimmed mean. ρ(x) =    x if |x| ≤ δ ±δ otherwise @freakonometrics freakonometrics freakonometrics.hypotheses.org 53
54. 54. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization Hampel (1974) introduced the Empirical Inﬂuence Function eif(x; θ, x) = (n + 1) θ({x, x}) − θ(x) The class of MM estimators was originally introduced by Yohai (1987) and Yohai et al. (1991) in the context of robust regression analysis. Consider some random vector X ∼ N(µ, Σ) Consider the related Mahalanobis norm, x 2 = (x − µ)T Σ−1 (x − µ) Robust estimators of µ and Σ are obtained from (µ, Σ) = argmin xi 2 @freakonometrics freakonometrics freakonometrics.hypotheses.org 54
55. 55. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization The Minimum Covariance Determinant Estimator (MCD) was introduced by Rousseeuw (1984) Given a sample {x1, · · · , xn}, consider the subset of h observations (out of n) whose (classical) covariance matrix has a smallest determinant Consider usually h = (d + dim(x) + 1)/2 A C-step is a move from one approximation µ1, C1 of the mean and the variance to a new one µ2, C2 with (possibly) a lower determinant... 1 > library(rrcov) 2 > mcd=CovMcd(X) 3 > summary(mcd) @freakonometrics freakonometrics freakonometrics.hypotheses.org 55
56. 56. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization To compute it, consider the following 3 steps, C-step iteration: repeat 500 times some C-steps and keep the best 10 solutions. From each of the top 10, carry out C-steps until convergence, and keep the best one. Partitoning if the dataset is large, partition into (say) 5 disjoint subsets. Carry out C-steps iterations for each subsets. Use the best solutions as starting points. Nesting if the subset is even larger, consider random subsets and use the partition procedure @freakonometrics freakonometrics freakonometrics.hypotheses.org 56
57. 57. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Robust portfolio optimization Finally, the Stahel–Donoho estimator (SDE) is due to Stahel (1981) and Donoho (1982), while the OGK estimator was proposed by Maronna & Zamar (2002). @freakonometrics freakonometrics freakonometrics.hypotheses.org 57
58. 58. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects 1 library(FRAPO) 2 data( StockIndex ) 3 pzoo = zoo ( StockIndex , order.by = rownames ( StockIndex ) ) 4 rzoo = ( pzoo / lag ( pzoo , k = -1) - 1 ) * 100 The following function can be used to estimate Σ 1 Moments <- function ( x , method = c ( "CovClassic" , "CovMcd" , " CovMest" , "CovMMest" , "CovMve" , "CovOgk" , "CovSde" , "CovSest" ) , ... ) { 2 method <- match.arg ( method ) 3 ans <- do.call ( method , list ( x = x , ... ) ) 4 return ( getCov ( ans ) )} @freakonometrics freakonometrics freakonometrics.hypotheses.org 58
59. 59. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects 1 > Moments(as.matrix(rzoo),"CovClassic") 2 SP500 N225 FTSE100 CAC40 GDAX HSI 3 SP500 17.772 12.706 13.766 17.802 19.451 18.924 4 N225 12.706 36.619 10.773 15.025 16.180 16.653 5 FTSE100 13.766 10.773 17.288 18.787 19.400 19.065 6 CAC40 17.802 15.025 18.787 30.947 29.904 22.774 7 GDAX 19.451 16.180 19.400 29.904 38.037 26.089 8 HSI 18.924 16.653 19.065 22.774 26.089 58.135 1 > Moments(as.matrix(rzoo),"CovMcd") 2 SP500 N225 FTSE100 CAC40 GDAX HSI 3 SP500 18.216 14.622 13.998 17.863 20.773 17.844 4 N225 14.622 40.945 12.910 18.157 18.789 15.832 5 FTSE100 13.998 12.910 16.331 17.790 19.813 15.117 6 CAC40 17.863 18.157 17.790 28.204 28.072 17.589 7 GDAX 20.773 18.789 19.813 28.072 35.880 22.427 8 HSI 17.844 15.832 15.117 17.589 22.427 44.121 @freakonometrics freakonometrics freakonometrics.hypotheses.org 59
60. 60. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects 1 > Moments(as.matrix(rzoo),"CovMest") 2 SP500 N225 FTSE100 CAC40 GDAX HSI 3 SP500 17.279 13.456 13.166 16.899 18.722 16.369 4 N225 13.456 40.132 11.482 15.795 16.992 16.907 5 FTSE100 13.166 11.482 15.438 16.666 17.828 14.273 6 CAC40 16.899 15.795 16.666 27.096 25.678 16.035 7 GDAX 18.722 16.992 17.828 25.678 31.926 20.549 8 HSI 16.369 16.907 14.273 16.035 20.549 42.624 1 > Moments(as.matrix(rzoo),"CovMMest") 2 SP500 N225 FTSE100 CAC40 GDAX HSI 3 SP500 16.126 11.966 12.328 16.043 17.746 16.295 4 N225 11.966 35.634 10.322 14.605 15.432 14.458 5 FTSE100 12.328 10.322 15.109 16.447 17.367 15.439 6 CAC40 16.043 14.605 16.447 27.571 26.430 18.110 7 GDAX 17.746 15.432 17.367 26.430 33.008 21.800 8 HSI 16.295 14.458 15.439 18.110 21.800 46.634 @freakonometrics freakonometrics freakonometrics.hypotheses.org 60
61. 61. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Computational Aspects 1 > Moments(as.matrix(rzoo),"CovOgk") 2 SP500 N225 FTSE100 CAC40 GDAX HSI 3 SP500 12.757 9.871 9.382 12.324 13.607 12.294 4 N225 9.871 27.533 8.252 11.905 12.626 11.448 5 FTSE100 9.382 8.252 10.920 11.811 12.419 10.366 6 CAC40 12.324 11.905 11.811 19.690 18.640 12.316 7 GDAX 13.607 12.626 12.419 18.640 23.188 15.027 8 HSI 12.294 11.448 10.366 12.316 15.027 32.958 1 > Moments(as.matrix(rzoo),"CovSde") 2 SP500 N225 FTSE100 CAC40 GDAX HSI 3 SP500 16.988 14.172 12.266 16.469 19.210 18.683 4 N225 14.172 39.978 12.342 18.379 19.660 16.415 5 FTSE100 12.266 12.342 14.234 15.402 17.316 15.634 6 CAC40 16.469 18.379 15.402 25.932 25.941 18.895 7 GDAX 19.210 19.660 17.316 25.941 32.906 23.186 8 HSI 18.683 16.415 15.634 18.895 23.186 47.170 @freakonometrics freakonometrics freakonometrics.hypotheses.org 61
62. 62. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Optimal Portfolio under Value-at-Risk Constraint Consider ﬁrst the case of Elliptical Returns. Elliptical distributions (see Fang, Ng & Kotz (1991)) are interesting since they extend the Gaussian case, with similar properties. If X ∼ N(µ, Σ), and if X =   X1 X2   ∼ N     µ1 µ2   ,   Σ11 Σ12 Σ21 Σ22     • Xi ∼ N(µi, Σi), for all i = 1, · · · , d, • α X = α1X1 + · · · + αdXd ∼ N(α µ, α Σα), • X1|X2 = x2 ∼ N(µ1 + Σ12Σ−1 2,2(x2 − µ2), Σ1,1 − Σ12Σ−1 2,2Σ21) @freakonometrics freakonometrics freakonometrics.hypotheses.org 62
63. 63. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Elliptical Distribution @freakonometrics freakonometrics freakonometrics.hypotheses.org 63
64. 64. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Optimal Portfolio under Value-at-Risk Constraint For instance, if X is elliptical, then for any α, αT X is also elliptical. Elliptical distributions were (formally) introduced in Kelker (1970). Spherical distributions are extensions of the N (0, I) and elliptical ones are extensions of the N (µ, Σ). Random vector X in Rn is said to have an elliptical distribution with generator g and parameters µ and Σ, denoted X ∼ Ell(g, µ, Σ) if it has density fX (x) = cn |Σ| 1/2 g 1 2 (x − µ) T Σ−1 (x − µ) , où la for some normalization constant cn deﬁned as cn = Γ (n/2) (2π) n/2 ∞ 0 tn/2−1 g (t) dt. If g(·) is the exponential function, we obtain the multivariate Gaussian distribution N(µ, Σ). @freakonometrics freakonometrics freakonometrics.hypotheses.org 64
65. 65. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Optimal Portfolio under Value-at-Risk Constraint Marginal distributions of elliptical ones are themselves elliptical X ∼ Ell(g, µ, Σ) ⇒ Xk ∼ Ell(g, µk, σ2 k) for k = 1, . . . , n. Furthermore, for any matrix B and vector b, BX ∼ Ell(g, µ, Σ) ⇒ b + BX ∼ Ell(g, b + Bµ, BΣBT ). For instance, one can obtain the multivariate Student t distribution with g (t) = 1 + t kp −p , where p should exceed n/2, and kp is some normalization coeﬃcient. The density of X is given by fX (x) = cn |Σ| 1/2 1 + (X − µ) T Σ (X − µ) Γ (p − n/2) −p for X ∈ Rn . @freakonometrics freakonometrics freakonometrics.hypotheses.org 65
66. 66. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Optimal Portfolio under Value-at-Risk Constraint This multivariate Student distribution can be obtained also as follows. Let Z ∼ N (0, I) and S ∼ χ2 (m) be independent. Vector Y = √ mZ/S has a Student t distribution, with m degrees of freedom. The general distribution can then be obtained using Y ∗ = µ + Σ1/2 Y , where (Σ1/2 )T (Σ1/2 ) = Σ. Similarly, the multivariate Cauchy distribution has density fX (x) = Γ ((n + 1) /2) π(n+1)/2|ΣΣ| 1/2 1 + (X − µ) (X − µ) −(n+1)/2 for x ∈ Rn . One can also introduce a multivariate logistic distribution, with generator g (t) = exp(−t) 1 + exp(−t) 2 . @freakonometrics freakonometrics freakonometrics.hypotheses.org 66
67. 67. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Density can then be writen fX (x) = cn |Σ| 1/2 exp −1 2 (X − µ) T Σ−1 (X − µ) 1 + exp −1 2 (X − µ) T Σ−1 (X − µ) 2 pour X ∈ Rn . Finally, consider the following generator g (t) = exp (−rts ) , where r ans s are two positive parameters. The associated density is fX (x) = cn |Σ| 1/2 exp − r 2 (x − µ) T Σ−1 (x − µ) s for any x ∈ Rn , where normalizing constant cn is here cn = sΓ (n/2) (2π) n/2 Γ (n/ (2s)) rn/(2s) , When s = r = 1, we recognize the Gaussian distribution, while s = 1/2 and r = √ 2 is the Laplace distribution. @freakonometrics freakonometrics freakonometrics.hypotheses.org 67
68. 68. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Allocations Based on Higher Moments Higher moments are more complex to deﬁne in high dimension (d ≥ 2). In dimension 1, skewness and kurtosis are respectively deﬁned as s = m3 = E((X − E(X))3 ) and κ = m4 = E((X − E(X))4 ). In dimension d, variance becomes a variance-covariance matrix d × d, and skewness will be d × d2 matrix. Set µ = E(X) S = M3 = E((X − µ)(X − µ)T ⊗ (X − µ)T ) = [si,j,k] where si,j,k = E((Xi − µi)(Xj − µj)(Xk − µk)), while K = M4 = E((X − µ)(X − µ)T ⊗ (X − µ)T ⊗ (X − µ)T ) = [κi,j,k,l] where κi,j,k,l = E (Xi − µi)(Xj − µj)(Xk − µk)(Xl − µl) , @freakonometrics freakonometrics freakonometrics.hypotheses.org 68
69. 69. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 where ⊗ is Kronecker product, e.g. A =   1 3 2 4   , B =   1 2 0 1   , A ⊗ B =   B 3B 2B 4B   =        1 2 3 6 0 1 0 3 2 4 4 8 0 2 0 4        In R, matrix product is %*% while Kronecker prodct is %x% 1 > A=matrix (1:4 ,2 ,2) 2 > B=matrix(c(1,0,2,1) ,2,2) 3 > A%*%B 4 [,1] [,2] 5 [1,] 1 5 6 [2,] 2 8 7 > A%x%B 8 [,1] [,2] [,3] [,4] 9 [1,] 1 2 3 6 @freakonometrics freakonometrics freakonometrics.hypotheses.org 69
70. 70. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 10 [2,] 0 1 0 3 11 [3,] 2 4 4 8 12 [4,] 0 2 0 4 Consider the case of dimension d = 2 (2 assets), then the skweness matrix is =   s1,1,1 s1,1,2 s2,1,1 s2,1,2 s1,2,1 s1,2,2 s2,2,1 s2,2,2   = S1 S2 , where S1 and S2 are 2 × 2 matrices. Similarily, M4 = K1,1 K1,2 K2,1 K2,2 , where Ki,j are 2 × 2 matrices. @freakonometrics freakonometrics freakonometrics.hypotheses.org 70
71. 71. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Allocations Based on Higher Moments The variance was based on d(d + 1)/2 distinct terms, the skewness is based on d(d + 1)(d + 2)/6 distinct terms, and the kurtosis is based on d(d + 1)(d + 3)/27 terms. Let X denote a random vector with mean µ, variance Σ, skewness S and Kurtosis K, then for any α, E(αT X) = αT µ and var(αT X) = αT Σα, Similarly, skewness and kurstosis can be derived for α X s = αT S(α ⊗ α) 1/3 while κ = αT K(α ⊗ α ⊗ α) 1/4 . @freakonometrics freakonometrics freakonometrics.hypotheses.org 71
72. 72. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Cornish-Fisher Decomposition to Approximate Value-at-Risk In a Gaussian model X ∼ N(µ, σ), the α-VaR is VaRα(X) = −µ + Φ−1 (1 − α) · σ = −E(X) + Φ−1 (1 − α) · V ar(X), where Φ is the c.d.f of the N(0, 1) distribution. Using here a Gaussian approximation V aR(X, α) = −E(X) + Φ−1 (1 − α) · V ar(X), for non-Gaussian variables might be a bad approximation. Use the Normal-Power approximation, or Edgeworth expansion. Cornish-Fisher approximation (from Cornish & Fisher (1950) or Hill & Davis (1968) ) is based on a higher moment expansion of a normalized version of X, [X − E(X)]/σ @freakonometrics freakonometrics freakonometrics.hypotheses.org 72
73. 73. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Cornish-Fisher Decomposition to Approximate Value-at-Risk Set VaRα(X) ∼ −E(X) + z1−α · V ar(X), where z1−α is Φ−1 (1−α)+ ζ1 6 [Φ−1 (1−α)2 −1]+ ζ2 24 [Φ−1 (1−α)3 −3Φ−1 (1−α)]− ζ2 1 36 [2Φ−1 (1−α)3 −5Φ−1 (1− where ζ1 is the skewness, and ζ2 is the excess-kurtosis ζ1 = E([X − E]3 ) E([X − E]2)3/2 and ζ2 = E([X − E]4 ) E([X − E]2)2 − 3. Given a n sample {X1, · · · , Xn}, the Cornish-Fisher estimation of the α-quantile is qn(α) = µ + zασ, where µ = 1 n n i=1 Xi and σ = 1 n − 1 n i=1 (Xi − µ) 2 , @freakonometrics freakonometrics freakonometrics.hypotheses.org 73
74. 74. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Cornish-Fisher Decomposition to Approximate Value-at-Risk and zα = Φ−1 (α)+ ζ1 6 [Φ−1 (α)2 −1]+ ζ2 24 [Φ−1 (α)3 −3Φ−1 (α)]− ζ2 1 36 [2Φ−1 (α)3 −5Φ−1 (α)], where ζ1 is the natural estimator for the skewness of X, and ζ2 is the natural estimator of the excess kurtosis, i.e. ζ1 = n(n − 1) n − 2 √ n n i=1(Xi − µ)3 ( n i=1(Xi − µ)2) 3/2 and ζ2 = n − 1 (n − 2)(n − 3) (n + 1)ζ2 + 6 where ζ2 = n n i=1(Xi − µ)4 ( n i=1(Xi − µ)2) 2 − 3. @freakonometrics freakonometrics freakonometrics.hypotheses.org 74
75. 75. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Numerical Optimization The goal is to ﬁnd x∗ = Argmin{f(x)} or x∗ = Argmin{f(x)} where with a very general setting, f is a Rp → R function. Construct a sequence (xn) or (xn) following the gradient f (xn) or f(xn). Itetatively, starting from x0 or x0 construct xn+1 = xn − µn · f (xn) or xn+1 = xn − µn · f(xn) where µn min R is obtained at each step using f(xn+1) = inf µ∈R {xn − µf (xn)} or f(xn+1) = inf µ∈Rd {xn − µ f(xn)} In dimension 1, if f is diﬀerentiable and β-convex, i.e. f x + y 2 ≤ f(x) + f(y) 2 − β 8 x − y 2 , @freakonometrics freakonometrics freakonometrics.hypotheses.org 75
76. 76. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 and if f is Lipschitz on any bounded set, i.e. for all M, there is CM such that if x + y ≤ M, f (x) + f (y) ≤ CM x − y , then the sequence (xn) converges towards the optimal value, whatever x0. Fixed Step Gradient Descent Consider here a sequence (xn) or (xn) constructed iteratively using xn+1 = xn − µ · f (xn) or xn+1 = xn − µ · f(xn), where µ > 0 is ﬁxed. The algorithm is simple, but there are more restictive conditions to insure convergence. If f is diﬀerentiable and β-convex, i.e. f x + y 2 ≤ f(x) + f(y) 2 − β 8 x − y 2 , @freakonometrics freakonometrics freakonometrics.hypotheses.org 76
77. 77. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 and if f is Lipschitz, i.e. there exists C such that f (x) + f (y) ≤ C x − y , then if 0 < µ < 2β/C2 , the sequence (xn) converges to the optimal solution, whatever x0. However, if we can obtain convergence, the speed of convergence is at least geometric since xn − x∗ ≤ κn x0 − x∗ where κn = 1 − 2βµ + µ2C2. Using Newtonś Algorithm Suppose f : Rn → Rn twice diﬀerentiable, and x∗ be a singular zero of f, in the sense that f(x∗ ) = 0 and f(x∗ ) is an invertible matrix. Taylor’s expansion, in the neighborhood of x yields f(x) = f(x∗ ) + f(x∗ )(x − (x∗ )) + O( x − x∗ 2 ). @freakonometrics freakonometrics freakonometrics.hypotheses.org 77
78. 78. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 If we neglect the remaining term, we construct a sequence (xn) en posant, à partir d’une valeur initiale x0, xn+1 = xn − f(xn)−1 f(xn) for all n = 0, 1, 2, · · · If f : Rn → Rn is twice diﬀerentiable, and x∗ is a singular zero of f, then sequence (xn) converges to the optimal decision whatever x0, and furthermore, there is C > 0 such that xn+1 − x∗ ≤ C xn − x∗ 2 . This algorithm is simple, but it is based on solving a linear system. @freakonometrics freakonometrics freakonometrics.hypotheses.org 78
79. 79. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Numerical Aspects 1 > asset.names = c("MSFT", "NORD", "SBUX") 2 > er = c(0.0427 , 0.0015 , 0.0285) 3 > names(er) = asset.names 4 > covmat = matrix(c(0.0100 , 0.0018 , 0.0011 , 0.0018 , 0.0109 , 0.0026 , 0.0011 , 0.0026 , 0.0199) ,nrow=3, ncol =3) 5 > rk.free = 0.005 6 > dimnames(covmat) = list(asset.names , asset.names) One can also use internal R function for most computations, see 1 > load("http:// freakonometrics .free.fr/portfolio.r") from Zivot (2013). 1 > ew = rep (1 ,3)/3 2 > equalWeight.portfolio = getPortfolio (er=er ,cov.mat=covmat ,weights= ew) 3 > equalWeight.portfolio 4 Call: @freakonometrics freakonometrics freakonometrics.hypotheses.org 79
80. 80. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 5 getPortfolio (er = er , cov.mat = covmat , weights = ew) 6 Portfolio expected return: 0.02423 7 Portfolio standard deviation: 0.07587 8 Portfolio weights: 9 MSFT NORD SBUX 10 0.3333 0.3333 0.3333 11 > plot(equalWeight.portfolio) To get the minimum variance portfolio, use 1 > gmin.port <- globalMin.portfolio(er , covmat) 2 > attributes(gmin.port) 3 \$names 4 [1] "call" 5 "er" 6 "sd" 7 "weights" 8 \$class 9 [1] "portfolio" @freakonometrics freakonometrics freakonometrics.hypotheses.org 80
81. 81. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 10 > gmin.port 11 Call: 12 globalMin.portfolio(er = er , cov.mat = covmat) 13 Portfolio expected return: 0.02489184 14 Portfolio standard deviation: 0.07267607 15 Portfolio weights: 16 MSFT NORD SBUX 17 0.4411 0.3656 0.1933 or for any eﬃcient portfolio, with a given target expected return 1 > target.return <- er[1] 2 > e.port.msft <- efficient.portfolio(er , covmat , target.return) 3 > e.port.msft 4 Call: 5 efficient.portfolio(er = er , cov.mat = covmat , 6 target.return = target.return) 7 Portfolio expected return: 0.0427 8 Portfolio standard deviation: 0.091656 @freakonometrics freakonometrics freakonometrics.hypotheses.org 81
82. 82. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 9 Portfolio weights: 10 MSFT NORD SBUX 11 0.8275 -0.0907 0.2633 We can also consider the case where a risk-free asset is available 1 > tan.port <- tangency.portfolio(er , covmat , rk.free) 2 > tan.port 3 Call: 4 tangency.portfolio(er = er , cov.mat = covmat , risk.free = rk.free) 5 Portfolio expected return: 0.0518896 6 Portfolio standard deviation: 0.1115816 7 Portfolio weights: 8 MSFT NORD SBUX 9 1.0268 -0.3263 0.2994 1 > ef <- efficient.frontier(er , covmat , alpha.min=-2, alpha.max =1.5 , nport =20) @freakonometrics freakonometrics freakonometrics.hypotheses.org 82
83. 83. Arthur Charpentier, Université de Rennes 1, Portfolio Optimization - 2017 Numerical Aspects One can also use standard R packages for most computations. 1 > library(FRAPO) 2 > library( PerformanceAnalytics ) 3 > library(fPortfolio) (to be continued...) @freakonometrics freakonometrics freakonometrics.hypotheses.org 83