[R-SIG-Finance] quadprog error?
none
investorcurious at gmail.com
Fri Mar 16 01:44:03 CET 2012
I want to report a following error with quadprog. The solve.QP function
finds a solution to the problem below that violates the last equality
constraint. I tried to solve the same problem using ipop from kernlab
package and get the solution in which all equality constraints are
enforced. I also tried an old version of quadprog, Version: 1.4-11,
Date: 2007-07-12 and my problem is solved correctly.
I have tried to contact Berwin A. Turlach <Berwin.Turlach at gmail.com>
(maintainer for quadprog package) with no success.
##############################################################
load(file='quadprog.Rdata')
# solve QP using quadprog
require(quadprog)
sol = solve.QP(Dmat, dvec, Amat, bvec, meq)
x = sol$solution
check = x %*% Amat - bvec
# for some reason last equlity constraint is violated
round(check[1:meq], 4)
# solve QP using kernlab
require(kernlab)
n = nrow(Amat)
sv = ipop(c = matrix(dvec), H = Dmat, A = t(Amat[,1:meq]),
b = bvec[1:meq], l = rep(-1000, n),
u = rep(1000, n), r = rep(0,meq))
x = primal(sv)
check = x %*% Amat - bvec
# all constraints are ok
round(check[1:meq], 4)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: quadprog.Rdata
Type: application/octet-stream
Size: 3568 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20120315/e2dbe77b/attachment.obj>
More information about the R-SIG-Finance
mailing list