[GSoC-PortA] Issue passing "clean"?

Ross Bennett rossbennett34 at gmail.com
Fri Oct 11 07:16:43 CEST 2013


Peter,

In commit r3216 I made revisions so that the ROI solvers recognize clean
and any other arguments in the $arguments slot in each objective. I am
really glad you brought this up because I realized that nothing in the
$arguments slot was being recognized for optimize_method="ROI"... this was
something I overlooked. This is corrected and cleaned returns can now be
used with optimize_method="ROI" for the QP/LP problems. I also added
"StdDev" as a valid objective name, but still use "var" to calculate the
variance-covariance matrix used in the objective function.

Regarding your example above with the min SD portfolio having a lower mETL
than the min mETL. I'm not 100% sure on this, but it could depend on if/how
you call constrained_objective to calculate the objective measures. For
example, the results of the minimum ETL portfolio with ROI will be
different than the minimum mETL portfolio with RP. The LP formulation to
minimize ETL uses empirical returns data whereas the optimization with
random portfolios uses modified ETL by default which will likely result in
different optimal weights. It is a case of comparing "apples to oranges".

Attached is a quick script demonstrating this. Relevant outputs below.

> # Minimum ETL using ROI
> optROI <- optimize.portfolio(R=ret, portfolio=tmp1,
optimize_method="ROI", trace=TRUE)
[1] 0.0833
> extractObjectiveMeasures(optROI)
$ES
[1] 0.01718848

> # Use constrained_objective to calculate mETL with the optimal weights
from optROI
> constrained_objective(w=optROI$weights, R=ret, portfolio=tmp1,
trace=TRUE)$objective_measures
$ES
         [,1]
ES 0.01761023
attr(,"names")
[1] "ES"

> # minimum mETL with random portfolios
> optRP <- optimize.portfolio(R=ret, portfolio=tmp1,
optimize_method="random", search_size=2000, trace=TRUE)
> extractObjectiveMeasures(optRP)
$ES
         [,1]
ES 0.01740961
attr(,"names")
[1] "ES"

Ross



On Wed, Oct 9, 2013 at 3:20 PM, Ross Bennett <rossbennett34 at gmail.com>wrote:

> Peter,
>
> Thanks for the detailed description of what is going on. I will be able to
> dig into this deeper tomorrow afternoon, but here are some initial comments.
>
> See comments in-line.
>
>
>
> On Wed, Oct 9, 2013 at 1:38 PM, Peter Carl <peter at braverock.com> wrote:
>
>> Ross,
>>
>> I'm running into the following:
>>
>> > buoys.portfmeas
>>                 Mean      StdDev       mETL
>> MinSD    0.005435103 0.009286484 0.01357282
>> MinmETL  0.005846839 0.011196709 0.01371471
>>
>> Note that the minimum standard deviation portfolio has a lower mETL than
>> the Min mETL portfolio.  Both were calculated with ROI.
>>
>> MinSD.portf <- add.objective(portfolio=init.portf,
>>   type="risk", # the kind of objective this is
>>   name="var", # name of the function
>>   arguments=list(clean=clean)
>> )
>>
>> > MinSD.ROI<-optimize.portfolio(R=R,
>> +   portfolio=MinSD.portf,
>> +   optimize_method='ROI'
>> +   )
>> Warning message:
>> In constrained_objective(w = weights, R = R, portfolio, trace = TRUE,  :
>>   some arguments stored for var do not match
>>
>> That warning is true, "var" doesn't take that list of arguments, including
>> "clean".  But when I use name="StdDev" in the portfolio construction, I
>> get the following error:
>>
>> Error in optimize.portfolio(R = R, portfolio = MinSD.portf,
>> optimize_method = "ROI") :
>>   ROI only solves mean, var, or sample ETL/ES/CVaR type business
>> objectives, choose a different optimize_method.
>> In addition: Warning message:
>> In is.na(le) : is.na() applied to non-(list or vector) of type 'NULL'
>>
>> So the first issue is to map "StdDev" into the list of acceptable
>> functions for that solver.  It should then accept the "clean" argument and
>> that should fix part of the issue.
>>
>
> Got it, I'll add functionality for StdDev to be accepted by the ROI
> solvers. I'll have to add StdDev, but still use "var" to calculate the
> variance-covariance matrix used in the objective function. I will also have
> to detect the "clean" argument so that the cleaned returns are used to
> calculate the variance-covariance matrix.
>
>
>>
>> The second issue is that the Min mETL portfolio being identified isn't
>> being plotted as the minimum mETL portfolio being identified in the cloud
>> of random portfolios.  This is the same issue I saw earlier that turned
>> out to be related to "clean" not being applied consistently across
>> objectives.
>>
>> In this case, it should be:
>> p=1-1/12
>> clean="boudt"
>> MinmETL.portf <- add.objective(portfolio=init.portf,
>>   type="risk", # the kind of objective this is
>>   name="ES", # the function to minimize
>>   arguments=list(p=p, clean=clean)
>> )
>>
>> > MinmETL.ROI<-optimize.portfolio(R=R,
>> +   portfolio=MinmETL.portf,
>> +   optimize_method='ROI',
>> +   trace=TRUE, verbose=TRUE
>> +   )
>> Warning message:
>> In is.na(le) : is.na() applied to non-(list or vector) of type 'NULL'
>>
>> I'm not sure if the warning is related.  But I'm wondering if "clean" is
>> getting passed into "ES" with ROI.  If it isn't, then the optimizer is
>> likely selecting the wrong portfolio.  Could you take a look at this when
>> you have a moment?
>>
>
> It could be related, in general, the "clean" argument is not passed to
> ROI. I should be able to make some changes so that the cleaned returns are
> used for the ROI solvers. I'll take a closer look and report back with my
> findings.
>
>
>>
>> Thanks,
>>
>> pcc
>> --
>> Peter Carl
>> http://www.braverock.com/peter
>>
>>
>> _______________________________________________
>> GSoC-PortA mailing list
>> GSoC-PortA at lists.r-forge.r-project.org
>> http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/gsoc-porta
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/gsoc-porta/attachments/20131010/8357af2a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testing_ETL_vs_mETL.R
Type: application/octet-stream
Size: 1233 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/gsoc-porta/attachments/20131010/8357af2a/attachment.obj>


More information about the GSoC-PortA mailing list