1

I am trying to solve quadratic problem in R. I have this data:

x1          x2      y
0.3858  0.4687      1 
0.4871  0.6110     -1
0.9218  0.4103     -1
0.7382  0.8936     -1
0.1763  0.0579      1
0.4057  0.3529      1
0.9355  0.8132     -1
0.2146  0.0099      1

And I need to figure out λ1 to λ8. I tried using the routine: solve.QP(Dmat, dvec, Amat, bvec, meq=0, factorized=FALSE) from package quadprog. I am confused what to input for dvec, bvec, Dmat in my case. I tried following but it doesn't give correct result:

Dmat <- matrix(0,8,8)
Amat<-   matrix(c(0.3858,0.4871,0.9218,0.7382,0.1763,0.4057,0.9355,0.2146,0.4687,0.611,0.4103,0.8936,0.0579,0.3529,0.8132,0.0099),8,2)
dvec<-c(1,-1,-1,-1,1,1,-1,1)
solve.QP(Dmat,dvec,Amat)

Result is supposed to be λ1 = 65.5261,λ2=65.5261, λ3 to λ8 = 0. Any help will be appreciated.

Ujjwal
  • 209
  • 2
  • 4
  • 10

1 Answers1

0

add diag(Dmat) <- 1 to your code.

Ramin Zahedi
  • 455
  • 2
  • 6
  • 20