What's the best package for SOCP in R?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

What's the best package for SOCP in R?

Ilya Kipnis-2
I was reading the following paper from Adam Butler:

http://www.bpgassociates.com/docs/Adaptive-Asset-Allocation-A-Primer.pdf

I saw the example on page 26, namely one with an 8% annualized volatility target.

I was wondering if there's a go-to package among the R/Finance community to solve problems of the type:

max w'r
s.t.
w'Sw = target
0 <= w_i <= 1 for all i
Sum(i=1...n)w_i = 1

I know that quadprog solves problems of the form of
min -w'r + lambda*w'Sw
s.t.
0 <= w_i <= 1 for all i
Sum(i=1...n)w_i = 1

I was wondering if there was a go-to package for SOCP so that I could solve the first type of problem without needing to call a global optimizer.

Thanks a lot.

-Ilya

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What's the best package for SOCP in R?

alexios
Ilya, Bernhard's cccp package should be the definitive socp package in R
now.
cran.r-project.org/package=cccp

-Alexios

On 08/07/2015 18:37, Ilya Kipnis wrote:

> I was reading the following paper from Adam Butler:
>
> http://www.bpgassociates.com/docs/Adaptive-Asset-Allocation-A-Primer.pdf
>
> I saw the example on page 26, namely one with an 8% annualized volatility target.
>
> I was wondering if there's a go-to package among the R/Finance community to solve problems of the type:
>
> max w'r
> s.t.
> w'Sw = target
> 0 <= w_i <= 1 for all i
> Sum(i=1...n)w_i = 1
>
> I know that quadprog solves problems of the form of
> min -w'r + lambda*w'Sw
> s.t.
> 0 <= w_i <= 1 for all i
> Sum(i=1...n)w_i = 1
>
> I was wondering if there was a go-to package for SOCP so that I could solve the first type of problem without needing to call a global optimizer.
>
> Thanks a lot.
>
> -Ilya
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] 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.
>
>

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What's the best package for SOCP in R?

Pfaff, Bernhard Dr.
Dear Ilya & Alexios,

given that the Alexios played the ball into my court, please find below a toy example to your problem:
(the parma package is loaded for the data set)

library(parma)
library(cccp)
data("etfdata")
R = etfdata/lag(etfdata)-1
R = na.omit(R * 100)
N <- ncol(R)
S = cov(coredata(R))
Se <- eigen(S)
Sr <- Se$vectors %*% diag(sqrt(Se$values)) %*% t(Se$vectors)
all.equal(Sr %*% Sr, S, check.attributes = FALSE)
mu <- colMeans(R)
q <- -mu
## Formulating constraints
## Non-negativity & SOC
nvec <- rep(0, N)
nno1 <- nnoc(G = -diag(N), h = nvec)
soc1 <- socc(F = Sr, g = nvec, d = nvec, f = 1.5)
## Budget constraint
A <- matrix(rep(1, N), nrow = 1, ncol = N)
b <- matrix(1, nrow = 1, ncol = 1)
## Solving problem
Popt <- cccp(q = q, A = A, b = b,
             cList = list(nno1, soc1))
w <- getx(Popt)
## checking
all(w > 0)
all.equal(sum(w), 1.0)
(retmax <- -getstate(Popt)["pobj"])
(sdrisk <- drop(sqrt(crossprod(w, S) %*% w)))

Best wishes,
Bernhard


-----Ursprüngliche Nachricht-----
Von: R-SIG-Finance [mailto:[hidden email]] Im Auftrag von alexios
Gesendet: Donnerstag, 9. Juli 2015 15:17
An: Ilya Kipnis; [hidden email]
Betreff: Re: [R-SIG-Finance] What's the best package for SOCP in R?

Ilya, Bernhard's cccp package should be the definitive socp package in R now.
cran.r-project.org/package=cccp

-Alexios

On 08/07/2015 18:37, Ilya Kipnis wrote:

> I was reading the following paper from Adam Butler:
>
> http://www.bpgassociates.com/docs/Adaptive-Asset-Allocation-A-Primer.p
> df
>
> I saw the example on page 26, namely one with an 8% annualized volatility target.
>
> I was wondering if there's a go-to package among the R/Finance community to solve problems of the type:
>
> max w'r
> s.t.
> w'Sw = target
> 0 <= w_i <= 1 for all i
> Sum(i=1...n)w_i = 1
>
> I know that quadprog solves problems of the form of min -w'r +
> lambda*w'Sw s.t.
> 0 <= w_i <= 1 for all i
> Sum(i=1...n)w_i = 1
>
> I was wondering if there was a go-to package for SOCP so that I could solve the first type of problem without needing to call a global optimizer.
>
> Thanks a lot.
>
> -Ilya
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] 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.
>
>

_______________________________________________
[hidden email] 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.
*****************************************************************
Confidentiality Note: The information contained in this ...{{dropped:10}}

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What's the best package for SOCP in R?

Mark Knecht
On Thu, Jul 9, 2015 at 9:03 AM, Pfaff, Bernhard Dr.
<[hidden email]> wrote:
> Dear Ilya & Alexios,
>
> given that the Alexios played the ball into my court, please find below a toy example to your problem:
> (the parma package is loaded for the data set)
>
> library(parma)
> library(cccp)


Sadly, library(parma) works its way down to Rglpk which doesn't build
coming from CRAN. Is there a better place to get that?

* installing *source* package ‘Rglpk’ ...
** package ‘Rglpk’ successfully unpacked and MD5 sums checked
** libs
/bin/sh: line 0: cd: GLPK: No such file or directory
Makevars:10: recipe for target 'GLPK.ts' failed
make: *** [GLPK.ts] Error 1
ERROR: compilation failed for package ‘Rglpk’

Thanks,
Mark

_______________________________________________
[hidden email] 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.
markknecht@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: What's the best package for SOCP in R?

Mark Knecht
On Fri, Jul 10, 2015 at 6:58 AM, Mark Knecht <[hidden email]> wrote:

> On Thu, Jul 9, 2015 at 9:03 AM, Pfaff, Bernhard Dr.
> <[hidden email]> wrote:
>> Dear Ilya & Alexios,
>>
>> given that the Alexios played the ball into my court, please find below a toy example to your problem:
>> (the parma package is loaded for the data set)
>>
>> library(parma)
>> library(cccp)
>
>
> Sadly, library(parma) works its way down to Rglpk which doesn't build
> coming from CRAN. Is there a better place to get that?
>
> * installing *source* package ‘Rglpk’ ...
> ** package ‘Rglpk’ successfully unpacked and MD5 sums checked
> ** libs
> /bin/sh: line 0: cd: GLPK: No such file or directory
> Makevars:10: recipe for target 'GLPK.ts' failed
> make: *** [GLPK.ts] Error 1
> ERROR: compilation failed for package ‘Rglpk’
>
> Thanks,
> Mark

Rglpk requires that I install glpk in Linux first. With that done the
example runs.

Thanks,
Mark

_______________________________________________
[hidden email] 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.
markknecht@gmail.com