[R] Help with Portfolio Optmization

R. Michael Weylandt michael.weylandt at gmail.com
Mon Jul 23 19:59:26 CEST 2012


On Mon, Jul 23, 2012 at 6:24 AM, MaheshT <mahesh.msmf at gmail.com> wrote:
> Hi,
>
> I need some help with Portfolio Optimization problem. I am trying to find
> the minimum variance portfolio subjected to constraints on weights like
>
> /x1< w1 <x2
> x3< w2 <x4</i>
>
> I need help with solving for the minimum variance portfolio as solve.QP
> doesn't allow me to specify the lower boundaries.

Well, no: you have to be a little smarter about it though: try to walk
through the example in ?solve.QP again.

The trick is to split the conditions and then note that

a < x < b -->
a < x & x < b -->
-x < -a & x < b -->

both of which are now of the form constant*x < bound so you can wrap
them up in a single matrix.

c(-1, 1) * x < c(-a, b)

Incidentally, this has already been solved for you here (inter alia):

https://systematicinvestor.wordpress.com/2011/12/13/backtesting-minimum-variance-portfolios/

For this sort of problem, you might also get better help on the
R-SIG-Finance lists.

Cheers,
Michael

>
> Thanks
> Mahesh
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Help-with-Portfolio-Optmization-tp4637425.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list