1

I am trying to find the global minimum of this problem and I cannot figure out why I am getting the error above. I am trying to set 5 of the assets equal to the exact weights and optimize the other 5 within a range of values. I would prefer not to use the meq=5 option.

    dvec<-matrix(0, 1,ncol(dmat))

dmat
    A   B   C   D   E   F   G   H   I   J
A   6.85E-08    -0.000000039    -0.00000242 1.00E-07    -0.00000206 -0.00000102 -1.14E-07   -0.000000531    -0.00000137 -0.00000132
B   -3.90E-08   0.001124367 0.000190585 -2.08E-06   0.000221485 0.000153652 5.99E-05    0.000038    0.0000762   0.000200415
C   -2.42E-06   0.000190585 0.001730743 1.30E-07    0.000878497 0.000926944 6.45E-05    0.000339591 0.000958817 0.000665363
D   1.00E-07    -0.00000208 0.00000013  9.68E-07    -0.00000198 -0.00000106 -3.39E-07   0.000000912 0.00000142  0.00000279
E   -2.06E-06   0.000221485 0.000878497 -1.98E-06   0.000857829 0.000590873 4.15E-05    0.00025093  0.000521244 0.000455809
F   -1.02E-06   0.000153652 0.000926944 -1.06E-06   0.000590873 0.001226696 4.72E-05    0.000198401 0.000512625 0.000343511
G   -1.14E-07   0.0000599   0.0000645   -3.39E-07   0.0000415   0.0000472   4.45E-05    0.0000435   0.000052    0.0000425
H   -5.31E-07   0.000038    0.000339591 9.12E-07    0.00025093  0.000198401 4.35E-05    0.000362761 0.00031198  0.000224669
I   -1.37E-06   0.0000762   0.000958817 1.42E-06    0.000521244 0.000512625 5.20E-05    0.00031198  0.00096765  0.000514901
J   -1.32E-06   0.000200415 0.000665363 2.79E-06    0.000455809 0.000343511 4.25E-05    0.000224669 0.000514901 0.000748266

    amat
        A   B   C   D   E   F   G   H   I   J   A   B   C   D   E   F   G   H   I   J
    A   -1  0   0   0   0   0   0   0   0   0   1   0   0   0   0   0   0   0   0   0
    B   0   -1  0   0   0   0   0   0   0   0   0   1   0   0   0   0   0   0   0   0
    C   0   0   -1  0   0   0   0   0   0   0   0   0   1   0   0   0   0   0   0   0
    D   0   0   0   1   0   0   0   0   0   0   0   0   0   -1  0   0   0   0   0   0
    E   0   0   0   0   -1  0   0   0   0   0   0   0   0   0   1   0   0   0   0   0
    F   0   0   0   0   0   -1  0   0   0   0   0   0   0   0   0   1   0   0   0   0
    G   0   0   0   0   0   0   -1  0   0   0   0   0   0   0   0   0   1   0   0   0
    H   0   0   0   0   0   0   0   -1  0   0   0   0   0   0   0   0   0   1   0   0
    I   0   0   0   0   0   0   0   0   -1  0   0   0   0   0   0   0   0   0   1   0
    J   0   0   0   0   0   0   0   0   0   -1  0   0   0   0   0   0   0   0   0   1

bvec
    A   B   C   D   E   F   G   H   I   J   A   B   C   D   E   F   G   H   I   J
     (757,631)   (805)   (770,471)   (71,668)    (10,011,652)    (5,870,322)     (10,942,502)    (52,569)    (10,582,791)    (5,293,429)     -       -       -       -       -       5,870,322   10,942,502      52,569      10,582,791      5,293,429 

    sol<-solve.QP(dmat, dvec, amat, bvec, meq=0)
user3390169
  • 1,015
  • 1
  • 11
  • 34
  • kinda getting a hunch that your matrix is not positive definite. Would you mind checking? – abhiieor Jul 21 '16 at 17:08
  • so, I ran is.positive.definite(dmat) and it returned TRUE. But if I run is.positive.definite(dmat, tol=1e-7) it returns FALSE. Does solve.QP have a tolerance level? – user3390169 Jul 21 '16 at 17:20
  • Interestingly, if I multiply the first half of amat by .9999 it seems to work. – user3390169 Jul 21 '16 at 17:37
  • Solve.QP dont have any tolerance limit but Hessian should be positive definite which you are making after your aforementioned transformation. – abhiieor Jul 21 '16 at 17:39

1 Answers1

0

Error mentioned in the subject line could be due to NON positive-definiteness of matrix. As OP figured out is.positive.definite() is a way to check it.

abhiieor
  • 3,132
  • 4
  • 30
  • 47