[R-SIG-Finance] Failure of solve.QP in portfolio modeling

Ilya Kipnis ilya.kipnis at gmail.com
Tue Sep 22 15:50:15 CEST 2015


Because you can't invert a matrix with more features than observations. IE
if you have 50 stocks but only use 26 weekly return data points, you can't
invert that covariance matrix because it's not positive semi-definite. You
may want to try my Constrained Critical Line algorithm.

https://quantstrattrader.wordpress.com/2015/06/05/momentum-markowitz-and-solving-rank-deficient-covariance-matrices-the-constrained-critical-line-algorithm/



On Tue, Sep 22, 2015 at 9:37 AM, aschmid1 <aschmid1 at stevens.edu> wrote:

> Hi everyone,
> I'm trying to estimate optimal Markowitz portfolio weights for a list of
> stocks chosen upon some criterion using solve.QP from quadprog library.
> When the number of stocks N reaches some limit, I get a message "matrix D
> in quadratic function is not positive definite." For example, if I
> rebalance every 6 weeks (which implies that variance is calculated for
> 6-week interval prior to the period for which I calculate portfolio
> weights), I can get solution for 25>=N<50. For 12-week interval, solution
> exists for 50>=N<100, and for 24-week interval, I can get solution for
> N=100. My attempt to remedy this problem with Higham's method doesn't help.
> I'll greatly appreciate you input: first, why this may happen (can there be
> lack of local minimum?), and second, whether there are R solvers that may
> need only semi positive definite matrix.
>
> Thanks! Alec
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>

	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list