0

I'm using the ROI package in R and am trying to setup an optimization with a quadratic objective function.

It looks like the default function is of the form: 1/2 x^T Q x+ C^T x. I'd like to alter this function so that I'm optimizing to maximize: x.V/(x^T Q x) Where v is the sq root of the diagonals for the covariance matrix Q.

Here is an example I have:

C1 <- matrix(runif(100, min=10, max=100),nrow=10)
C <- as.matrix(forceSymmetric(C1))
V <- sqrt(diag(C))
full_invest <- L_constraint(rep(1, 10), "==", 1)

qcqp <- OP(Q_objective(Q = C, L = rep(0, 10)),
          full_invest,
          bounds = V_bound(ui = seq_len(10), ub = rep(0.25, 10)),
          max = FALSE)
sol1 <- ROI_solve(qcqp, solver = "alabama", start = rep(1/10, 10))

In this example the optimization is minimizing 1/2 x^T Q x+ C^T x How can I set this up so that my optimization function includes the sum of the product of x and V.

GT213
  • 89
  • 6
  • Note that the Sharpe ratio can be reformulated as a standard convex QP. That is what is usually being used. SR is slightly different than what you propose. – Erwin Kalvelagen Jun 22 '23 at 02:09
  • I would try with the **CVXR** package. – Stéphane Laurent Jun 22 '23 at 08:01
  • I don't think it is convex. – Erwin Kalvelagen Jun 22 '23 at 09:31
  • For now I've come up with a solution using an F_objective instead of Q_objective in the optimization, which seems to work but need to do some more testing: `dR <- function(w, covMatrix) { weightedAvgVol <- sum(w * sqrt(diag(covMatrix))) portfolioVariance <- (w %*% covMatrix %*% w)[1,1] - 1 * weightedAvgVol / sqrt(portfolioVariance) } wrapper <- function(x) dR(x, C) o <- OP(F_objective(F = wrapper, n = (10)),` – GT213 Jun 22 '23 at 13:44

0 Answers0