SOCP Solver Error for fPortoflio using solveRsocp

与世无争的帅哥 提交于 2019-12-02 13:38:33

问题


I would like to use an R SOCP solver to get similar results to the following paper: http://www.optimization-online.org/DB_FILE/2014/05/4366.pdf

And doing a bit of googling, it seems like it used to be part of fPortfolioSolver, but that package looks like it no longer exists....

And this looks like how it used to be implemented...

https://stat.ethz.ch/pipermail/r-sig-finance/2010q2/006074.html

The solver still sort of exists here:

https://r-forge.r-project.org/scm/viewvc.php/pkg/fPortfolio/R/solveRsocp.R?view=markup&root=rmetrics&pathrev=3507

But it should be referencing the Rsocp package available here:

https://r-forge.r-project.org/R/?group_id=156

However there are a few errors that need to help it to get it to work

e.g. line 117 needs to change to

Rsocp:::.SqrtMatrix

and line 165 needs to change to

optim <- Rsocp::socp(f, A, b, C, d, N, x, z, w, control)

but when running the following code, I get the following error...

lppData=100*LPP2005.RET[,1:6] 
maxRetSpec=portfolioSpec() 
setTargetRisk(maxRetSpec)=0.07 
setSolver(maxRetSpec)="solveRsocp"
efficientPortfolio(data=lppData, spec=maxRetSpec, constraints="LongOnly") 

 Error in .socp.phase1(f, A, b, N, control) : Phase 1 failed, alpha>=0 

traceback()
6 stop("Phase 1 failed, alpha>=0") 
5 .socp.phase1(f, A, b, N, control) 
4 Rsocp::socp(f, A, b, C, d, N, x, z, w, control) at solveRsocp.R#165
3 .rsocp(f = args$f, A = args$A, b = args$b, C = args$C, d = args$d, 
N = args$N, targetRisk = args$targetRisk, mu = args$mu, Scale = args$Scale) at    solveRsocp.R#64
2 Solver(data, spec, constraints) 
1 efficientPortfolio(data = lppData, spec = maxRetSpec, constraints = "LongOnly") 

Any help to solve this situation so that the solver works and that the paper could be replicated would be greatly be appreciated...


回答1:


Error Fixed by changing

setTargetRisk(maxRetSpec)=0.07 

to

setTargetRisk(maxRetSpec)=0.1


来源:https://stackoverflow.com/questions/24509960/socp-solver-error-for-fportoflio-using-solversocp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!