# Why can't I take the Value at Risk “VaR” as a a risk objective in PerformanceAnalytics? (it does work for "ES)

I am currently playing around with PortfolioAnalytics package in R and some data and I am aiming to create different portfolios with different VaR. However, I am struggling first of all, add.objective() is not taking VaR as a risk measure - it does work with "ES".

I am unsure if I am misunderstanding something, but if I want to allow for more risk in the risk objective I assumed that i can just set a higher p (eg p=0.2 instead of p=0.05) - below some code for clarification:

#test
data(edhec)
returns <- edhec[, 1:4]
colnames(returns) <- c("CA", "CTAG", "DS", "EM")
fund.names <- colnames(returns)

pfx <- portfolio.spec(assets=fund.names)
pfx <- add.constraint(portfolio=pfx, type="full_investment")
pfx <- add.constraint(portfolio=pfx, type="long_only")
pfx <- add.constraint(portfolio=pfx, type="box",
min=0.0,
max=0.6)
pfx <- add.objective(portfolio=pfx, type="return", name="mean", return_target= 0.05)
type='risk',
name='ES',
arguments= list(p=0.05))**

bt_pfx <- optimize.portfolio.rebalancing(R=returns, portfolio= pfx ,
optimize_method="ROI",
rebalance_on="years",
trace=  TRUE,
training_period= NULL,
rolling_window = NULL)

chart.Weights(bt_pfx,  ylim=c(0, 1),col = rainbow12equal, main="PFX Weights")

write.csv(extractObjectiveMeasures(bt_pfx))


Furthermore with a higher p I assumed that the returns should be higher as well, however the opposite is the case.

So I am not sure if I am misunderstanding something or is there an other option to allow for more risk in a portfolio?

• In the example here rdocumentation.org/packages/PortfolioAnalytics/versions/1.1.0/… they use p=0.925 so perhaps their interpretation of p is the opposite of yours. The old $\alpha$ vs $1-\alpha$ confusion. – Alex C May 2 at 1:24
• I've tried that as well, leasing to same results. Seems like R recognises both methods 0.05 or 0.95. – brko May 2 at 5:41