0

I am using solve.QP in quadprog package of R to solve the classical mean-variance optimization problem. In my understanding, the output component "value" means the variance of the optimized portfolio and many codes for the mean-variance optimization posted online also show that sqrt(sol$value) is the standard deviation of the optimized portfolio.

However, when I use solve.QP to solve a simple mean-variance optimization, sol$value provides me a negative value which is also different from the value calculated by using the portfolio variance function: w%*%covariance%*%t(w). I was trying to search online for the definition or the algorithm for sol$value but unfortunately I could not find detailed description. The R Documentation for quadprog only states that "value" is "scalar, the value of the quadratic function at the solution".

So could anyone who is familiar with solve.QP could tell me the exact definition or algorithm of sol$value. And if my understanding about it is correct, namely the variance of the optimized portfolio, then what is the possible reason that solve.QP provides me negative values for sol$value.

cryo111
  • 4,444
  • 1
  • 15
  • 37
Dr_BUG
  • 33
  • 5

1 Answers1

0

solve.QP is a general solver for quadratic optimization problems. So you have to be aware of which quadratic problem you are actually solving. Since you are dealing with mean-variance portfolio optimization, your's is probably like

 wopt=argmax_w(t(w)%*%r-lambda*t(w)%*%C%*%w)

with r, w, lambda and C being the expected return, the portfolio weights, the risk aversion parameter and the covariance matrix, respectively. wopt is the optimal weights vector. sol$value will give you the value of your objective function at wopt.

Some other mean-variance formulations try to maximize t(w)%*%r with a constraint on the risk (i.e. variance). For both formulations sol$value will not be the variance t(wopt)%*%C %*%wopt. Maybe you have been looking at minimum variance portfolio optimizations? There your variance would be the objective function.

Anyway, you will get the variance of your mean-variance optimization via

t(sol$solution)$%*%C%*%sol$solution

because wopt=sol$solution.

cryo111
  • 4,444
  • 1
  • 15
  • 37
  • Thank you very much. I think you have answered my question and I have misunderstood the meaning of the output value. – Dr_BUG Mar 26 '16 at 03:56
  • @Dr_BUG If you think that this is an appropriate answer, you can accept it via clicking on the checkmark. – cryo111 Mar 28 '16 at 16:58