Skip to content
Prev 14039 / 15274 Next

CVaR and Penalty Augmented objective function

Hi Michael,

thanks for your reply, I apologize for the not full clarity of my question.
In the following, I try to report a full example.

#Library
*library(PerformanceAnalytics)*
*library(PortfolioAnalytics)*

#Returns data present in "PortfolioAnalytics"
*data(indexes)*
*indexes <- indexes[,1:4]*

#New Portfolio Object
*Wcons <- portfolio.spec(assets=colnames(indexes))*

#Add box constraints
*Wcons <- add.constraint(portfolio=Wcons, type='box', min=0, max=1)*

#Add the full investment constraint
*Wcons <- add.constraint(portfolio=Wcons, type="full_investment")*

#Add Objective specification: VaR with default parameter for vector "mu"
(EXAMPLE 1)
*VaRObjSpec <- add.objective(portfolio=Wcons, type="risk", name="VaR",
arguments=list(p=0.95), enabled=TRUE)*

#The value of the objective function is:
*constrained_objective(w=rep(1/4,4), R=indexes, portfolio=VaRObjSpec)    #* VaR
*0.0499467*

#This is the VaR of the equal-weight portfolio as computed by the function
VaR in the PerformanceAnalytics package.
*VaRout <- VaR(indexes, weights=rep(1/4,4), p=0.95,
portfolio_method="component")*
*VaRout$MVaR       # *[1,]* 0.0499467*

Now, I repet the VaR example with a user-defined vector for the parameter
"mu".

#User-defined vector "mu"
*myMu = rep(0.01, 4)*

#Add Objective specification: VaR with user-defined parameter for vector
"mu"
*myVaRObjSpec <- add.objective(portfolio=Wcons, type="risk", name="VaR",
arguments=list(p=0.95, mu=myMu), enabled=TRUE)*

#The value of the objective function is:
*constrained_objective(w=rep(1/4,4), R=indexes, portfolio=myVaRObjSpec)
 #* VaR *0.04638622*

#This is the VaR of the equal-weight portfolio as computed by the function
VaR in the PerformanceAnalytics package with *mu=myMu.*
*myVaRout <- VaR(indexes, weights=rep(1/4,4),
p=0.95, mu=myMu, portfolio_method="component")*
*myVaRout$MVaR       # *[1,]* 0.04638622*

So, using the default and user-defined parameter for "mu" there is
corrispondence between constrained_objective and the function VaR of
PerformanceAnalytics package.
I repet the example but now adding CVaR as risk objective in Wcons
portfolio.

#Add Objective specification: CVaR with default parameter for vector "mu"
(EXAMPLE 2)
*CVaRObjSpec <- add.objective(portfolio=Wcons, type="risk", name="CVaR",
arguments=list(p=0.95), enabled=TRUE)*

#The value of the objective function is:
*constrained_objective(w=rep(1/4,4), R=indexes, portfolio=CVaRObjSpec)    #* ES
*0.1253199*

#This is the CVaR of the equal-weight portfolio as computed by the function
ES in the PerformanceAnalytics package.
*CVaRout <- ES(indexes, weights=rep(1/4,4), p=0.95,
portfolio_method="component")*
*CVaRout$MES       # *[1,]* 0.1253199*

Now, I repet the CVaR example with a user-defined vector for the parameter
"mu".

#User-defined vector "mu"
*myMu = rep(0.01, 4)*

#Add Objective specification: CVaR with user-defined parameter for vector
"mu"
*myCVaRObjSpec <- add.objective(portfolio=Wcons, type="risk", name="CVaR",
arguments=list(p=0.95, mu=myMu), enabled=TRUE)*

#The value of the objective function is:
*constrained_objective(w=rep(1/4,4), R=indexes, portfolio=myCVaRObjSpec)
 #* ES *0.1217594*

#This should be the CVaR of the equal-weight portfolio as computed by the
function ES in the PerformanceAnalytics package with *mu=myMu.*
*myCVaRout <- ES(indexes, weights=rep(1/4,4),
p=0.95, mu=myMu, portfolio_method="component")*
*myCVaRout$MES       # *[1,]* 0.1235878*

In this case, using the user-defined parameter for "mu" there is no
corrispondence between the value of constrained_objective (0.1217594*) *and
the result of function ES of PerformanceAnalytics package (0.1235878). Why
there is no match in this case?
This not the case for the matrix parameter (for portfolio) "sigma": if I
use a user-defined sigma matrix, there is always corrispondence (without,
obviosly, costraints that augment the penalty augmented objective
function) between the value of constrained_objective (with VaR/CVaR risk
objective) and the result of function VaR/ES of PerformanceAnalytics
package.

I hope my example is clear enough to illustrate the question.
Thanks a lot for your attention.
Marco


On Wed, Oct 12, 2016 at 1:55 AM, Michael Weylandt <
michael.weylandt at gmail.com> wrote: