问题
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