# Equal Risk Contribution in Portfolio Analytics r pkg

I am trying to estimate the weights of an equal risk portfolio using the PortfolioAnalytics package in r.

To start with, I have tried to redo the example provided in the portfolio vignette. The code is given below,

[![library(PortfolioAnalytics)
library(DEoptim)
library(ROI)
require(ROI.plugin.glpk)
data(edhec)
R <- edhec$, 1:6$
colnames(R) <- c("CA", "CTAG", "DS", "EM", "EQMN", "ED")
funds <- colnames(R)
# Create an initial portfolio object with leverage and box constraints
init <- portfolio.spec(assets=funds)
min_sum=0.99, max_sum=1.01)
init <- add.constraint(portfolio=init, type="box", min=0.05, max=0.65)
init$constraints$$$2$$$$min <- rep(0, 6)
init$constraints$$$2$$$$max <- rep(1, 6)
arguments=list(p=0.95))
name="ETL", min_concentration=TRUE,
arguments=list(p=0.95))
opt_eq_meanETL <- optimize.portfolio(R=R, portfolio=eq_meanETL,
optimize_method="DEoptim",
search_size=2000,
trace=TRUE, traceDE=5)]]


The risk contribution is given in the image. My question is why is there a difference in the % risk contribution for all the portfolios. isn't the ERC portfolio produces the same contribution for each of the assets in the portfolio.

Thanks.

• (1) I don't know this package (2) you have box constraints on the portfolio weights. Are any of these constraint binding? What happens if you loosen these contraints, do the ERC contribs become equal? – noob2 Apr 12 '17 at 12:16
• Box constraints are not binding here, also the box constraints are relaxed to long only in the code. – Sadhak Apr 12 '17 at 13:45
• If your goal is to create an ERC portfolio, the FRAPO package might be much easier to use. I use it myself regularly. It works quite well. – pteetor Jun 20 '18 at 22:22