# Optimital portfolio

### Description

Function wich computes the portfolio's weights

### Usage

1 | ```
optimalPortfolio(Sigma, mu = NULL, semiDev = NULL, control = list())
``` |

### Arguments

`Sigma` |
a |

`mu` |
a |

`semiDev` |
a vector |

`control` |
control parameters (see *Details*). |

### Details

The argument `control`

is a list that can supply any of the following components:

`type`

method used to compute the optimal portfolio, among

`'mv'`

,`'minvol'`

,`'erc'`

,`'maxdiv'`

and`'riskeff'`

where:`'mv'`

is used to compute the weights of the mean-variance portfolio. The weights are computed following this equation:*w = 1 / γ Σ^{-1} μ*`'minvol'`

is used to compute the weights of the minimum variance portfolio.`'erc'`

is used to compute the weights of the equal-risk-contribution portfolio. For a portfolio*w*, the percentage volatility risk contribution of the i-th asset in the portfolio is given by:*% RC_i = w_i[Σ w]_i / (w' Σ w)*Then we compute the optimal portfolio by solving the following optimization problem:

*argmin { ∑_{i=1}^{N} (% RC_i - 1/N)^2}*`'maxdiv'`

is used to compute the weights of the maximum diversification portfolio where:*DR(w) = (w' σ)/(√(w' Σ w)) ≥ 1*is used in the optimization problem.

`'riskeff'`

is used to compute the weights of the risk-efficient portfolio:*w = argmax ( w'J ξ)√(w'Σ w)*where

*J*is a*(N x 10)*matrix of zeros whose*(i,j)*-th element is one if the semi-deviation of stock*i*belongs to decile*j*,*ξ = (ξ_1,…,ξ_{10})'*. Default:`type = 'mv'`

`constraint`

constraint used for the optimization, among

`'none'`

,`'lo'`

and`'gross'`

where :`'none'`

is used to compute the unconstraint portfolio`'lo'`

is the long-only constraint.`'gross'`

is the gross constraint.Default:

`constraint = 'none'`

.`gross.c`

Gross exposure constraint. Default:

`gross.c = 1.6`

.`gamma`

Risk aversion parameter. Default:

`gamma = 0.89`

.

### Value

A *(N x 1)* vector of optimal portfolio weights.

### Author(s)

David Ardia <david.ardia@unifr.ch> and Jean-Philippe Gagnon Fleury.

### References

Amenc, N., Goltz, F., Martellini, L., Retowsky, P. (2011).
Efficient indexation: An alternatice to cap-weightes indices.
*Journal of Investment Management* **9**(4), pp.1–23.

Ardia, D., Boudt, K. (2013). Implied expected returns and the choice of a mean-variance efficient portfolio proxy. http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2215042.

Choueifaty, Y., Coignard, Y., (2008).
Toward maximum diversification.
*Journal of Portfolio Management* **35** (1), pp.40–51.

Choueifaty, Y., Froidure, T., Reynier, J., (2011).
Properties of the most diversified portfolio.
*Working paper*.

Das, S., Markowitz, H., Scheid, J., Statman, M., (2010).
Portfolio optimization with mental accounts.
*Journal of Financial and Quantitative Analysis* **45**, pp.311–334.

DeMiguel, V., Garlappi, L., Uppal, R., (2009).
Optimal versus naive diversification: How inefficient is the 1/n portfolio strategy.
*The Review of Financial Studies* **22**(5), pp.1915–1953.

Fan, J., Zhang, J., Yu, K., March (2009). Asset allocation and risk assessment with gross exposure constraints for vast portfolios.

Maillard, S., Roncalli, T., Teiletche, J., (2010).
The properties of equally weighted risk contribution portfolios.
*Journal of Portfolio Management* **36**(4), pp.60–70.

Martellini, L., (2008).
Towards the design of better equity benchmarks.
*Journal of Portfolio Management* **34**, Summer,pp.34–41.

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | ```
# For the examples, we simply generate a 100 x 25 random matrix.
set.seed(3214)
T = 100
N = 25
rets = matrix(rnorm(T*N), nrow = T, ncol = N)
mu = meanEstimation(rets)
Sigma = covEstimation(rets)
semiDev = semidevEstimation(rets)
#Computes the mean-variance portfolio without constraint and gamma = 0.89.
optimalPortfolio(mu = mu, Sigma = Sigma)
#Computes the mean-variance portfolio without constraint and gamma = 1.
optimalPortfolio(mu = mu, Sigma = Sigma, control = list(gamma = 1))
#Computes the mean-variance portfolio with without and gamma = 0.89.
optimalPortfolio(mu = mu, Sigma = Sigma, control = list(type = "mv"))
#Computes the mean-variance portfolio without constraint and gamma = 0.89.
optimalPortfolio(mu = mu, Sigma = Sigma, control = list(type = "mv", constraint = "none"))
#Computes the mean-variance portfolio with the long only constraint and gamma = 0.89.
optimalPortfolio(mu = mu, Sigma = Sigma, control = list(type = "mv", constraint = "lo"))
#Computes the mean-variance portfolio with the gross constraint, gross constraint parameter = 1.6 and gamma = 0.89.
optimalPortfolio(mu = mu, Sigma = Sigma, control = list(type = "mv", constraint = "gross"))
#Computes the mean-variance portfolio with the gross constraint, gross constraint parameter = 1.2 and gamma = 0.89.
optimalPortfolio(mu = mu, Sigma = Sigma, control = list(type = "mv", constraint = "gross", gross.c = 1.2))
#Computes the minimum volatility portfolio without constraint.
optimalPortfolio(Sigma = Sigma, control = list(type = "minvol"))
#Computes the minimum volatility portfolio without constraint.
optimalPortfolio(Sigma = Sigma, control = list(type = "minvol", constraint = "none"))
#Computes the minimim volatility portfolio with the long only constraint.
optimalPortfolio(Sigma = Sigma, control = list(type = "minvol", constraint = "lo"))
#Computes the minimum volatility portfolio with the gross constraint and the gross constraint parameter = 1.6.
optimalPortfolio(Sigma = Sigma, control = list(type = "minvol", constraint = "gross"))
#Computes the minimum volatility portfolio with the gross constraint and the gross parameter = 1.2.
optimalPortfolio(Sigma = Sigma, control = list(type = "minvol", constraint = "gross", gross.c = 1.2))
#Computes the equal-risk-contribution portfolio without constraint.
optimalPortfolio(Sigma = Sigma, control = list(type = "erc"))
#Computes the equal-risk-contribution portfolio without constraint.
optimalPortfolio(Sigma = Sigma, control = list(type = "erc", constraint = "none"))
#Computes the equal-risk-contribution portfolio with the long only constraint.
optimalPortfolio(Sigma = Sigma, control = list(type = "erc", constraint = "lo"))
#Computes the equal-risk-contribution portfolio with the gross constraint and the gross parameter = 1.6.
optimalPortfolio(Sigma = Sigma, control = list(type = "erc", constraint = "gross"))
#Computes the equal-risk-contribution portfolio with the gross constraint and the gross parameter = 1.2.
optimalPortfolio(Sigma = Sigma, control = list(type = "erc", constraint = "gross", gross.c = 1.2))
#Computes the maximum diversification portfolio without constraint.
optimalPortfolio(Sigma = Sigma, control = list(type = "maxdiv"))
#Computes the maximum diversification portfolio without constraint.
optimalPortfolio(Sigma = Sigma, control = list(type = "maxdiv", constraint = "none"))
#Compute the maximum diversification portoflio with the long only constraint.
optimalPortfolio(Sigma = Sigma, control = list(type = "maxdiv", constraint = "lo"))
#Computes the maximum diversification portfolio with the gross constraint and the gross parameter = 1.6.
optimalPortfolio(Sigma = Sigma, control = list(type = "maxdiv", constraint = "gross"))
#Computes the maximum diversification portfolio with the gross constraint and the gross parameter = 1.2.
optimalPortfolio(Sigma = Sigma, control = list(type = "maxdiv", constraint = "gross", gross.c = 1.2))
#Computes the risk-efficient portfolio without constraint.
optimalPortfolio(Sigma = Sigma, semiDev = semiDev, control = list(type = "riskeff"))
#Computes the risk-efficient portfolio without constraint.
optimalPortfolio(Sigma = Sigma, semiDev = semiDev, control = list(type = "riskeff", constraint = "none"))
#Computes the risk-efficient portfolio with the long only constraint.
optimalPortfolio(Sigma = Sigma, semiDev = semiDev, control = list(type = "riskeff", constraint = "lo"))
#Computes the risk-efficient portfolio with the gross constraint and the gross parameter = 1.6.
optimalPortfolio(Sigma = Sigma, semiDev = semiDev, control = list(type = "riskeff", constraint = "gross"))
#Computes the risk-efficient portfolio with the gross constraint and the gross parameter = 1.2.
optimalPortfolio(Sigma = Sigma, semiDev = semiDev, control = list(type = "riskeff", constraint = "gross", gross.c = 1.2))
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.