[R-SIG-Finance] Basic Mean Variance Optimization

spencerg spencer.graves at prodsyse.com
Sun Jun 28 05:50:11 CEST 2009

      I have not seen a reply to this, so I will offer a comment. 

      First, I recommend you not worry about computer time until you 
actually know you have a problem with that.  Focus first on getting 
something to do what you want.  Then if it takes too long to compute, 
think about how to get it to run faster.  Often in R, a little thought 
and experimentation can yield big improvements in performance without 
coding anything in a compiled language like C.  If that fails, before 
you run to C, it might be wise to use tools like Rprof or system.time to 
understand which parts of your code take the most time.  For example, if 
most of the time is consumed with waiting for a data base query to 
complete, writing that in C will only give you code that is harder to 
maintain with no substantive improvement in performance.  Beyond that, 
there is the "QuantLib" project (http://quantlib.org/index.shtml) and 
the RQuantLib package to interface to some of the QuantLib code. 

      Have you seen Wuertz, et al. (2009) Portfolio Optimization with 
R/Rmetrics (www.rmetrics.org)?  

      The computation of a variance optimal portfolio might involve the 
computation of something like solve(S, r), where r = a vector of 
estimated log(returns) on the different assets, and S = the 
corresponding covariance matrix.  However, with hundreds of assets, you 
need a stable way to estimate S to avoid problems with degeneracy.  You 
could do that with a singular factor analysis algorithm.  This could be 
updated regularly using the binomial inverse theorem 
(http://en.wikipedia.org/wiki/Binomial_inverse_theorem), which is a 
standard part of a traditional Kalman filter algorithm that could be 
used to update r, S and S-inverse based on the latest information 

      Hope this helps. 

burke nersesian wrote:
> Need single period weighting for simple portfolio (minimal assumptions and constraints).
> Each asset has a variance = 1.0 and expected return = 1.0 and the covariance with each of the other assets in the portfolio is > 0.0 and < 1.0,
> (in other words, the weighting will only be dependent on the covariance matrix to produce in essence the minimum variance portfolio). 
> If possible, I would prefer each weight to be positive. The portfolio contains hundreds of assets and must be calculated thousands of times so R seems too slow for the job.
> Does anyone know of any C function in say, GSL, BLAS or any other library that takes a Convariance Matrix as input and returns a weight vector as output?
> The solution doesn't have to be guaranteed to be robust, if it dominates the equal weighted portfolio that's sufficient.
> Any ideas will help, thank you all so much!
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.

More information about the R-SIG-Finance mailing list