Description Usage Arguments Details Value Author(s) References Examples
View source: R/riskParityPortfolio.R
This function designs risk parity portfolios to equalize/distribute the risk contributions of the different assets, which is missing if we simply consider the overall volatility of the portfolio as in the meanvariance Markowitz portfolio. In addition to the vanilla formulation, where the risk contributions are perfectly equalized subject to no shortselling and budget constraints, many other formulations are considered that allow for box constraints, as well as the inclusion of additional objectives like the expected return and overall variance. In short, this function solves the following problem:
minimize R(w)  lmd_mu * t(w) %*% mu + lmd_var * t(w) %*% Sigma %*% w
subject to sum(w) = 1, w_lb <= w <= w_ub
,
Cmat %*% w = cvec, Dmat %*% w <= dvec
,
where R(w)
denotes the risk concentration,
t(w) %*% mu
is the expected return, t(w) %*% Sigma %*% w
is the
overall variance, lmd_mu
and lmd_var
are the tradeoff weights
for the expected return and the variance terms, respectively, w_lb
and
w_ub
are the lower and upper bound vector values for the portfolio vector w
,
Cmat %*% w = cvec
denotes arbitrary linear equality constrains, and
Dmat %*% w = dvec
denotes arbitrary linear inequality constrains.
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  riskParityPortfolio(
Sigma,
b = NULL,
mu = NULL,
lmd_mu = 0,
lmd_var = 0,
w_lb = 0,
w_ub = 1,
Cmat = NULL,
cvec = NULL,
Dmat = NULL,
dvec = NULL,
method_init = c("cyclicalspinu", "cyclicalroncalli", "newton"),
method = c("sca", "alabama", "slsqp"),
formulation = NULL,
w0 = NULL,
theta0 = NULL,
gamma = 0.9,
zeta = 1e07,
tau = NULL,
maxiter = 1000,
ftol = 1e08,
wtol = 5e07,
use_gradient = TRUE,
use_qp_solver = TRUE
)

Sigma 
Covariance or correlation matrix (this is the only mandatory argument). 
b 
Budget vector, i.e., the risk budgeting targets. The default is the uniform 1/N vector. 
mu 
Vector of expected returns (only needed if the expected return term is desired in the objective). 
lmd_mu 
Scalar weight to control the importance of the expected return term. 
lmd_var 
Scalar weight to control the importance of the variance term (only currently available for the SCA method). 
w_lb 
Lower bound (either a vector or a scalar) on the value of each portfolio weight. 
w_ub 
Upper bound (either a vector or a scalar) on the value of each portfolio weight. 
Cmat 
Equality constraints matrix. 
cvec 
Equality constraints vector. 
Dmat 
Inequality constraints matrix. 
dvec 
Inequality constraints vector. 
method_init 
Method to compute the vanilla solution. In case of
additional constraints or objective terms, this solution is used as
the initial point for the subsequent method. The default is

method 
Method to solve the nonvanilla formulation. The default is 
formulation 
String indicating the risk concentration formulation to be used.
It must be one of: "diag", "rcdoubleindex",
"rcoverbdoubleindex", "rcovervar vs b",
"rcovervar", "rcoversd vs btimessd",
"rc vs btimesvar", "rc vs theta", or
"rcoverb vs theta". The default is "rcoverbdoubleindex".
If 
w0 
Initial value for the portfolio weights. Default is a convex combination of the risk parity portfolio, the (uncorrelated) minimum variance portfolio, and the maximum return portfolio. 
theta0 
Initial value for theta (in case formulation uses theta). If not provided, the optimum solution for a fixed vector of portfolio weights will be used. 
gamma 
Learning rate for the SCA method. 
zeta 
Factor used to decrease the learning rate at each iteration for the SCA method. 
tau 
Regularization factor. 
maxiter 
Maximum number of iterations for the SCA loop. 
ftol 
Convergence tolerance on the objective function. 
wtol 
Convergence tolerance on the values of the portfolio weights. 
use_gradient 
This parameter is meaningful only if method is either

use_qp_solver 
Whether or not to use the general QP solver from quadprog to solve each iteration of the SCA algorithm. Default is TRUE. 
By default, the problem considered is the vanilla risk parity portfolio:
w >= 0, sum(w) = 1
, with no expected return term, and no variance term. In this case,
the problem formulation is convex and the optimal solution is guaranteed to be achieved with
a perfect risk concentration, i.e., R(w) = 0
. By default, we use the formulation by
Spinu (2013) (method_init = "cyclicalspinu"
), but the user can also select the formulation
by Roncalli et al. (2013) (method_init = "cyclicalroncalli"
).
In case of additional box constraints, expected return term, or variance term,
then the problem is nonconvex and the global optimal solution cannot be
guaranteed, just a local optimal. We use the efficient sucessive
convex approximation (SCA) method proposed in Feng & Palomar (2015),
where the user can choose among many different risk concentration
terms (through the argument formulation
), namely:
formulation = "rcdoubleindex":
sum_{i,j} (r_i  r_j)^2
formulation = "rcvstheta":
sum_{i} (r_i  theta)^2
formulation = "rcovervarvsb":
sum_{i} (r_i/r  b_i)^2
formulation = "rcoverb doubleindex":
sum_{i,j} (r_i/b_i  r_j/b_j)^2
formulation = "rcvsbtimesvar":
sum_{i} (r_i  b_i*r)^2
formulation = "rcoversd vs btimessd":
sum_{i} (r_i/sqrt(r)  b_i*sqrt(r))^2
formulation = "rcoverb vs theta":
sum_{i} (r_i/b_i  theta)^2
formulation = "rcovervar":
sum_{i} (r_i/r)^2
where r_i = w_i*(Sigma%*%w)_i
is the risk contribution and
r = t(w)%*%Sigma%*%w
is the overall risk (i.e., variance).
For more details, please check the vignette.
A list containing possibly the following elements:

Optimal portfolio vector. 

The relative risk contribution of every asset. 

Optimal value for theta (in case that it is part of the chosen formulation.) 

Sequence of values of the objective function at each iteration. 

Risk concentration term of the portfolio 

Expected return term of the portoflio 

Variance term of the portfolio 

Elapsed time recorded at every iteration. 

Boolean flag to indicate whether or not the optimization converged. 

Boolean flag to indicate whether or not the computed portfolio respects the linear constraints. 
Ze Vinicius and Daniel P. Palomar
Y. Feng, and D. P. Palomar (2015). SCRIP: Successive Convex Optimization Methods for Risk Parity Portfolio Design. IEEE Trans. on Signal Processing, vol. 63, no. 19, pp. 52855300. <https://doi.org/10.1109/TSP.2015.2452219>
F. Spinu (2013). An Algorithm for Computing Risk Parity Weights. <https://dx.doi.org/10.2139/ssrn.2297383>
T. GriveauBillion, J. Richard, and T. Roncalli (2013). A fast algorithm for computing Highdimensional risk parity portfolios. <https://arxiv.org/pdf/1311.4057.pdf>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  library(riskParityPortfolio)
# create covariance matrix
N < 5
V < matrix(rnorm(N^2), ncol = N)
Sigma < cov(V)
# risk parity portfolio
res < riskParityPortfolio(Sigma)
names(res)
#> [1] "w" "risk_contribution"
res$w
#> [1] 0.04142886 0.38873465 0.34916787 0.09124019 0.12942842
res$relative_risk_contribution
#> [1] 0.2 0.2 0.2 0.2 0.2
# risk budggeting portfolio
res < riskParityPortfolio(Sigma, b = c(0.4, 0.4, 0.1, 0.05, 0.05))
res$relative_risk_contribution
#> [1] 0.40 0.40 0.10 0.05 0.05

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.