[R-SIG-Finance] mean-(scalar) portfolio optimization
Brian G. Peterson
brian at braverock.com
Thu Aug 24 16:01:04 CEST 2006
On Thursday 24 August 2006 05:38, Patrick Burns wrote:
> If you are serious about portfolio optimization, then
> you need to confront integer constraints such as a
> maximum number of assets to trade and a maximum
> number of assets in the portfolio. The "nice" optimization
> algorithms are going to fail in this case.
I understand that completely unconstrained optimization approaches are
dangerous because of local minima and other problems. All the papers
that I've referenced use some constraints, at least on the weighting
vector, and often on number of instruments.
I'm working in a pretty contrained universe already. I'll never have
several thousand instruments in a portfolio, for example. The application
that I'm looking for is for a strategic asset allocation (for example in
a portfolio of funds, or in a sector or industry portfolio), rebalanced
relatively infrequently, so some of the constraints that you mention
would have been implied by my universe. I use different approaches for
frequent trading or tactical allocation.
I've consolidated the references below in GNU format, as I think it will
make it easier for others to find and discuss these useful papers.
So, back to the goals of my original post, how best to solve the
constrained mean-(scalar) portfolio optimization problem in R...
In general, they all fall into a class of problems that may be simply
let w' be the desired portfolio weights
let R be a set of returns for various instruments
solve for a weighting vector w such that risk is minimized
w' = min(risk(R))
solve for a weighting vector w such that return is maximized over
risk budget rb
w'=max(mean(R)) such that risk(R) < rb
and other similar formulations. The details on all these a[proaches are of
course more complicated, and what we're trying to get...
It does not look like simple quadratic methods are appropriate for a
solution using a scalar measure of risk. So, solve.QP is out. If anyone
disagrees with this, I'd love to talk about it.
'optim' may be appropriate, if we have a good way of estimating the
gradient, and if it can allow for reasonable constraints. Rodriguez(5)
discusses methods of estimating the gradient, and 'constrOptim' may be
able to constrain the space appropriately, I don't have any opinion on
whether this is a workable approach, community input solicited.
Gilli(1) recommends a constrained brute force approach to estimating.
Since I am not completely familiar with this paper, having not really
evaluated brute force methods, I'm not sure what the best approach in R
would be. I think that one could use 'nlm' or 'constrOptim' to model an
approach similar to the one Gilli proposes, but input from Patrick or
anyone else who has tried to implement Gilli would be appreciated.
Martellini(4) and Rockinger(2) solve a four-moment CAPM using a
differentiable series of linear equations. So, I believe that a
'simplex' or 'glm' or 'gls' approach could be used to go down that path.
Ma(3) approaches the problem from a Quantile Regression angle. I think
that this approach is quite promising, and could be solved for in R using
I believe that all of these approaches have theoretical merit. Like any
approach, they all have drawbacks and limitations.
I'd like to avoid spending a bunch of trial and error time implementing
each of these methods in turn. Some pointers specifically on
implementation approaches in R would be vastly appreciated. Thoughts from
anyone else who has implemented portfolio optimization in R would be very
valuable. I'll continue to share what I come up with.
Gilli, M., et. al., "A Data-Driven Optimization Heuristic for Downside
Risk Minimization" . Swiss Finance Institute Research Paper No. 06-2
Available at SSRN: http://ssrn.com/abstract=910233
Jondeau, E. and Rockinger, M.," Optimal Portfolio Allocation Under Higher
Moments" Bank of France, 2004 Available at:
Ma, L. and Pohlman, L. "Return Forecasts and Optimal Portfolio
Construction: A Quantile Regression Approach" Available at:
Martellini, Vaissié, and Ziemann "Investing in Hedge Funds: Adding Value
through Active Style Allocation Decisions" EDHEC 2005. Available at:
Rodriguez, G. ,"Portfolio Optimization w/ Quantile-based Risk Measures",
MIT, 1999. Available at http://citeseer.ist.psu.edu/lemus99portfolio.html
> Brian G. Peterson wrote:
> >>Brian G. Peterson wrote:
> >>>The R function solve.QP is used by several authors to solve classic
> >>>Markowitz mean-variance optimization using solve.QP and a covariance
> >>>Many other classes of portfolio optimization solve for the weighting
> >>>vector w using a scalar measure of risk, such as VaR, Sortino,
> >>> Omega, etc.
> >>>Basically, this class of problems could be expressed as:
> >>>let w' be the desired portfolio weights
> >>>let R be a set of returns for various instruments
> >>>solve for a weighting vector w such that risk is minimized
> >>>w' = min(risk(R))
> >>>solve for a weighting vector w such that return is maximized over
> >>> risk budget y
> >>>w'=max(mean(R)) such that risk(R)<.05
> >>>and other similar formulations.
> >>>solve.QP does not appear to be appropriate for these kinds of
> >>>optimization. The functions 'optim' and 'optimize' seem to return
> >>>scalar values, solving only for a single minima or maxima, and not
> >>>for the vector (although I may be misunderstanding them).
> >>>Does anyone have any pointers on how you might go about solving
> >>> these kinds of optimization problems in R? I apologize if this is
> >>> a simple problem that I haven't been able to find a reference for
> >>> online. I will happily post the optimizer code once it's working.
> >On Wednesday 23 August 2006 12:01, Patrick Burns wrote:
> >>You are misunderstanding 'optim' -- it optimizes
> >>a function over one argument but that argument can be
> >>a vector.
> >Thanks for correcting me on 'optim'. I'll take a closer look. I am
> > aware of the problem of finding *a* minima, but not necessarily the
> > best minima, in a series that could have more than one.
> >>However the utilities that you mention are hard to
> >>optimize. See 'A Data-driven optimization heuristic
> >>for downside risk minimization' by Gilli et al.
> >This paper basically advocates a constrained brute-force estimation.
> >I'd like to avoid that if possible, for reasons of computational
> >complexity. That's clearly not the only approach being advocated in
> > the current literature.
> >This one:
> >Portfolio Optimization w/ Quantile-based Risk Measures
> >Gerardo Jose Lemus Rodriguez, MIT, 1999
> >does a pretty good comparison of quantile-based, gradient methods, and
> >non-gradient methods, and looks like it has some good prototypes that
> >could be implemented. From this paper, it looks like a non-parametric
> >gradient estimator should give acceptable results with minimal
> >computational effort.
> >This paper:
> >05-12-19.1651 Investing in Hedge Funds: Adding Value through Active
> > Style Allocation Decisions
> >Martellini, Vaissié, and Ziemann 2005
> >uses w' = min(VaR(95%)) with constraints on weight
> >to good effect to establish strategic weighting, but does not provide
> > the math for solving directly for the weighting vector, only expected
> > return under a a four-moment CAPM model, or a four-moment Taylor
> > expansion that could be transformed and solved for w'.
> >This paper:
> >Optimal Portfolio Allocation Under Higher Moments
> >solves for a differentiable series of nonlinear equations into a four
> >moment CAPM model. This is another relatively intensive approach that
> >I'd like to avoid.
> >I could reference other papers, but I think that these are
> > representative. I was hoping to spark some discussion of optimization
> > around scalar measures of risk such as VaR, Omega, or Expected
> > Shortfall.
> >I'm hoping that others on this list have done something similar and
> > would be willing to point me more directly towards implementation in
> > R, as estimation and optimization function in R are still pretty
> > foreign to me.
> > - Brian
More information about the R-SIG-Finance